1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-08-02 20:35:25 +02:00

fix(services): separate table state [BE-11401] (#152)

This commit is contained in:
Ali 2024-12-11 11:58:43 +13:00 committed by GitHub
parent 52c90d4d0a
commit 069f22afa4
4 changed files with 25 additions and 16 deletions

View file

@ -28,34 +28,35 @@ import { TableActions } from './TableActions';
import { type TableSettings as TableSettingsType } from './types';
import { TableSettings } from './TableSettings';
const tableKey = 'services';
const store = createPersistedStore<TableSettingsType>(
tableKey,
'name',
(set) => ({
...refreshableSettings(set),
...hiddenColumnsSettings(set),
expanded: {},
setExpanded(value) {
set({ expanded: value });
},
})
);
export function ServicesDatatable({
titleIcon = Shuffle,
dataset,
isAddActionVisible,
isStackColumnVisible,
onRefresh,
tableKey,
}: {
dataset: Array<ServiceViewModel> | undefined;
titleIcon?: IconProps['icon'];
isAddActionVisible?: boolean;
isStackColumnVisible?: boolean;
onRefresh?(): void;
tableKey: string;
}) {
// use a unique tableKey so that unrelated services datatables don't share state
const store = createPersistedStore<TableSettingsType>(
tableKey,
'name',
(set) => ({
...refreshableSettings(set),
...hiddenColumnsSettings(set),
expanded: {},
setExpanded(value) {
set({ expanded: value });
},
})
);
// useRef so that updating the parent filter doesn't cause a re-render
const parentFilteredStatusRef = useRef<Map<string, boolean>>(new Map());
const environmentId = useEnvironmentId();