15768: made separate file for project panel action binding Arvados-DCO-1.1-Signed...
[arvados-workbench2.git] / src / store / project-panel / project-panel-action.ts
index e0d58247e713f226e33577b35be69be62de1b93c..305799e820f6c070a1797d457989ae022ff591c5 100644 (file)
@@ -2,7 +2,24 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-import { bindDataExplorerActions } from "../data-explorer/data-explorer-action";
-import { ProjectPanelMiddlewareService } from "./project-panel-middleware-service";
+import { Dispatch } from "redux";
+import { propertiesActions } from "store/properties/properties-actions";
+import { RootState } from "store/store";
+import { getProperty } from "store/properties/properties";
+import { loadProject } from "store/workbench/workbench-actions";
+import { projectPanelActions } from "store/project-panel/project-panel-action-bind";
 
-export const projectPanelActions = bindDataExplorerActions(ProjectPanelMiddlewareService.getInstance());
+export const PROJECT_PANEL_ID = "projectPanel";
+export const PROJECT_PANEL_CURRENT_UUID = "projectPanelCurrentUuid";
+export const IS_PROJECT_PANEL_TRASHED = "isProjectPanelTrashed";
+
+export const openProjectPanel = (projectUuid: string) => async (dispatch: Dispatch) => {
+    await dispatch<any>(loadProject(projectUuid));
+    dispatch(propertiesActions.SET_PROPERTY({ key: PROJECT_PANEL_CURRENT_UUID, value: projectUuid }));
+    dispatch(projectPanelActions.RESET_EXPLORER_SEARCH_VALUE());
+    dispatch(projectPanelActions.REQUEST_ITEMS());
+};
+
+export const getProjectPanelCurrentUuid = (state: RootState) => getProperty<string>(PROJECT_PANEL_CURRENT_UUID)(state.properties);
+
+export const setIsProjectPanelTrashed = (isTrashed: boolean) => propertiesActions.SET_PROPERTY({ key: IS_PROJECT_PANEL_TRASHED, value: isTrashed });