Save sorting order when changing view (#2353)

Signed-off-by: vshakirova <vshakirova@mirantis.com>
This commit is contained in:
Violetta authored and GitHub committed 2021-04-01 10:29:17 -04:00
1 parent 48ea877cd5
commit 33c405bdcf
8 files changed
+44 -11

No files matched your search

@@ -0,0 +1,22 @@
import { createStorage } from "../../utils";
import { TableSortParams } from "./table";
export interface TableStorageModel {
sortParams: {
[tableId: string]: Partial<TableSortParams>;
}
}
export const tableStorage = createStorage<TableStorageModel>("table_settings", {
sortParams: {}
});
export function getSortParams(tableId: string): Partial<TableSortParams> {
return tableStorage.get().sortParams[tableId];
}
export function setSortParams(tableId: string, sortParams: Partial<TableSortParams>) {
tableStorage.merge(draft => {
draft.sortParams[tableId] = sortParams;
});
}