diff --git a/app/react/components/datatables/types.ts b/app/react/components/datatables/types.ts index 021bc6d5b..81a125e27 100644 --- a/app/react/components/datatables/types.ts +++ b/app/react/components/datatables/types.ts @@ -24,10 +24,11 @@ export interface SortableTableSettings { export function sortableSettings( set: Set, - initialSortBy = 'name' + initialSortBy = 'name', + desc = false ): SortableTableSettings { return { - sortBy: { id: initialSortBy, desc: false }, + sortBy: { id: initialSortBy, desc }, setSortBy: (id: string, desc: boolean) => set({ sortBy: { id, desc } }), }; } diff --git a/app/react/portainer/notifications/NotificationsView.tsx b/app/react/portainer/notifications/NotificationsView.tsx index 3b4069500..90dca55b0 100644 --- a/app/react/portainer/notifications/NotificationsView.tsx +++ b/app/react/portainer/notifications/NotificationsView.tsx @@ -18,7 +18,7 @@ import { columns } from './columns'; import { createStore } from './datatable-store'; const storageKey = 'notifications-list'; -const useSettingsStore = createStore(storageKey, 'time'); +const useSettingsStore = createStore(storageKey, 'time', true); export function NotificationsView() { const settingsStore = useSettingsStore(); diff --git a/app/react/portainer/notifications/datatable-store.ts b/app/react/portainer/notifications/datatable-store.ts index acc4e5770..d0e0e4c81 100644 --- a/app/react/portainer/notifications/datatable-store.ts +++ b/app/react/portainer/notifications/datatable-store.ts @@ -19,11 +19,15 @@ interface TableSettings SettableColumnsTableSettings, RefreshableTableSettings {} -export function createStore(storageKey: string, initialSortBy?: string) { +export function createStore( + storageKey: string, + initialSortBy?: string, + desc?: boolean +) { return create()( persist( (set) => ({ - ...sortableSettings(set, initialSortBy), + ...sortableSettings(set, initialSortBy, desc), ...paginationSettings(set), ...hiddenColumnsSettings(set), ...refreshableSettings(set),