X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/4ea2ff188ec745966387ce8bbe14880bfeede863..6fdd4a4d609cf8fa459786f42eb337f8da6a5afa:/src/store/side-panel-tree/side-panel-tree-actions.ts diff --git a/src/store/side-panel-tree/side-panel-tree-actions.ts b/src/store/side-panel-tree/side-panel-tree-actions.ts index 09009930..4aa5e26e 100644 --- a/src/store/side-panel-tree/side-panel-tree-actions.ts +++ b/src/store/side-panel-tree/side-panel-tree-actions.ts @@ -5,6 +5,7 @@ import { Dispatch } from 'redux'; import { treePickerActions } from "~/store/tree-picker/tree-picker-actions"; import { RootState } from '~/store/store'; +import { getUserUuid } from "~/common/getuser"; import { ServiceRepository } from '~/services/services'; import { FilterBuilder } from '~/services/api/filter-builder'; import { resourcesActions } from '~/store/resources/resources-actions'; @@ -19,6 +20,7 @@ import { GroupClass } from '~/models/group'; export enum SidePanelTreeCategory { PROJECTS = 'Projects', SHARED_WITH_ME = 'Shared with me', + PUBLIC_FAVORITES = 'Public Favorites', WORKFLOWS = 'Workflows', FAVORITES = 'Favorites', TRASH = 'Trash' @@ -42,6 +44,7 @@ export const getSidePanelTreeBranch = (uuid: string) => (treePicker: TreePicker) }; const SIDE_PANEL_CATEGORIES = [ + SidePanelTreeCategory.PUBLIC_FAVORITES, SidePanelTreeCategory.WORKFLOWS, SidePanelTreeCategory.FAVORITES, SidePanelTreeCategory.TRASH, @@ -50,8 +53,11 @@ const SIDE_PANEL_CATEGORIES = [ export const isSidePanelTreeCategory = (id: string) => SIDE_PANEL_CATEGORIES.some(category => category === id); export const initSidePanelTree = () => - (dispatch: Dispatch, _: () => RootState, { authService }: ServiceRepository) => { - const rootProjectUuid = authService.getUuid() || ''; + (dispatch: Dispatch, getState: () => RootState, { authService }: ServiceRepository) => { + const rootProjectUuid = getUserUuid(getState()); + if (!rootProjectUuid) { + return; + } const nodes = SIDE_PANEL_CATEGORIES.map(id => initTreeNode({ id, value: id })); const projectsNode = initTreeNode({ id: rootProjectUuid, value: SidePanelTreeCategory.PROJECTS }); const sharedNode = initTreeNode({ id: SidePanelTreeCategory.SHARED_WITH_ME, value: SidePanelTreeCategory.SHARED_WITH_ME }); @@ -104,13 +110,14 @@ const loadSharedRoot = async (dispatch: Dispatch, _: () => RootState, services: dispatch(treePickerActions.LOAD_TREE_PICKER_NODE({ id: SidePanelTreeCategory.SHARED_WITH_ME, pickerId: SIDE_PANEL_TREE })); const params = { - filters: `[${new FilterBuilder() + filters: `[${new FilterBuilder() .addIsA('uuid', ResourceKind.PROJECT) .addEqual('groupClass', GroupClass.PROJECT) .getFilters()}]`, order: new OrderBuilder() .addAsc('name', GroupContentsResourcePrefix.PROJECT) .getOrder(), + limit: 1000 }; const { items } = await services.groupsService.shared(params); @@ -152,9 +159,13 @@ export const activateSidePanelTreeProject = (id: string) => }; export const activateSidePanelTreeBranch = (id: string) => - async (dispatch: Dispatch, _: void, services: ServiceRepository) => { - const ancestors = await services.ancestorsService.ancestors(id, services.authService.getUuid() || ''); - const isShared = ancestors.every(({ uuid }) => uuid !== services.authService.getUuid()); + async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { + const userUuid = getUserUuid(getState()); + if (!userUuid) { + return; + } + const ancestors = await services.ancestorsService.ancestors(id, userUuid); + const isShared = ancestors.every(({ uuid }) => uuid !== userUuid); if (isShared) { await dispatch(loadSidePanelTreeProjects(SidePanelTreeCategory.SHARED_WITH_ME)); }