19302: publicfavorites works Arvados-DCO-1.1-Signed-off-by: Lisa Knox <lisa.knox...
authorLisa Knox <lisaknox83@gmail.com>
Tue, 24 Oct 2023 15:08:25 +0000 (11:08 -0400)
committerLisa Knox <lisaknox83@gmail.com>
Tue, 24 Oct 2023 15:08:25 +0000 (11:08 -0400)
src/store/side-panel-tree/side-panel-tree-actions.ts

index 05fe84f24084028f3724a71bdc76db95efefb326..5ed7eee1ea50f589e2000c60f16f5dd99772ec6b 100644 (file)
@@ -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<ProjectResource>()
-    //         .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<ProjectResource>()
+        //     .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) =>