From 70cc7de1fd7fb72c757a8466dee7ca6bf8e55c84 Mon Sep 17 00:00:00 2001 From: Lisa Knox Date: Tue, 24 Oct 2023 11:08:25 -0400 Subject: [PATCH] 19302: publicfavorites works Arvados-DCO-1.1-Signed-off-by: Lisa Knox --- .../side-panel-tree-actions.ts | 53 +++++++++++-------- 1 file changed, 30 insertions(+), 23 deletions(-) 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 05fe84f2..5ed7eee1 100644 --- a/src/store/side-panel-tree/side-panel-tree-actions.ts +++ b/src/store/side-panel-tree/side-panel-tree-actions.ts @@ -20,6 +20,8 @@ import { CategoriesListReducer } from 'common/plugintypes'; import { pluginConfig } from 'plugins'; import { LinkClass } from 'models/link'; + + export enum SidePanelTreeCategory { PROJECTS = 'Home Projects', SHARED_WITH_ME = 'Shared with me', @@ -152,29 +154,34 @@ const loadFavorites = async (dispatch: Dispatch, getState: () => RootState, serv }; const loadPublicFavorites = async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { - // dispatch(treePickerActions.LOAD_TREE_PICKER_NODE({ id: SidePanelTreeCategory.PUBLIC_FAVORITES, pickerId: SIDE_PANEL_TREE })); - - // const params = { - // filters: `[${new FilterBuilder() - // .addIsA('uuid', ResourceKind.PROJECT) - // .addIn('group_class', [GroupClass.PROJECT, GroupClass.FILTER]) - // .addDistinct('uuid', getState().auth.config.uuidPrefix + '-j7d0g-publicfavorites') - // .getFilters()}]`, - // order: new OrderBuilder() - // .addAsc('name', GroupContentsResourcePrefix.PROJECT) - // .getOrder(), - // limit: 1000 - // }; - - // const { items } = await services.groupsService.shared(params); - - // dispatch(treePickerActions.LOAD_TREE_PICKER_NODE_SUCCESS({ - // id: SidePanelTreeCategory.PUBLIC_FAVORITES, - // pickerId: SIDE_PANEL_TREE, - // nodes: items.map(item => initTreeNode({ id: item.uuid, value: item })), - // })); - - // dispatch(resourcesActions.SET_RESOURCES(items)); + dispatch(treePickerActions.LOAD_TREE_PICKER_NODE({ id: SidePanelTreeCategory.PUBLIC_FAVORITES, pickerId: SIDE_PANEL_TREE })); + + const uuidPrefix = getState().auth.config.uuidPrefix; + const publicProjectUuid = `${uuidPrefix}-j7d0g-publicfavorites`; + const typeFilters = [ResourceKind.COLLECTION, ResourceKind.CONTAINER_REQUEST, ResourceKind.GROUP, ResourceKind.WORKFLOW]; + + const params = { + filters: new FilterBuilder() + .addEqual('link_class', LinkClass.STAR) + .addEqual('owner_uuid', publicProjectUuid) + .addIsA('head_uuid', typeFilters) + .getFilters(), + // order: new OrderBuilder() + // .addAsc('name', GroupContentsResourcePrefix.PROJECT) + // .getOrder(), + // limit: 1000 + }; + + const { items } = await services.linkService.list(params); + console.log(items) + + dispatch(treePickerActions.LOAD_TREE_PICKER_NODE_SUCCESS({ + id: SidePanelTreeCategory.PUBLIC_FAVORITES, + pickerId: SIDE_PANEL_TREE, + nodes: items.map(item => initTreeNode({ id: item.headUuid, value: item })), + })); + + dispatch(resourcesActions.SET_RESOURCES(items)); }; export const activateSidePanelTreeItem = (id: string) => -- 2.30.2