mirror of https://github.com/portainer/portainer
fix(notifications): sort by newest first by default [EE-4467] (#7891)
parent
58947fee69
commit
c1f94be9b2
|
@ -24,10 +24,11 @@ export interface SortableTableSettings {
|
|||
|
||||
export function sortableSettings(
|
||||
set: Set<SortableTableSettings>,
|
||||
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 } }),
|
||||
};
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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<TableSettings>()(
|
||||
persist(
|
||||
(set) => ({
|
||||
...sortableSettings(set, initialSortBy),
|
||||
...sortableSettings(set, initialSortBy, desc),
|
||||
...paginationSettings(set),
|
||||
...hiddenColumnsSettings(set),
|
||||
...refreshableSettings(set),
|
||||
|
|
Loading…
Reference in New Issue