Refactor to apply global navigation actions
[arvados-workbench2.git] / src / store / tree-picker / tree-picker.ts
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import { Tree } from "~/models/tree";
6 import { TreeItemStatus } from "~/components/tree/tree";
7 import { RootState } from '~/store/store';
8
9 export type TreePicker = { [key: string]: Tree<TreePickerNode> };
10
11 export interface TreePickerNode {
12     nodeId: string;
13     value: any;
14     selected: boolean;
15     collapsed: boolean;
16     status: TreeItemStatus;
17 }
18
19 export const createTreePickerNode = (data: { nodeId: string, value: any }) => ({
20     ...data,
21     selected: false,
22     collapsed: true,
23     status: TreeItemStatus.INITIAL
24 });
25
26 export const getTreePicker = (id: string) => (state: TreePicker): Tree<TreePickerNode> | undefined => state[id];