From 948bf5f1e58f1003630b3b564e813557d1f54d84 Mon Sep 17 00:00:00 2001 From: Daniel Kos Date: Tue, 26 Jun 2018 11:06:04 +0200 Subject: [PATCH] Navigation fixes Feature #13666 Arvados-DCO-1.1-Signed-off-by: Daniel Kos --- src/services/auth-service/auth-service.ts | 4 ++++ src/store/collection/collection-reducer.ts | 2 +- src/store/navigation/navigation-action.ts | 7 +++++-- src/store/project/project-reducer.ts | 8 ++++---- src/views/workbench/workbench.tsx | 4 +++- 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/services/auth-service/auth-service.ts b/src/services/auth-service/auth-service.ts index d71f0299..e953a75d 100644 --- a/src/services/auth-service/auth-service.ts +++ b/src/services/auth-service/auth-service.ts @@ -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; } diff --git a/src/store/collection/collection-reducer.ts b/src/store/collection/collection-reducer.ts index 939ca625..5c257ea4 100644 --- a/src/store/collection/collection-reducer.ts +++ b/src/store/collection/collection-reducer.ts @@ -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; diff --git a/src/store/navigation/navigation-action.ts b/src/store/navigation/navigation-action.ts index 6e4b4bef..9b4c88ea 100644 --- a/src/store/navigation/navigation-action.ts +++ b/src/store/navigation/navigation-action.ts @@ -42,14 +42,17 @@ export const setProjectItem = (projects: Array>, 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(getProjectList(itemId)) - .then(() => openProjectItem(treeItem.data)); + .then(() => openProjectItem(treeItem!.data)); } if (itemMode === ItemMode.ACTIVE || itemMode === ItemMode.BOTH) { dispatch(getCollectionList(itemId)); diff --git a/src/store/project/project-reducer.ts b/src/store/project/project-reducer.ts index 39d194dd..0e2018b4 100644 --- a/src/store/project/project-reducer.ts +++ b/src/store/project/project-reducer.ts @@ -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 diff --git a/src/views/workbench/workbench.tsx b/src/views/workbench/workbench.tsx index a597c597..e8b15f20 100644 --- a/src/views/workbench/workbench.tsx +++ b/src/views/workbench/workbench.tsx @@ -131,7 +131,9 @@ class Workbench extends React.Component { mainAppBarActions: MainAppBarActionProps = { onBreadcrumbClick: ({ itemId }: NavBreadcrumb) => { - // this.toggleProjectTreeItem(itemId, status); + this.props.dispatch( + setProjectItem(this.props.projects, itemId, ResourceKind.PROJECT, ItemMode.BOTH) + ); }, onSearch: searchText => { this.setState({ searchText }); -- 2.30.2