Refactor to apply global navigation actions
[arvados-workbench2.git] / src / store / tree-picker / tree-picker.ts
index ee45beccd5451b11621dd136ad41ec183a23b6fa..fd104fe4b25695624c6ee771aa14f44a4921bb93 100644 (file)
@@ -2,22 +2,25 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-import { Tree } from "../../models/tree";
-import { TreeItemStatus } from "../../components/tree/tree";
+import { Tree } from "~/models/tree";
+import { TreeItemStatus } from "~/components/tree/tree";
+import { RootState } from '~/store/store';
 
-export type TreePicker = Tree<TreePickerNode>;
+export type TreePicker = { [key: string]: Tree<TreePickerNode> };
 
 export interface TreePickerNode {
-    id: string;
+    nodeId: string;
     value: any;
     selected: boolean;
     collapsed: boolean;
     status: TreeItemStatus;
 }
 
-export const createTreePickerNode = (data: {id: string, value: any}) => ({
+export const createTreePickerNode = (data: { nodeId: string, value: any }) => ({
     ...data,
     selected: false,
     collapsed: true,
     status: TreeItemStatus.INITIAL
-});
\ No newline at end of file
+});
+
+export const getTreePicker = (id: string) => (state: TreePicker): Tree<TreePickerNode> | undefined => state[id];
\ No newline at end of file