Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return;
cockpit.location.go(["nfs", row.props.entry.fields[0], row.props.entry.fields[1]]);
}
// table-hover class is needed till PF4 Table has proper support for clickable rows
// https://github.com/patternfly/patternfly-react/issues/3267
return (
);
}
}
var mounts = Object.keys(client.blocks).filter(is_mount)
.map(make_mount);
function onRowClick(event, row) {
if (!event || event.button !== 0)
return;
go_to_block(row.props.client, row.props.path);
}
// table-hover class is needed till PF4 Table has proper support for clickable rows
// https://github.com/patternfly/patternfly-react/issues/3267
return (
);
}
}
reset = () => {
this.setState(
{
page: 1,
sortBy: { index: 0, direction: SortByDirection.asc },
filterBy: {}
},
() => {
if (this.toolbarRef) {
this.toolbarRef.reset();
}
}
);
};
constructor(props) {
super(props);
const sortBy = {};
if ('sortBy' in props) {
sortBy.index = props.sortBy.index || 0;
sortBy.direction = props.sortBy.direction || SortByDirection.asc;
}
this.state = { sortBy };
this.onSort = this.onSort.bind(this);
}
componentDidMount() {
const { columns } = this.state;
const sp = new URLSearchParams(window.location.search);
const columnIndex = _.findIndex(columns, { title: sp.get('sortBy') });
if (columnIndex > -1) {
const sortOrder = sp.get('orderBy') || SortByDirection.asc;
const column = columns[columnIndex];
this._applySort(
column.sortField,
column.sortFunc,
column.sortAsNumber,
sortOrder,
column.title,
);
this.setState({
sortBy: {
index: columnIndex + this._columnShift,
direction: sortOrder,
},
});
}
onSort(_event, index, direction) {
const sortedRows = this.state.rows.sort((a, b) => {
if (a[index] < b[index]) {
return -1;
}
return a[index] > b[index] ? 1 : 0;
});
this.setState({
sortBy: {
index,
direction
},
rows: direction === SortByDirection.asc ? sortedRows : sortedRows.reverse()
});
}
constructor(props) {
super(props);
this.state = {
sortBy: propFromLocation(props, "sortBy", {
index: 0,
direction: SortByDirection.asc
}),
filterBy: propFromLocation(props, "filterBy", {}),
perPage: propFromLocation(props, "perPage", 10),
total: 1,
page: propFromLocation(props, "page", 1),
columns: [],
allRows: [],
rows: [],
redirect: false,
redirectState: {}
};
this.entity = this.props.service.utilities.entityFromProps(props);
if (!dataMap[this.entity]) {
this.state.redirect = true;
} else {
this.dataSource = new dataMap[this.entity](this.props.service);
onSort(_event, index, direction) {
const sortedRows = this.state.dataRows.sort((a, b) => (a[index] < b[index] ? -1 : a[index] > b[index] ? 1 : 0));
this.setState({
sortBy: {
index,
direction
},
rows:
direction === SortByDirection.asc
? this.processToComponents(sortedRows)
: this.processToComponents(sortedRows.reverse())
});
}
render() {
let pci = null;
let memory = null;
if (this.props.info.pci.length > 0) {
const sortedPci = this.props.info.pci.concat();
pci = (
({
columns: [dev.cls, dev.model, dev.vendor, dev.slot]
}))} />
);
}
if (this.props.info.memory.length > 0) {
memory = (
sortRows(rows) {
const { index, direction } = this.state.sortBy;
const sortedRows = rows.sort((a, b) => (a.cells[index].title.localeCompare(b.cells[index].title)));
return direction === SortByDirection.asc ? sortedRows : sortedRows.reverse();
}