X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/45f4e01be5f55c1ba1ec21b3ca1b1371bed707ee..7ae86efd9905582df4191910528c3803a68ba81b:/src/store/navigation/navigation-action.ts diff --git a/src/store/navigation/navigation-action.ts b/src/store/navigation/navigation-action.ts index 50f6e205e0..f8687ed754 100644 --- a/src/store/navigation/navigation-action.ts +++ b/src/store/navigation/navigation-action.ts @@ -11,11 +11,13 @@ import { dataExplorerActions } from "../data-explorer/data-explorer-action"; import { PROJECT_PANEL_ID } from "../../views/project-panel/project-panel"; import { RootState } from "../store"; import { Resource, ResourceKind } from "../../models/resource"; +import { getCollectionUrl } from "../../models/collection"; +import { getProjectUrl } from "../../models/project"; export const getResourceUrl = (resource: T): string => { switch (resource.kind) { - case ResourceKind.Project: return `/projects/${resource.uuid}`; - case ResourceKind.Collection: return `/collections/${resource.uuid}`; + case ResourceKind.PROJECT: return getProjectUrl(resource.uuid); + case ResourceKind.COLLECTION: return getCollectionUrl(resource.uuid); default: return resource.href; } }; @@ -33,10 +35,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,12 +44,15 @@ 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(getProjectList(itemId)); promise .then(() => dispatch(() => { + 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})); }));