Merge branch 'master' into 13883-arrow-animation-is-not-working-after-loading
[arvados-workbench2.git] / src / store / navigation / navigation-action.ts
index 3920b5a27c69bf17cfbeca27a7c0bda562662f47..52086231742d8d9f37925c11cd41e95ef4395603 100644 (file)
@@ -14,8 +14,8 @@ import { Resource, ResourceKind } from "../../models/resource";
 
 export const getResourceUrl = <T extends Resource>(resource: T): string => {
     switch (resource.kind) {
-        case ResourceKind.Project: return `/projects/${resource.uuid}`;
-        case ResourceKind.Collection: return `/collections/${resource.uuid}`;
+        case ResourceKind.PROJECT: return `/projects/${resource.uuid}`;
+        case ResourceKind.COLLECTION: return `/collections/${resource.uuid}`;
         default: return resource.href;
     }
 };
@@ -33,10 +33,6 @@ export const setProjectItem = (itemId: string, itemMode: ItemMode) =>
 
         if (treeItem) {
 
-            if (itemMode === ItemMode.OPEN || itemMode === ItemMode.BOTH) {
-                dispatch(projectActions.TOGGLE_PROJECT_TREE_ITEM_OPEN(treeItem.data.uuid));
-            }
-
             const resourceUrl = getResourceUrl(treeItem.data);
 
             if (itemMode === ItemMode.ACTIVE || itemMode === ItemMode.BOTH) {
@@ -46,15 +42,19 @@ export const setProjectItem = (itemId: string, itemMode: ItemMode) =>
                 dispatch(projectActions.TOGGLE_PROJECT_TREE_ITEM_ACTIVE(treeItem.data.uuid));
             }
 
-            const promise = treeItem.status === TreeItemStatus.Loaded
+            const promise = treeItem.status === TreeItemStatus.LOADED
                 ? Promise.resolve()
                 : dispatch<any>(getProjectList(itemId));
 
             promise
                 .then(() => dispatch<any>(() => {
+                    if (itemMode === ItemMode.OPEN || itemMode === ItemMode.BOTH) {
+                        dispatch(projectActions.TOGGLE_PROJECT_TREE_ITEM_OPEN(treeItem.data.uuid));
+                    }
                     dispatch(dataExplorerActions.RESET_PAGINATION({id: PROJECT_PANEL_ID}));
                     dispatch(dataExplorerActions.REQUEST_ITEMS({id: PROJECT_PANEL_ID}));
                 }));
 
         }
     };
+