Navigation fixes
authorDaniel Kos <daniel.kos@contractors.roche.com>
Tue, 26 Jun 2018 09:06:04 +0000 (11:06 +0200)
committerDaniel Kos <daniel.kos@contractors.roche.com>
Tue, 26 Jun 2018 09:06:04 +0000 (11:06 +0200)
Feature #13666

Arvados-DCO-1.1-Signed-off-by: Daniel Kos <daniel.kos@contractors.roche.com>

src/services/auth-service/auth-service.ts
src/store/collection/collection-reducer.ts
src/store/navigation/navigation-action.ts
src/store/project/project-reducer.ts
src/views/workbench/workbench.tsx

index d71f0299aa6cd866d30da96dd59fd69e17b94f03..e953a75d14aabbcd52a2d61fcf32e260d83717f3 100644 (file)
@@ -35,6 +35,10 @@ export default class AuthService {
         return localStorage.getItem(API_TOKEN_KEY) || undefined;
     }
 
+    public getUuid() {
+        return localStorage.getItem(USER_UUID_KEY) || undefined;
+    }
+
     public getOwnerUuid() {
         return localStorage.getItem(USER_OWNER_UUID_KEY) || undefined;
     }
index 939ca625bf5627f84e1bb509a6f9049725dd8eb4..5c257ea43bf0cb89dbbb05f3c71dc3131cfb3096 100644 (file)
@@ -13,7 +13,7 @@ const collectionsReducer = (state: CollectionState = [], action: CollectionActio
         CREATE_COLLECTION: collection => [...state, collection],
         REMOVE_COLLECTION: () => state,
         COLLECTIONS_REQUEST: () => {
-            return state;
+            return [];
         },
         COLLECTIONS_SUCCESS: ({ collections }) => {
             return collections;
index 6e4b4bef38cd158c52f2ccd2001839cd2ef97e44..9b4c88eac845a7df4317a0b4403cef5288f6c5c6 100644 (file)
@@ -42,14 +42,17 @@ export const setProjectItem = (projects: Array<TreeItem<Project>>, itemId: strin
 
         dispatch(push(getResourceUrl({...resource, kind: itemKind})));
     };
-    const treeItem = findTreeItem(projects, itemId);
+    let treeItem = findTreeItem(projects, itemId);
+    if (treeItem && itemKind === ResourceKind.LEVEL_UP) {
+        treeItem = findTreeItem(projects, treeItem.data.ownerUuid);
+    }
 
     if (treeItem) {
         if (treeItem.status === TreeItemStatus.Loaded) {
             openProjectItem(treeItem.data);
         } else {
             dispatch<any>(getProjectList(itemId))
-                .then(() => openProjectItem(treeItem.data));
+                .then(() => openProjectItem(treeItem!.data));
         }
         if (itemMode === ItemMode.ACTIVE || itemMode === ItemMode.BOTH) {
             dispatch<any>(getCollectionList(itemId));
index 39d194ddbd96435dccea29116faa2739dd1653eb..0e2018b41c3830784c24b9615ad8b08db40cf70c 100644 (file)
@@ -123,8 +123,8 @@ const projectsReducer = (state: ProjectState = { items: [], currentItemId: "" },
                 item.open = !item.open;
             }
             return {
-                ...state,
-                items
+                items,
+                currentItemId: itemId
             };
         },
         TOGGLE_PROJECT_TREE_ITEM_ACTIVE: itemId => {
@@ -143,8 +143,8 @@ const projectsReducer = (state: ProjectState = { items: [], currentItemId: "" },
             const items = _.cloneDeep(state.items);
             resetTreeActivity(items);
             return {
-                ...state,
-                items
+                items,
+                currentItemId: ""
             };
         },
         default: () => state
index a597c5973f0cc35699b315186304bc3ebbe8f2a7..e8b15f206d213b66e7d3f97feb2f7ac647e3d131 100644 (file)
@@ -131,7 +131,9 @@ class Workbench extends React.Component<WorkbenchProps, WorkbenchState> {
 
     mainAppBarActions: MainAppBarActionProps = {
         onBreadcrumbClick: ({ itemId }: NavBreadcrumb) => {
-            // this.toggleProjectTreeItem(itemId, status);
+            this.props.dispatch<any>(
+                setProjectItem(this.props.projects, itemId, ResourceKind.PROJECT, ItemMode.BOTH)
+            );
         },
         onSearch: searchText => {
             this.setState({ searchText });