Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
Signed-off-by: Andrei Stepanov <astepano@redhat.com>
  • Loading branch information
Andrei-Stepanov committed Oct 30, 2023
1 parent 03ffd18 commit 7c869d2
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/components/SSTResultsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import {
EmptyStateIcon,
EmptyStateVariant,
} from '@patternfly/react-core';
import ReactTable, {
import {
Table,
sortable,
cellWidth,
Expand All @@ -46,6 +46,10 @@ import ReactTable, {
TableHeader,
TableVariant,
SortByDirection,
ICell,
IRow,
ISortBy,
OnSort,
} from '@patternfly/react-table';
import classNames from 'classnames';
import { ApolloError } from '@apollo/client';
Expand All @@ -68,7 +72,7 @@ interface EmptyStateParam {
title: string;
}

const columns: ReactTable.ICell[] = [
const columns: ICell[] = [
{
/* 0 */
title: 'NVR',
Expand Down Expand Up @@ -121,7 +125,7 @@ const columns: ReactTable.ICell[] = [
},
];

function makeRow(row: SSTResult): ReactTable.IRow[] {
function makeRow(row: SSTResult): IRow[] {
const cells = [];
cells.push({
sortKey: row.nvr,
Expand Down Expand Up @@ -295,7 +299,7 @@ function makeEmptyStateRow({
icon,
icon_color,
title,
}: EmptyStateParam): ReactTable.IRow {
}: EmptyStateParam): IRow {
return {
heightAuto: true,
cells: [
Expand Down Expand Up @@ -325,8 +329,8 @@ interface ResultsTableProps {

export function ResultsTable(props: ResultsTableProps) {
const { error, loading, results } = props;
const [rows, setRows] = useState<ReactTable.IRow[]>([]);
const [sortBy, setSortBy] = useState<ReactTable.ISortBy>({});
const [rows, setRows] = useState<IRow[]>([]);
const [sortBy, setSortBy] = useState<ISortBy>({});

/** `columns` is global var, need to reset before previous render */
/** https://issues.redhat.com/browse/OSCI-3214 */
Expand Down Expand Up @@ -356,7 +360,7 @@ export function ResultsTable(props: ResultsTableProps) {
}
}, [error, loading, results]);

const onSort: ReactTable.OnSort = (_event, index, direction) => {
const onSort: OnSort = (_event, index, direction) => {
const sortedRows = rows.sort((a, b) =>
a[index].sortKey < b[index].sortKey
? -1
Expand Down

0 comments on commit 7c869d2

Please sign in to comment.