Merge branch 'master' into 14129-inputs-modal-new
[arvados.git] / src / store / workbench / workbench-actions.ts
index 774e96eb0b17243a1402c20bc33fb432472678a6..aaf8f2665f9a1b07318c6a9d3179a0fbd3727d5d 100644 (file)
@@ -7,7 +7,7 @@ import { RootState } from "../store";
 import { loadDetailsPanel } from '~/store/details-panel/details-panel-action';
 import { snackbarActions } from '../snackbar/snackbar-actions';
 import { loadFavoritePanel } from '../favorite-panel/favorite-panel-action';
-import { openProjectPanel, projectPanelActions } from '~/store/project-panel/project-panel-action';
+import { openProjectPanel, projectPanelActions, setIsProjectPanelTrashed } from '~/store/project-panel/project-panel-action';
 import { activateSidePanelTreeItem, initSidePanelTree, SidePanelTreeCategory, loadSidePanelTreeProjects } from '../side-panel-tree/side-panel-tree-actions';
 import { loadResource, updateResources } from '../resources/resources-actions';
 import { favoritePanelActions } from '~/store/favorite-panel/favorite-panel-action';
@@ -53,7 +53,6 @@ import { collectionPanelActions } from "~/store/collection-panel/collection-pane
 import { CollectionResource } from "~/models/collection";
 import { searchResultsPanelActions, loadSearchResultsPanel } from '~/store/search-results-panel/search-results-panel-actions';
 import { searchResultsPanelColumns } from '~/views/search-results-panel/search-results-panel-view';
-import * as uuid from 'uuid/v4';
 
 export const WORKBENCH_LOADING_SCREEN = 'workbenchLoadingScreen';
 
@@ -123,6 +122,7 @@ export const loadProject = (uuid: string) =>
     handleFirstTimeLoad(
         async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
             const userUuid = services.authService.getUuid();
+            dispatch(setIsProjectPanelTrashed(false));
             if (userUuid) {
                 if (userUuid !== uuid) {
                     const match = await loadGroupContentsResource({ uuid, userUuid, services });
@@ -134,11 +134,12 @@ export const loadProject = (uuid: string) =>
                         },
                         SHARED: project => {
                             dispatch<any>(setSharedWithMeBreadcrumbs(uuid));
-                            dispatch(activateSidePanelTreeItem(SidePanelTreeCategory.SHARED_WITH_ME));
+                            dispatch(activateSidePanelTreeItem(uuid));
                             dispatch(finishLoadingProject(project));
                         },
                         TRASHED: project => {
                             dispatch<any>(setTrashBreadcrumbs(uuid));
+                            dispatch(setIsProjectPanelTrashed(true));
                             dispatch(activateSidePanelTreeItem(SidePanelTreeCategory.TRASH));
                             dispatch(finishLoadingProject(project));
                         }
@@ -213,7 +214,7 @@ export const loadCollection = (uuid: string) =>
                         dispatch(collectionPanelActions.SET_COLLECTION(collection as CollectionResource));
                         dispatch(updateResources([collection]));
                         dispatch<any>(setSharedWithMeBreadcrumbs(collection.ownerUuid));
-                        dispatch(activateSidePanelTreeItem(SidePanelTreeCategory.SHARED_WITH_ME));
+                        dispatch(activateSidePanelTreeItem(collection.ownerUuid));
                         dispatch(loadCollectionFiles(collection.uuid));
                     },
                     TRASHED: collection => {
@@ -257,11 +258,10 @@ export const updateCollection = (data: collectionUpdateActions.CollectionUpdateF
 export const copyCollection = (data: CopyFormDialogData) =>
     async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
         try {
-            const oldProject = getResource(data.ownerUuid)(getState().resources);
+            const copyToProject = getResource(data.ownerUuid)(getState().resources);
             const collection = await dispatch<any>(collectionCopyActions.copyCollection(data));
-            // dispatch<any>(updateResources([collection]));
-            if (oldProject && collection) {
-                dispatch<any>(reloadProjectMatchingUuid([oldProject.uuid]));
+            if (copyToProject && collection) {
+                dispatch<any>(reloadProjectMatchingUuid([copyToProject.uuid]));
                 dispatch(snackbarActions.OPEN_SNACKBAR({
                     message: 'Collection has been copied.',
                     hideDuration: 3000,