X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/6d1da474f9ae85108bbde00fe341cca65fd0ca06..66fbf108bc45021a3187bb63f4c0672e4e6ad3c9:/src/views-components/projects-tree-picker/generic-projects-tree-picker.tsx

diff --git a/src/views-components/projects-tree-picker/generic-projects-tree-picker.tsx b/src/views-components/projects-tree-picker/generic-projects-tree-picker.tsx
index d8a5d49f..07b1ad81 100644
--- a/src/views-components/projects-tree-picker/generic-projects-tree-picker.tsx
+++ b/src/views-components/projects-tree-picker/generic-projects-tree-picker.tsx
@@ -5,6 +5,7 @@
 import * as React from "react";
 import { Dispatch } from "redux";
 import { connect } from "react-redux";
+import { isEqual } from 'lodash/fp';
 import { TreeItem, TreeItemStatus } from '~/components/tree/tree';
 import { ProjectResource } from "~/models/project";
 import { treePickerActions } from "~/store/tree-picker/tree-picker-actions";
@@ -15,13 +16,14 @@ import { GroupContentsResource } from '~/services/groups-service/groups-service'
 import { CollectionDirectory, CollectionFile, CollectionFileType } from '~/models/collection-file';
 import { ResourceKind } from '~/models/resource';
 import { TreePickerProps, TreePicker } from "~/views-components/tree-picker/tree-picker";
+import { LinkResource } from "~/models/link";
 
 export interface ProjectsTreePickerRootItem {
     id: string;
     name: string;
 }
 
-export type ProjectsTreePickerItem = ProjectsTreePickerRootItem | GroupContentsResource | CollectionDirectory | CollectionFile;
+export type ProjectsTreePickerItem = ProjectsTreePickerRootItem | GroupContentsResource | CollectionDirectory | CollectionFile | LinkResource;
 type PickedTreePickerProps = Pick<TreePickerProps<ProjectsTreePickerItem>, 'onContextMenu' | 'toggleItemActive' | 'toggleItemOpen' | 'toggleItemSelection'>;
 
 export interface ProjectsTreePickerDataProps {
@@ -30,7 +32,8 @@ export interface ProjectsTreePickerDataProps {
     rootItemIcon: IconType;
     showSelection?: boolean;
     relatedTreePickers?: string[];
-    loadRootItem: (item: TreeItem<ProjectsTreePickerRootItem>, pickerId: string, includeCollections?: boolean, inlcudeFiles?: boolean) => void;
+    disableActivation?: string[];
+    loadRootItem: (item: TreeItem<ProjectsTreePickerRootItem>, pickerId: string, includeCollections?: boolean, includeFiles?: boolean) => void;
 }
 
 export type ProjectsTreePickerProps = ProjectsTreePickerDataProps & Partial<PickedTreePickerProps>;
@@ -43,6 +46,12 @@ const mapStateToProps = (_: any, { rootItemIcon, showSelection }: ProjectsTreePi
 const mapDispatchToProps = (dispatch: Dispatch, { loadRootItem, includeCollections, includeFiles, relatedTreePickers, ...props }: ProjectsTreePickerProps): PickedTreePickerProps => ({
     onContextMenu: () => { return; },
     toggleItemActive: (event, item, pickerId) => {
+
+        const { disableActivation = [] } = props;
+        if (disableActivation.some(isEqual(item.id))) {
+            return;
+        }
+
         dispatch(treePickerActions.ACTIVATE_TREE_PICKER_NODE({ id: item.id, pickerId, relatedTreePickers }));
         if (props.toggleItemActive) {
             props.toggleItemActive(event, item, pickerId);
@@ -75,6 +84,14 @@ const mapDispatchToProps = (dispatch: Dispatch, { loadRootItem, includeCollectio
 export const ProjectsTreePicker = connect(mapStateToProps, mapDispatchToProps)(TreePicker);
 
 const getProjectPickerIcon = ({ data }: TreeItem<ProjectsTreePickerItem>, rootIcon: IconType): IconType => {
+    if ('headKind' in data) {
+        switch (data.headKind) {
+            case ResourceKind.COLLECTION:
+                return CollectionIcon;
+            default:
+                return ProjectIcon;
+        }
+    }
     if ('kind' in data) {
         switch (data.kind) {
             case ResourceKind.COLLECTION:
