Skip to content

Commit

Permalink
FE: Fix sorting connectors duplicates items (#119)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nilumilak authored Feb 16, 2024
1 parent b7db580 commit 877272b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions frontend/src/components/Connect/List/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const List: React.FC = () => {
navigate(clusterConnectConnectorPath(clusterName, connect, name))
}
emptyMessage="No connectors found"
setRowId={(originalRow) => `${originalRow.name}-${originalRow.connect}`}
/>
);
};
Expand Down
8 changes: 7 additions & 1 deletion frontend/src/components/common/NewTable/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ export interface TableProps<TData> {

onRowHover?: (row: Row<TData>) => void;
onMouseLeave?: () => void;

setRowId?: (originalRow: Row<TData>) => string;
}

type UpdaterFn<T> = (previousState: T) => T;
Expand Down Expand Up @@ -132,6 +134,7 @@ const Table: React.FC<TableProps<any>> = ({
onRowClick,
onRowHover,
onMouseLeave,
setRowId,
}) => {
const [searchParams, setSearchParams] = useSearchParams();
const location = useLocation();
Expand Down Expand Up @@ -164,7 +167,10 @@ const Table: React.FC<TableProps<any>> = ({
rowSelection,
},
getRowId: (originalRow, index) => {
return originalRow.name ? originalRow.name : `${index}`;
return (
setRowId?.(originalRow) ||
(originalRow.name ? originalRow.name : `${index}`)
);
},
onSortingChange: onSortingChange as OnChangeFn<SortingState>,
onPaginationChange: onPaginationChange as OnChangeFn<PaginationState>,
Expand Down

0 comments on commit 877272b

Please sign in to comment.