import { pluginConfig } from 'plugins';
import { LinkClass } from 'models/link';
+
+
export enum SidePanelTreeCategory {
PROJECTS = 'Home Projects',
SHARED_WITH_ME = 'Shared with me',
};
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) =>