[ARVADOS-WORKBENCH2] updated: 1.2.0-592-g725ea8d
Git user
git at public.curoverse.com
Wed Oct 10 17:23:20 EDT 2018
Summary of changes:
src/components/tree/tree.tsx | 8 ++++--
.../generic-projects-tree-picker.tsx | 30 +++++++++++++++++++---
.../projects-tree-picker/projects-tree-picker.tsx | 8 ++++--
src/views/workbench/workbench.tsx | 15 ++++++++---
4 files changed, 51 insertions(+), 10 deletions(-)
via 725ea8d5e40c33ccba89ba2936b135ea0ddddd5a (commit)
from a0e9ecd6a913a6465b500f642412daf1e1a6420b (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit 725ea8d5e40c33ccba89ba2936b135ea0ddddd5a
Author: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
Date: Wed Oct 10 23:23:03 2018 +0200
Add props for controlling which checkboxes should be visible
Feature #13862
Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
diff --git a/src/components/tree/tree.tsx b/src/components/tree/tree.tsx
index df3fc7f..b6d7719 100644
--- a/src/components/tree/tree.tsx
+++ b/src/components/tree/tree.tsx
@@ -87,7 +87,7 @@ export interface TreeProps<T> {
level?: number;
onContextMenu: (event: React.MouseEvent<HTMLElement>, item: TreeItem<T>) => void;
render: (item: TreeItem<T>, level?: number) => ReactElement<{}>;
- showSelection?: boolean;
+ showSelection?: boolean | ((item: TreeItem<T>) => boolean);
toggleItemActive: (event: React.MouseEvent<HTMLElement>, item: TreeItem<T>) => void;
toggleItemOpen: (event: React.MouseEvent<HTMLElement>, item: TreeItem<T>) => void;
toggleItemSelection?: (event: React.MouseEvent<HTMLElement>, item: TreeItem<T>) => void;
@@ -99,6 +99,10 @@ export const Tree = withStyles(styles)(
const level = this.props.level ? this.props.level : 0;
const { classes, render, toggleItemOpen, items, toggleItemActive, onContextMenu, disableRipple } = this.props;
const { list, listItem, loader, toggableIconContainer, renderContainer } = classes;
+ const isCheckboxVisible = typeof this.props.showSelection === 'function'
+ ? this.props.showSelection
+ : () => this.props.showSelection ? true : false;
+
return <List component="div" className={list}>
{items && items.map((it: TreeItem<T>, idx: number) =>
<div key={`item/${level}/${idx}`}>
@@ -114,7 +118,7 @@ export const Tree = withStyles(styles)(
{this.getProperArrowAnimation(it.status, it.items!)}
</ListItemIcon>
</i>
- {this.props.showSelection &&
+ { isCheckboxVisible(it) &&
<Checkbox
checked={it.selected}
className={classes.checkbox}
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 1ddbe3a..c877a15 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
@@ -25,18 +25,21 @@ export type ProjectsTreePickerItem = ProjectsTreePickerRootItem | GroupContentsR
type PickedTreePickerProps = Pick<TreePickerProps<ProjectsTreePickerItem>, 'onContextMenu' | 'toggleItemActive' | 'toggleItemOpen' | 'toggleItemSelection'>;
export interface ProjectsTreePickerDataProps {
- pickerId: string;
includeCollections?: boolean;
includeFiles?: boolean;
rootItemIcon: IconType;
+ rootItemSelection?: boolean;
+ projectsSelection?: boolean;
+ collectionsSelection?: boolean;
+ filesSelection?: boolean;
loadRootItem: (item: TreeItem<ProjectsTreePickerRootItem>, pickerId: string, includeCollections?: boolean, inlcudeFiles?: boolean) => void;
}
export type ProjectsTreePickerProps = ProjectsTreePickerDataProps & Partial<PickedTreePickerProps>;
-const mapStateToProps = (_: any, { pickerId, rootItemIcon }: ProjectsTreePickerProps) => ({
+const mapStateToProps = (_: any, { rootItemIcon, ...props }: ProjectsTreePickerProps) => ({
render: renderTreeItem(rootItemIcon),
- pickerId,
+ showSelection: isSelectionVisible(props),
});
const mapDispatchToProps = (dispatch: Dispatch, { loadRootItem, includeCollections, includeFiles, ...props }: ProjectsTreePickerProps): PickedTreePickerProps => ({
@@ -89,6 +92,27 @@ const getProjectPickerIcon = ({ data }: TreeItem<ProjectsTreePickerItem>, rootIc
return rootIcon;
}
};
+interface IsSelectionVisibleParams {
+ rootItemSelection?: boolean;
+ projectsSelection?: boolean;
+ collectionsSelection?: boolean;
+ filesSelection?: boolean;
+}
+const isSelectionVisible = (params: IsSelectionVisibleParams) =>
+ ({ data, status }: TreeItem<ProjectsTreePickerItem>) => {
+ if ('kind' in data) {
+ switch (data.kind) {
+ case ResourceKind.COLLECTION:
+ return !!params.collectionsSelection;
+ default:
+ return !!params.projectsSelection;
+ }
+ } else if ('type' in data) {
+ return !!params.filesSelection;
+ } else {
+ return !!params.rootItemSelection;
+ }
+ };
const renderTreeItem = (rootItemIcon: IconType) => (item: TreeItem<ProjectResource>) =>
<ListItemTextIcon
diff --git a/src/views-components/projects-tree-picker/projects-tree-picker.tsx b/src/views-components/projects-tree-picker/projects-tree-picker.tsx
index 7982813..550f085 100644
--- a/src/views-components/projects-tree-picker/projects-tree-picker.tsx
+++ b/src/views-components/projects-tree-picker/projects-tree-picker.tsx
@@ -16,14 +16,18 @@ export interface ProjectsTreePickerProps {
pickerId: string;
includeCollections?: boolean;
includeFiles?: boolean;
+ rootItemSelection?: boolean;
+ projectsSelection?: boolean;
+ collectionsSelection?: boolean;
+ filesSelection?: boolean;
toggleItemActive?: (event: React.MouseEvent<HTMLElement>, item: TreeItem<ProjectsTreePickerItem>, pickerId: string) => void;
}
-export const ProjectsTreePicker = ({ pickerId, ...props }: ProjectsTreePickerProps) => {
+export const ProjectsTreePicker = ({ pickerId, ...props }: ProjectsTreePickerProps) => {
const { home, shared, favorites } = getProjectsTreePickerIds(pickerId);
return <div>
<HomeTreePicker pickerId={home} {...props} />
<SharedTreePicker pickerId={shared} {...props} />
<FavoritesTreePicker pickerId={favorites} {...props} />
</div>;
- };
+};
diff --git a/src/views/workbench/workbench.tsx b/src/views/workbench/workbench.tsx
index dd68cb8..3a23f21 100644
--- a/src/views/workbench/workbench.tsx
+++ b/src/views/workbench/workbench.tsx
@@ -93,11 +93,20 @@ export const WorkbenchPanel =
</Grid>
<Grid item xs className={classes.content}>
<p>Projects only</p>
- <ProjectsTreePicker pickerId="testPicker1"/>
+ <ProjectsTreePicker pickerId="testPicker1" />
<p>Collections included</p>
- <ProjectsTreePicker pickerId="testPicker2" includeCollections/>
+ <ProjectsTreePicker
+ pickerId="testPicker2"
+ includeCollections
+ collectionsSelection
+ />
<p>Files included</p>
- <ProjectsTreePicker pickerId="testPicker3" includeCollections includeFiles toggleItemActive={(...args: any[]) => console.log(args)}/>
+ <ProjectsTreePicker
+ pickerId="testPicker3"
+ includeCollections
+ includeFiles
+ filesSelection
+ toggleItemActive={(...args: any[]) => console.log(args)} />
<Switch>
<Route path={Routes.PROJECTS} component={ProjectPanel} />
<Route path={Routes.COLLECTIONS} component={CollectionPanel} />
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list