Skip to content

Commit

Permalink
fix(sources): fix sorting by connection and type (#266)
Browse files Browse the repository at this point in the history
  • Loading branch information
gitdallas authored Dec 18, 2023
1 parent 844f6e5 commit 056a268
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/pages/sources/SourcesListView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ const SourcesListView: React.FunctionComponent = () => {
setAlerts((prevAlerts) => [...prevAlerts.filter((alert) => alert.key !== key)]);
};

enum columnOrderMap {
name = "name",
connection = "most_recent_connect_scan__start_time",
type = "source_type",
}

const tableState = useTableState({
persistTo: 'urlParams',
isSelectionEnabled: true,
Expand Down Expand Up @@ -160,14 +166,12 @@ const SourcesListView: React.FunctionComponent = () => {
}
],
// Because isSortEnabled is true, TypeScript will require these sort-related properties:
sortableColumns: ['name', 'connection', 'type', 'credentials', 'unreachableSystems'],
sortableColumns: ['name', 'connection', 'type'],
initialSort: {
columnKey: sortColumn as
| 'name'
| 'connection'
| 'type'
| 'credentials'
| 'unreachableSystems',
| 'type',
direction: sortDirection as 'asc' | 'desc'
},
initialFilterValues: filters ? JSON.parse(filters) : undefined
Expand All @@ -187,9 +191,8 @@ const SourcesListView: React.FunctionComponent = () => {
.map(key => `${key}=${filterValues[key]}`)
.join('&')
: null;

const ordering = `${(activeSort?.direction ?? sortDirection) === 'desc' ? '-' : ''}${
activeSort?.columnKey ?? sortColumn
activeSort?.columnKey ? columnOrderMap[activeSort.columnKey] : sortColumn
}`;

const query =
Expand Down

0 comments on commit 056a268

Please sign in to comment.