feat(edge/stacks): default refresh rate to 10s [EE-7155] (#11891)

pull/11913/head
Chaim Lev-Ari 2024-06-09 14:17:21 +03:00 committed by GitHub
parent eb6d251a73
commit b0e3afa0b6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 7 deletions

View File

@ -53,10 +53,11 @@ export interface SettableColumnsTableSettings {
}
export function hiddenColumnsSettings<T extends SettableColumnsTableSettings>(
set: ZustandSetFunc<T>
set: ZustandSetFunc<T>,
initialHiddenColumns: string[] = []
): SettableColumnsTableSettings {
return {
hiddenColumns: [],
hiddenColumns: initialHiddenColumns,
setHiddenColumns: (hiddenColumns: string[]) =>
set((s) => ({ ...s, hiddenColumns })),
};
@ -68,10 +69,11 @@ export interface RefreshableTableSettings {
}
export function refreshableSettings<T extends RefreshableTableSettings>(
set: ZustandSetFunc<T>
set: ZustandSetFunc<T>,
autoRefreshRate = 0
): RefreshableTableSettings {
return {
autoRefreshRate: 0,
autoRefreshRate,
setAutoRefreshRate: (autoRefreshRate: number) =>
set((s) => ({ ...s, autoRefreshRate })),
};
@ -113,6 +115,7 @@ export function createPersistedStore<T extends BasicTableSettings>(
}) as T,
{
name: keyBuilder(`datatable_settings_${storageKey}`),
version: 1,
}
)
);

View File

@ -12,9 +12,12 @@ export interface TableSettings
SettableColumnsTableSettings,
RefreshableTableSettings {}
export function createStore(storageKey: string) {
export function createStore(
storageKey: string,
initialHiddenColumns: string[] = []
) {
return createPersistedStore<TableSettings>(storageKey, 'name', (set) => ({
...hiddenColumnsSettings(set),
...refreshableSettings(set),
...hiddenColumnsSettings(set, initialHiddenColumns),
...refreshableSettings(set, 10),
}));
}