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(
|
export function sortableSettings(
|
||||||
set: Set<SortableTableSettings>,
|
set: Set<SortableTableSettings>,
|
||||||
initialSortBy = 'name'
|
initialSortBy = 'name',
|
||||||
|
desc = false
|
||||||
): SortableTableSettings {
|
): SortableTableSettings {
|
||||||
return {
|
return {
|
||||||
sortBy: { id: initialSortBy, desc: false },
|
sortBy: { id: initialSortBy, desc },
|
||||||
setSortBy: (id: string, desc: boolean) => set({ sortBy: { id, desc } }),
|
setSortBy: (id: string, desc: boolean) => set({ sortBy: { id, desc } }),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ import { columns } from './columns';
|
||||||
import { createStore } from './datatable-store';
|
import { createStore } from './datatable-store';
|
||||||
|
|
||||||
const storageKey = 'notifications-list';
|
const storageKey = 'notifications-list';
|
||||||
const useSettingsStore = createStore(storageKey, 'time');
|
const useSettingsStore = createStore(storageKey, 'time', true);
|
||||||
|
|
||||||
export function NotificationsView() {
|
export function NotificationsView() {
|
||||||
const settingsStore = useSettingsStore();
|
const settingsStore = useSettingsStore();
|
||||||
|
|
|
@ -19,11 +19,15 @@ interface TableSettings
|
||||||
SettableColumnsTableSettings,
|
SettableColumnsTableSettings,
|
||||||
RefreshableTableSettings {}
|
RefreshableTableSettings {}
|
||||||
|
|
||||||
export function createStore(storageKey: string, initialSortBy?: string) {
|
export function createStore(
|
||||||
|
storageKey: string,
|
||||||
|
initialSortBy?: string,
|
||||||
|
desc?: boolean
|
||||||
|
) {
|
||||||
return create<TableSettings>()(
|
return create<TableSettings>()(
|
||||||
persist(
|
persist(
|
||||||
(set) => ({
|
(set) => ({
|
||||||
...sortableSettings(set, initialSortBy),
|
...sortableSettings(set, initialSortBy, desc),
|
||||||
...paginationSettings(set),
|
...paginationSettings(set),
|
||||||
...hiddenColumnsSettings(set),
|
...hiddenColumnsSettings(set),
|
||||||
...refreshableSettings(set),
|
...refreshableSettings(set),
|
||||||
|
|
Loading…
Reference in New Issue