How to use the @patternfly/react-table.SortByDirection.asc function in @patternfly/react-table

To help you get started, we’ve selected a few @patternfly/react-table examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cockpit-project / cockpit / pkg / storaged / nfs-panel.jsx View on Github external
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 (
            
                
            
        );
    }
}
github cockpit-project / cockpit / pkg / storaged / fsys-panel.jsx View on Github external
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 (
            
                
            
        );
    }
}
github apache / qpid-dispatch / console / react / src / details / entityListTable.js View on Github external
reset = () => {
    this.setState(
      {
        page: 1,
        sortBy: { index: 0, direction: SortByDirection.asc },
        filterBy: {}
      },
      () => {
        if (this.toolbarRef) {
          this.toolbarRef.reset();
        }
      }
    );
  };
github cockpit-project / cockpit / pkg / lib / cockpit-components-table.jsx View on Github external
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);
    }
github openshift / console / frontend / public / components / factory / table.tsx View on Github external
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,
          },
        });
      }
github patternfly / patternfly-react / packages / patternfly-4 / react-table / src / components / Table / demo / DemoSortableTable.js View on Github external
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()
    });
  }
github apache / qpid-dispatch / console / react / src / overview / overviewTable.js View on Github external
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);
github patternfly / patternfly-react / packages / patternfly-4 / react-docs / src / components / css-variables.js View on Github external
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())
    });
  }
github cockpit-project / cockpit / pkg / systemd / hwinfo.jsx View on Github external
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 = (
github cockpit-project / cockpit / pkg / lib / cockpit-components-table.jsx View on Github external
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();
    }