X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/1f9a8ec32f818d8e78d683ad5569b9e4ae0f693a..c859c9d9325e2ed86d5d7b067e1209e73ee81251:/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 b26b8a51..ff506103 100644 --- a/src/store/side-panel-tree/side-panel-tree-actions.ts +++ b/src/store/side-panel-tree/side-panel-tree-actions.ts @@ -4,24 +4,27 @@ import { Dispatch } from 'redux'; import { treePickerActions } from "~/store/tree-picker/tree-picker-actions"; -import { RootState } from '../store'; +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 '../resources/resources-actions'; -import { getTreePicker, TreePicker } from '../tree-picker/tree-picker'; +import { resourcesActions } from '~/store/resources/resources-actions'; +import { getTreePicker, TreePicker } from '~/store/tree-picker/tree-picker'; import { getNodeAncestors, getNodeAncestorsIds, getNode, TreeNode, initTreeNode, TreeNodeStatus } from '~/models/tree'; import { ProjectResource } from '~/models/project'; -import { OrderBuilder } from '../../services/api/order-builder'; +import { OrderBuilder } from '~/services/api/order-builder'; import { ResourceKind } from '~/models/resource'; -import { GroupContentsResourcePrefix } from '../../services/groups-service/groups-service'; +import { GroupContentsResourcePrefix } from '~/services/groups-service/groups-service'; +import { GroupClass } from '~/models/group'; export enum SidePanelTreeCategory { PROJECTS = 'Projects', SHARED_WITH_ME = 'Shared with me', + PUBLIC_FAVORITES = 'Public Favorites', WORKFLOWS = 'Workflows', - RECENT_OPEN = 'Recently open', - FAVORITES = 'Favorites', - TRASH = 'Trash' + FAVORITES = 'My Favorites', + TRASH = 'Trash', + ALL_PROCESSES = 'All Processes' } export const SIDE_PANEL_TREE = 'sidePanelTree'; @@ -42,17 +45,19 @@ export const getSidePanelTreeBranch = (uuid: string) => (treePicker: TreePicker) }; const SIDE_PANEL_CATEGORIES = [ - SidePanelTreeCategory.WORKFLOWS, - SidePanelTreeCategory.RECENT_OPEN, + SidePanelTreeCategory.PUBLIC_FAVORITES, SidePanelTreeCategory.FAVORITES, + SidePanelTreeCategory.WORKFLOWS, + SidePanelTreeCategory.ALL_PROCESSES, SidePanelTreeCategory.TRASH, ]; 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 }); @@ -86,7 +91,7 @@ const loadProject = (projectUuid: string) => dispatch(treePickerActions.LOAD_TREE_PICKER_NODE({ id: projectUuid, pickerId: SIDE_PANEL_TREE })); const params = { filters: new FilterBuilder() - .addEqual('ownerUuid', projectUuid) + .addEqual('owner_uuid', projectUuid) .getFilters(), order: new OrderBuilder() .addAsc('name') @@ -101,20 +106,22 @@ const loadProject = (projectUuid: string) => dispatch(resourcesActions.SET_RESOURCES(items)); }; -const loadSharedRoot = async (dispatch: Dispatch, _: () => RootState, services: ServiceRepository) => { +const loadSharedRoot = async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { 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) - .getFilters(), + .addEqual('group_class', GroupClass.PROJECT) + .addDistinct('uuid', getState().auth.config.uuidPrefix + '-j7d0g-publicfavorites') + .getFilters()}]`, order: new OrderBuilder() .addAsc('name', GroupContentsResourcePrefix.PROJECT) .getOrder(), - excludeHomeProject: true, + limit: 1000 }; - const { items } = await services.groupsService.contents('', params); + const { items } = await services.groupsService.shared(params); dispatch(treePickerActions.LOAD_TREE_PICKER_NODE_SUCCESS({ id: SidePanelTreeCategory.SHARED_WITH_ME, @@ -153,9 +160,11 @@ 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)); }