21128: Merge commit 'adbbc9e3c7a36d39b30f403555ee5889e32adcc0' into 21128-toolbar...
[arvados.git] / services / workbench2 / src / store / workbench / workbench-actions.ts
index b03400d5ae28c7abc55b86ac5e0f01e99668e95a..b286186aba5eb71a9803fe096e9022c7ecfbcba2 100644 (file)
@@ -15,13 +15,13 @@ import {
     initSidePanelTree,
     loadSidePanelTreeProjects,
     SidePanelTreeCategory,
+    SIDE_PANEL_TREE, 
 } from "store/side-panel-tree/side-panel-tree-actions";
 import { updateResources } from "store/resources/resources-actions";
 import { projectPanelColumns } from "views/project-panel/project-panel";
 import { favoritePanelColumns } from "views/favorite-panel/favorite-panel";
 import { matchRootRoute } from "routes/routes";
 import {
-    setBreadcrumbs,
     setGroupDetailsBreadcrumbs,
     setGroupsBreadcrumbs,
     setProcessBreadcrumbs,
@@ -31,6 +31,10 @@ import {
     setUsersBreadcrumbs,
     setMyAccountBreadcrumbs,
     setUserProfileBreadcrumbs,
+    setInstanceTypesBreadcrumbs,
+    setVirtualMachinesBreadcrumbs,
+    setVirtualMachinesAdminBreadcrumbs,
+    setRepositoriesBreadcrumbs,
 } from "store/breadcrumbs/breadcrumbs-actions";
 import { navigateTo, navigateToRootProject } from "store/navigation/navigation-action";
 import { MoveToFormDialogData } from "store/move-to-dialog/move-to-dialog";
@@ -50,6 +54,7 @@ import { trashPanelColumns } from "views/trash-panel/trash-panel";
 import { loadTrashPanel, trashPanelActions } from "store/trash-panel/trash-panel-action";
 import { loadProcessPanel } from "store/process-panel/process-panel-actions";
 import { loadSharedWithMePanel, sharedWithMePanelActions } from "store/shared-with-me-panel/shared-with-me-panel-actions";
+import { sharedWithMePanelColumns } from "views/shared-with-me-panel/shared-with-me-panel";
 import { CopyFormDialogData } from "store/copy-dialog/copy-dialog";
 import { workflowPanelActions } from "store/workflow-panel/workflow-panel-actions";
 import { loadSshKeysPanel } from "store/auth/auth-action-ssh";
@@ -94,10 +99,10 @@ import { subprocessPanelActions } from "store/subprocess-panel/subprocess-panel-
 import { subprocessPanelColumns } from "views/subprocess-panel/subprocess-panel-root";
 import { loadAllProcessesPanel, allProcessesPanelActions } from "../all-processes-panel/all-processes-panel-action";
 import { allProcessesPanelColumns } from "views/all-processes-panel/all-processes-panel";
-import { AdminMenuIcon } from "components/icon/icon";
 import { userProfileGroupsColumns } from "views/user-profile-panel/user-profile-panel-root";
 import { selectedToArray, selectedToKindSet } from "components/multiselect-toolbar/MultiselectToolbar";
 import { multiselectActions } from "store/multiselect/multiselect-actions";
+import { treePickerActions } from "store/tree-picker/tree-picker-actions";
 
 export const WORKBENCH_LOADING_SCREEN = "workbenchLoadingScreen";
 
@@ -109,6 +114,12 @@ export const isWorkbenchLoading = (state: RootState) => {
 export const handleFirstTimeLoad = (action: any) => async (dispatch: Dispatch<any>, getState: () => RootState) => {
     try {
         await dispatch(action);
+    } catch (e) {
+        snackbarActions.OPEN_SNACKBAR({
+            message: "Error " + e,
+            hideDuration: 8000,
+            kind: SnackbarKind.WARNING,
+        })
     } finally {
         if (isWorkbenchLoading(getState())) {
             dispatch(progressIndicatorActions.STOP_WORKING(WORKBENCH_LOADING_SCREEN));
@@ -134,7 +145,7 @@ export const loadWorkbench = () => async (dispatch: Dispatch, getState: () => Ro
             })
         );
         dispatch(trashPanelActions.SET_COLUMNS({ columns: trashPanelColumns }));
-        dispatch(sharedWithMePanelActions.SET_COLUMNS({ columns: projectPanelColumns }));
+        dispatch(sharedWithMePanelActions.SET_COLUMNS({ columns: sharedWithMePanelColumns }));
         dispatch(workflowPanelActions.SET_COLUMNS({ columns: workflowPanelColumns }));
         dispatch(
             searchResultsPanelActions.SET_FETCH_MODE({
@@ -328,7 +339,7 @@ export const moveProject =
                 } catch (e) {
                     dispatch(
                         snackbarActions.OPEN_SNACKBAR({
-                            message: e.message,
+                            message: !!(project as any).frozenByUuid ? 'Could not move frozen project.' : e.message,
                             hideDuration: 2000,
                             kind: SnackbarKind.ERROR,
                         })
@@ -735,23 +746,30 @@ export const loadLinks = handleFirstTimeLoad(async (dispatch: Dispatch<any>) =>
 
 export const loadVirtualMachines = handleFirstTimeLoad(async (dispatch: Dispatch<any>) => {
     await dispatch(loadVirtualMachinesPanel());
-    dispatch(setBreadcrumbs([{ label: "Virtual Machines" }]));
+    dispatch(setVirtualMachinesBreadcrumbs());
+    dispatch<any>(activateSidePanelTreeItem(SidePanelTreeCategory.SHELL_ACCESS));
 });
 
 export const loadVirtualMachinesAdmin = handleFirstTimeLoad(async (dispatch: Dispatch<any>) => {
     await dispatch(loadVirtualMachinesPanel());
-    dispatch(setBreadcrumbs([{ label: "Virtual Machines Admin", icon: AdminMenuIcon }]));
+    dispatch(setVirtualMachinesAdminBreadcrumbs());
+    dispatch(treePickerActions.DEACTIVATE_TREE_PICKER_NODE({pickerId: SIDE_PANEL_TREE} ))
 });
 
 export const loadRepositories = handleFirstTimeLoad(async (dispatch: Dispatch<any>) => {
     await dispatch(loadRepositoriesPanel());
-    dispatch(setBreadcrumbs([{ label: "Repositories" }]));
+    dispatch(setRepositoriesBreadcrumbs());
 });
 
 export const loadSshKeys = handleFirstTimeLoad(async (dispatch: Dispatch<any>) => {
     await dispatch(loadSshKeysPanel());
 });
 
+export const loadInstanceTypes = handleFirstTimeLoad(async (dispatch: Dispatch<any>) => {
+    dispatch<any>(activateSidePanelTreeItem(SidePanelTreeCategory.INSTANCE_TYPES));
+    dispatch(setInstanceTypesBreadcrumbs());
+});
+
 export const loadSiteManager = handleFirstTimeLoad(async (dispatch: Dispatch<any>) => {
     await dispatch(loadSiteManagerPanel());
 });