Merge branch '20943-trashed-role-groups' refs #20943
[arvados.git] / services / workbench2 / src / store / project-panel / project-panel-action.ts
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import { Dispatch } from "redux";
6 import { propertiesActions } from "store/properties/properties-actions";
7 import { RootState } from "store/store";
8 import { getProperty } from "store/properties/properties";
9 import { loadProject } from "store/workbench/workbench-actions";
10 import { projectPanelRunActions, projectPanelDataActions } from "store/project-panel/project-panel-action-bind";
11
12 export const PROJECT_PANEL_CURRENT_UUID = "projectPanelCurrentUuid";
13 export const IS_PROJECT_PANEL_TRASHED = "isProjectPanelTrashed";
14
15 export const openProjectPanel = (projectUuid: string) => async (dispatch: Dispatch) => {
16     await dispatch<any>(loadProject(projectUuid));
17     dispatch(propertiesActions.SET_PROPERTY({ key: PROJECT_PANEL_CURRENT_UUID, value: projectUuid }));
18
19     dispatch(projectPanelDataActions.RESET_EXPLORER_SEARCH_VALUE());
20     dispatch(projectPanelDataActions.REQUEST_ITEMS());
21
22     dispatch(projectPanelRunActions.RESET_EXPLORER_SEARCH_VALUE());
23     dispatch(projectPanelRunActions.REQUEST_ITEMS());
24 };
25
26 export const getProjectPanelCurrentUuid = (state: RootState) => getProperty<string>(PROJECT_PANEL_CURRENT_UUID)(state.properties);
27
28 export const setIsProjectPanelTrashed = (isTrashed: boolean) => propertiesActions.SET_PROPERTY({ key: IS_PROJECT_PANEL_TRASHED, value: isTrashed });