Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(sources): fix sorting by connection and type #266

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading