[ARVADOS-WORKBENCH2] created: 1.4.1-332-gd8a3b5fd
Git user
git at public.arvados.org
Fri May 1 21:01:54 UTC 2020
at d8a3b5fdd6f606800e9b321acb3fca10c5183cb9 (commit)
commit d8a3b5fdd6f606800e9b321acb3fca10c5183cb9
Author: Lucas Di Pentima <lucas at di-pentima.com.ar>
Date: Fri May 1 17:56:22 2020 -0300
16118: Restricts UI elements when a collection is read-only.
* Shows a lock icon indicating the read-only access.
* The three-dotted 'More options' menu only shows appropriate actions.
* The properties panel only shows properties without the 'delete tag' button.
* The files panel general 'More options' menu shows appropriate actions.
* The files panel individual context menu also filters editing action when
read-only.
* The files panel's upload button isn't rendered on read-only collections.
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas at di-pentima.com.ar>
diff --git a/src/components/collection-panel-files/collection-panel-files.tsx b/src/components/collection-panel-files/collection-panel-files.tsx
index 0a443907..3de4068f 100644
--- a/src/components/collection-panel-files/collection-panel-files.tsx
+++ b/src/components/collection-panel-files/collection-panel-files.tsx
@@ -12,9 +12,10 @@ import { DownloadIcon } from '~/components/icon/icon';
export interface CollectionPanelFilesProps {
items: Array<TreeItem<FileTreeData>>;
+ isWritable: boolean;
onUploadDataClick: () => void;
- onItemMenuOpen: (event: React.MouseEvent<HTMLElement>, item: TreeItem<FileTreeData>) => void;
- onOptionsMenuOpen: (event: React.MouseEvent<HTMLElement>) => void;
+ onItemMenuOpen: (event: React.MouseEvent<HTMLElement>, item: TreeItem<FileTreeData>, isWritable: boolean) => void;
+ onOptionsMenuOpen: (event: React.MouseEvent<HTMLElement>, isWritable: boolean) => void;
onSelectionToggle: (event: React.MouseEvent<HTMLElement>, item: TreeItem<FileTreeData>) => void;
onCollapseToggle: (id: string, status: TreeItemStatus) => void;
onFileClick: (id: string) => void;
@@ -48,25 +49,25 @@ const styles: StyleRulesCallback<CssRules> = theme => ({
export const CollectionPanelFiles =
withStyles(styles)(
- ({ onItemMenuOpen, onOptionsMenuOpen, onUploadDataClick, classes, ...treeProps }: CollectionPanelFilesProps & WithStyles<CssRules>) =>
+ ({ onItemMenuOpen, onOptionsMenuOpen, onUploadDataClick, classes, isWritable, ...treeProps }: CollectionPanelFilesProps & WithStyles<CssRules>) =>
<Card className={classes.root}>
<CardHeader
title="Files"
classes={{ action: classes.button }}
action={
- <Button onClick={onUploadDataClick}
+ isWritable && <Button onClick={onUploadDataClick}
variant='contained'
color='primary'
size='small'>
<DownloadIcon className={classes.uploadIcon} />
Upload data
- </Button>
+ </Button>
} />
<CardHeader
className={classes.cardSubheader}
action={
<Tooltip title="More options" disableFocusListener>
- <IconButton onClick={onOptionsMenuOpen}>
+ <IconButton onClick={(ev) => onOptionsMenuOpen(ev, isWritable)}>
<CustomizeTableIcon />
</IconButton>
</Tooltip>
@@ -79,5 +80,5 @@ export const CollectionPanelFiles =
File size
</Typography>
</Grid>
- <FileTree onMenuOpen={onItemMenuOpen} {...treeProps} />
+ <FileTree onMenuOpen={(ev, item) => onItemMenuOpen(ev, item, isWritable)} {...treeProps} />
</Card>);
diff --git a/src/components/file-tree/file-tree.tsx b/src/components/file-tree/file-tree.tsx
index ad7ac73e..34a11cd6 100644
--- a/src/components/file-tree/file-tree.tsx
+++ b/src/components/file-tree/file-tree.tsx
@@ -26,7 +26,7 @@ export class FileTree extends React.Component<FileTreeProps> {
onContextMenu={this.handleContextMenu}
toggleItemActive={this.handleToggleActive}
toggleItemOpen={this.handleToggle}
- toggleItemSelection={this.handleSelectionChange}
+ toggleItemSelection={this.handleSelectionChange}
currentItemUuid={this.props.currentItemUuid} />;
}
diff --git a/src/components/icon/icon.tsx b/src/components/icon/icon.tsx
index a3d01e94..163010e4 100644
--- a/src/components/icon/icon.tsx
+++ b/src/components/icon/icon.tsx
@@ -53,6 +53,7 @@ import SettingsEthernet from '@material-ui/icons/SettingsEthernet';
import Star from '@material-ui/icons/Star';
import StarBorder from '@material-ui/icons/StarBorder';
import Warning from '@material-ui/icons/Warning';
+import Visibility from '@material-ui/icons/Lock';
import VpnKey from '@material-ui/icons/VpnKey';
export type IconType = React.SFC<{ className?: string, style?: object }>;
@@ -96,6 +97,7 @@ export const ProcessIcon: IconType = (props) => <BubbleChart {...props} />;
export const ProjectIcon: IconType = (props) => <Folder {...props} />;
export const ProjectsIcon: IconType = (props) => <Inbox {...props} />;
export const ProvenanceGraphIcon: IconType = (props) => <DeviceHub {...props} />;
+export const ReadOnlyIcon: IconType = (props) => <Visibility {...props} />;
export const RemoveIcon: IconType = (props) => <Delete {...props} />;
export const RemoveFavoriteIcon: IconType = (props) => <Star {...props} />;
export const PublicFavoriteIcon: IconType = (props) => <Public {...props} />;
diff --git a/src/index.tsx b/src/index.tsx
index d428b1c3..16759b7f 100644
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -24,10 +24,10 @@ import { rootProjectActionSet } from "~/views-components/context-menu/action-set
import { projectActionSet } from "~/views-components/context-menu/action-sets/project-action-set";
import { resourceActionSet } from '~/views-components/context-menu/action-sets/resource-action-set';
import { favoriteActionSet } from "~/views-components/context-menu/action-sets/favorite-action-set";
-import { collectionFilesActionSet } from '~/views-components/context-menu/action-sets/collection-files-action-set';
-import { collectionFilesItemActionSet } from '~/views-components/context-menu/action-sets/collection-files-item-action-set';
+import { collectionFilesActionSet, readOnlyCollectionFilesActionSet } from '~/views-components/context-menu/action-sets/collection-files-action-set';
+import { collectionFilesItemActionSet, readOnlyCollectionFilesItemActionSet } from '~/views-components/context-menu/action-sets/collection-files-item-action-set';
import { collectionFilesNotSelectedActionSet } from '~/views-components/context-menu/action-sets/collection-files-not-selected-action-set';
-import { collectionActionSet } from '~/views-components/context-menu/action-sets/collection-action-set';
+import { collectionActionSet, readOnlyCollectionActionSet } from '~/views-components/context-menu/action-sets/collection-action-set';
import { collectionResourceActionSet } from '~/views-components/context-menu/action-sets/collection-resource-action-set';
import { processActionSet } from '~/views-components/context-menu/action-sets/process-action-set';
import { loadWorkbench } from '~/store/workbench/workbench-actions';
@@ -70,10 +70,13 @@ addMenuActionSet(ContextMenuKind.PROJECT, projectActionSet);
addMenuActionSet(ContextMenuKind.RESOURCE, resourceActionSet);
addMenuActionSet(ContextMenuKind.FAVORITE, favoriteActionSet);
addMenuActionSet(ContextMenuKind.COLLECTION_FILES, collectionFilesActionSet);
+addMenuActionSet(ContextMenuKind.READONLY_COLLECTION_FILES, readOnlyCollectionFilesActionSet);
addMenuActionSet(ContextMenuKind.COLLECTION_FILES_NOT_SELECTED, collectionFilesNotSelectedActionSet);
addMenuActionSet(ContextMenuKind.COLLECTION_FILES_ITEM, collectionFilesItemActionSet);
+addMenuActionSet(ContextMenuKind.READONLY_COLLECTION_FILES_ITEM, readOnlyCollectionFilesItemActionSet);
addMenuActionSet(ContextMenuKind.COLLECTION, collectionActionSet);
addMenuActionSet(ContextMenuKind.COLLECTION_RESOURCE, collectionResourceActionSet);
+addMenuActionSet(ContextMenuKind.READONLY_COLLECTION, readOnlyCollectionActionSet);
addMenuActionSet(ContextMenuKind.TRASHED_COLLECTION, trashedCollectionActionSet);
addMenuActionSet(ContextMenuKind.PROCESS, processActionSet);
addMenuActionSet(ContextMenuKind.PROCESS_RESOURCE, processResourceActionSet);
diff --git a/src/store/context-menu/context-menu-actions.ts b/src/store/context-menu/context-menu-actions.ts
index 431d15e8..2ba6bc2c 100644
--- a/src/store/context-menu/context-menu-actions.ts
+++ b/src/store/context-menu/context-menu-actions.ts
@@ -55,7 +55,7 @@ export const openContextMenu = (event: React.MouseEvent<HTMLElement>, resource:
);
};
-export const openCollectionFilesContextMenu = (event: React.MouseEvent<HTMLElement>) =>
+export const openCollectionFilesContextMenu = (event: React.MouseEvent<HTMLElement>, isWritable: boolean) =>
(dispatch: Dispatch, getState: () => RootState) => {
const isCollectionFileSelected = JSON.stringify(getState().collectionPanelFiles).includes('"selected":true');
dispatch<any>(openContextMenu(event, {
@@ -63,7 +63,11 @@ export const openCollectionFilesContextMenu = (event: React.MouseEvent<HTMLEleme
uuid: '',
ownerUuid: '',
kind: ResourceKind.COLLECTION,
- menuKind: isCollectionFileSelected ? ContextMenuKind.COLLECTION_FILES : ContextMenuKind.COLLECTION_FILES_NOT_SELECTED
+ menuKind: isCollectionFileSelected
+ ? isWritable
+ ? ContextMenuKind.COLLECTION_FILES
+ : ContextMenuKind.READONLY_COLLECTION_FILES
+ : ContextMenuKind.COLLECTION_FILES_NOT_SELECTED
}));
};
diff --git a/src/store/resources/resources-reducer.ts b/src/store/resources/resources-reducer.ts
index 22108e04..bb0cd383 100644
--- a/src/store/resources/resources-reducer.ts
+++ b/src/store/resources/resources-reducer.ts
@@ -7,7 +7,11 @@ import { ResourcesAction, resourcesActions } from './resources-actions';
export const resourcesReducer = (state: ResourcesState = {}, action: ResourcesAction) =>
resourcesActions.match(action, {
- SET_RESOURCES: resources => resources.reduce((state, resource) => setResource(resource.uuid, resource)(state), state),
- DELETE_RESOURCES: ids => ids.reduce((state, id) => deleteResource(id)(state), state),
+ SET_RESOURCES: resources => resources.reduce(
+ (state, resource) => setResource(resource.uuid, resource)(state),
+ state),
+ DELETE_RESOURCES: ids => ids.reduce(
+ (state, id) => deleteResource(id)(state),
+ state),
default: () => state,
});
\ No newline at end of file
diff --git a/src/store/workbench/workbench-actions.ts b/src/store/workbench/workbench-actions.ts
index dbf795b6..c6932558 100644
--- a/src/store/workbench/workbench-actions.ts
+++ b/src/store/workbench/workbench-actions.ts
@@ -283,7 +283,7 @@ export const loadCollection = (uuid: string) =>
OWNED: async collection => {
dispatch(collectionPanelActions.SET_COLLECTION(collection as CollectionResource));
dispatch(updateResources([collection]));
- await dispatch(activateSidePanelTreeItem(collection.ownerUuid));
+ dispatch(activateSidePanelTreeItem(collection.ownerUuid));
dispatch(setSidePanelBreadcrumbs(collection.ownerUuid));
dispatch(loadCollectionPanel(collection.uuid));
},
@@ -301,7 +301,6 @@ export const loadCollection = (uuid: string) =>
dispatch(activateSidePanelTreeItem(SidePanelTreeCategory.TRASH));
dispatch(loadCollectionPanel(collection.uuid));
},
-
});
}
});
diff --git a/src/views-components/collection-panel-files/collection-panel-files.ts b/src/views-components/collection-panel-files/collection-panel-files.ts
index e5983b6b..eb16eb6c 100644
--- a/src/views-components/collection-panel-files/collection-panel-files.ts
+++ b/src/views-components/collection-panel-files/collection-panel-files.ts
@@ -52,11 +52,22 @@ const mapDispatchToProps = (dispatch: Dispatch): Pick<CollectionPanelFilesProps,
onSelectionToggle: (event, item) => {
dispatch(collectionPanelFilesAction.TOGGLE_COLLECTION_FILE_SELECTION({ id: item.id }));
},
- onItemMenuOpen: (event, item) => {
- dispatch<any>(openContextMenu(event, { menuKind: ContextMenuKind.COLLECTION_FILES_ITEM, kind: ResourceKind.COLLECTION, name: item.data.name, uuid: item.id, ownerUuid: '' }));
+ onItemMenuOpen: (event, item, isWritable) => {
+ dispatch<any>(openContextMenu(
+ event,
+ {
+ menuKind: isWritable
+ ? ContextMenuKind.COLLECTION_FILES_ITEM
+ : ContextMenuKind.READONLY_COLLECTION_FILES_ITEM,
+ kind: ResourceKind.COLLECTION,
+ name: item.data.name,
+ uuid: item.id,
+ ownerUuid: ''
+ }
+ ));
},
- onOptionsMenuOpen: (event) => {
- dispatch<any>(openCollectionFilesContextMenu(event));
+ onOptionsMenuOpen: (event, isWritable) => {
+ dispatch<any>(openCollectionFilesContextMenu(event, isWritable));
},
onFileClick: (id) => {
dispatch(openDetailsPanel(id));
diff --git a/src/views-components/context-menu/action-sets/collection-action-set.ts b/src/views-components/context-menu/action-sets/collection-action-set.ts
index 9629f028..ea97a9b1 100644
--- a/src/views-components/context-menu/action-sets/collection-action-set.ts
+++ b/src/views-components/context-menu/action-sets/collection-action-set.ts
@@ -16,21 +16,7 @@ import { openSharingDialog } from '~/store/sharing-dialog/sharing-dialog-actions
import { openAdvancedTabDialog } from "~/store/advanced-tab/advanced-tab";
import { toggleDetailsPanel } from '~/store/details-panel/details-panel-action';
-export const collectionActionSet: ContextMenuActionSet = [[
- {
- icon: RenameIcon,
- name: "Edit collection",
- execute: (dispatch, resource) => {
- dispatch<any>(openCollectionUpdateDialog(resource));
- }
- },
- {
- icon: ShareIcon,
- name: "Share",
- execute: (dispatch, { uuid }) => {
- dispatch<any>(openSharingDialog(uuid));
- }
- },
+export const readOnlyCollectionActionSet: ContextMenuActionSet = [[
{
component: ToggleFavoriteAction,
execute: (dispatch, resource) => {
@@ -39,11 +25,6 @@ export const collectionActionSet: ContextMenuActionSet = [[
});
}
},
- {
- icon: MoveToIcon,
- name: "Move to",
- execute: (dispatch, resource) => dispatch<any>(openMoveCollectionDialog(resource))
- },
{
icon: CopyIcon,
name: "Copy to project",
@@ -59,13 +40,6 @@ export const collectionActionSet: ContextMenuActionSet = [[
dispatch<any>(toggleDetailsPanel());
}
},
- // {
- // icon: ProvenanceGraphIcon,
- // name: "Provenance graph",
- // execute: (dispatch, resource) => {
- // // add code
- // }
- // },
{
icon: AdvancedIcon,
name: "Advanced",
@@ -73,17 +47,32 @@ export const collectionActionSet: ContextMenuActionSet = [[
dispatch<any>(openAdvancedTabDialog(resource.uuid));
}
},
+]];
+
+export const collectionActionSet: ContextMenuActionSet = readOnlyCollectionActionSet.concat([[
+ {
+ icon: RenameIcon,
+ name: "Edit collection",
+ execute: (dispatch, resource) => {
+ dispatch<any>(openCollectionUpdateDialog(resource));
+ }
+ },
+ {
+ icon: ShareIcon,
+ name: "Share",
+ execute: (dispatch, { uuid }) => {
+ dispatch<any>(openSharingDialog(uuid));
+ }
+ },
+ {
+ icon: MoveToIcon,
+ name: "Move to",
+ execute: (dispatch, resource) => dispatch<any>(openMoveCollectionDialog(resource))
+ },
{
component: ToggleTrashAction,
execute: (dispatch, resource) => {
dispatch<any>(toggleCollectionTrashed(resource.uuid, resource.isTrashed!!));
}
},
- // {
- // icon: RemoveIcon,
- // name: "Remove",
- // execute: (dispatch, resource) => {
- // // add code
- // }
- // }
-]];
+]]);
diff --git a/src/views-components/context-menu/action-sets/collection-files-action-set.ts b/src/views-components/context-menu/action-sets/collection-files-action-set.ts
index 885f222c..fc0139c8 100644
--- a/src/views-components/context-menu/action-sets/collection-files-action-set.ts
+++ b/src/views-components/context-menu/action-sets/collection-files-action-set.ts
@@ -7,32 +7,42 @@ import { collectionPanelFilesAction, openMultipleFilesRemoveDialog } from "~/sto
import { openCollectionPartialCopyDialog, openCollectionPartialCopyToSelectedCollectionDialog } from '~/store/collections/collection-partial-copy-actions';
import { DownloadCollectionFileAction } from "~/views-components/context-menu/actions/download-collection-file-action";
-export const collectionFilesActionSet: ContextMenuActionSet = [[{
- name: "Select all",
- execute: dispatch => {
- dispatch(collectionPanelFilesAction.SELECT_ALL_COLLECTION_FILES());
+export const readOnlyCollectionFilesActionSet: ContextMenuActionSet = [[
+ {
+ name: "Select all",
+ execute: dispatch => {
+ dispatch(collectionPanelFilesAction.SELECT_ALL_COLLECTION_FILES());
+ }
+ },
+ {
+ name: "Unselect all",
+ execute: dispatch => {
+ dispatch(collectionPanelFilesAction.UNSELECT_ALL_COLLECTION_FILES());
+ }
+ },
+ {
+ component: DownloadCollectionFileAction,
+ execute: () => { return; }
+ },
+ {
+ name: "Create a new collection with selected",
+ execute: dispatch => {
+ dispatch<any>(openCollectionPartialCopyDialog());
+ }
+ },
+ {
+ name: "Copy selected into the collection",
+ execute: dispatch => {
+ dispatch<any>(openCollectionPartialCopyToSelectedCollectionDialog());
+ }
}
-}, {
- name: "Unselect all",
- execute: dispatch => {
- dispatch(collectionPanelFilesAction.UNSELECT_ALL_COLLECTION_FILES());
- }
-}, {
- name: "Remove selected",
- execute: dispatch => {
- dispatch(openMultipleFilesRemoveDialog());
- }
-}, {
- component: DownloadCollectionFileAction,
- execute: () => { return; }
-}, {
- name: "Create a new collection with selected",
- execute: dispatch => {
- dispatch<any>(openCollectionPartialCopyDialog());
- }
-}, {
- name: "Copy selected into the collection",
- execute: dispatch => {
- dispatch<any>(openCollectionPartialCopyToSelectedCollectionDialog());
- }
-}]];
+]];
+
+export const collectionFilesActionSet: ContextMenuActionSet = readOnlyCollectionFilesActionSet.concat([[
+ {
+ name: "Remove selected",
+ execute: dispatch => {
+ dispatch(openMultipleFilesRemoveDialog());
+ }
+ },
+]]);
diff --git a/src/views-components/context-menu/action-sets/collection-files-item-action-set.ts b/src/views-components/context-menu/action-sets/collection-files-item-action-set.ts
index 61603edf..4c6874c6 100644
--- a/src/views-components/context-menu/action-sets/collection-files-item-action-set.ts
+++ b/src/views-components/context-menu/action-sets/collection-files-item-action-set.ts
@@ -9,22 +9,30 @@ import { openFileRemoveDialog, openRenameFileDialog } from '~/store/collection-p
import { CollectionFileViewerAction } from '~/views-components/context-menu/actions/collection-file-viewer-action';
-export const collectionFilesItemActionSet: ContextMenuActionSet = [[{
- name: "Rename",
- icon: RenameIcon,
- execute: (dispatch, resource) => {
- dispatch<any>(openRenameFileDialog({ name: resource.name, id: resource.uuid }));
+export const readOnlyCollectionFilesItemActionSet: ContextMenuActionSet = [[
+ {
+ component: DownloadCollectionFileAction,
+ execute: () => { return; }
+ },
+ {
+ component: CollectionFileViewerAction,
+ execute: () => { return; },
}
-}, {
- component: DownloadCollectionFileAction,
- execute: () => { return; }
-}, {
- name: "Remove",
- icon: RemoveIcon,
- execute: (dispatch, resource) => {
- dispatch<any>(openFileRemoveDialog(resource.uuid));
+]];
+
+export const collectionFilesItemActionSet: ContextMenuActionSet = readOnlyCollectionFilesItemActionSet.concat([[
+ {
+ name: "Rename",
+ icon: RenameIcon,
+ execute: (dispatch, resource) => {
+ dispatch<any>(openRenameFileDialog({ name: resource.name, id: resource.uuid }));
+ }
+ },
+ {
+ name: "Remove",
+ icon: RemoveIcon,
+ execute: (dispatch, resource) => {
+ dispatch<any>(openFileRemoveDialog(resource.uuid));
+ }
}
-}], [{
- component: CollectionFileViewerAction,
- execute: () => { return; },
-}]];
+]]);
\ No newline at end of file
diff --git a/src/views-components/context-menu/context-menu.tsx b/src/views-components/context-menu/context-menu.tsx
index 65e98cc5..55b0abd8 100644
--- a/src/views-components/context-menu/context-menu.tsx
+++ b/src/views-components/context-menu/context-menu.tsx
@@ -70,11 +70,14 @@ export enum ContextMenuKind {
FAVORITE = "Favorite",
TRASH = "Trash",
COLLECTION_FILES = "CollectionFiles",
+ READONLY_COLLECTION_FILES = "ReadOnlyCollectionFiles",
COLLECTION_FILES_ITEM = "CollectionFilesItem",
+ READONLY_COLLECTION_FILES_ITEM = "ReadOnlyCollectionFilesItem",
COLLECTION_FILES_NOT_SELECTED = "CollectionFilesNotSelected",
COLLECTION = 'Collection',
COLLECTION_ADMIN = 'CollectionAdmin',
COLLECTION_RESOURCE = 'CollectionResource',
+ READONLY_COLLECTION = 'ReadOnlyCollection',
TRASHED_COLLECTION = 'TrashedCollection',
PROCESS = "Process",
PROCESS_ADMIN = 'ProcessAdmin',
diff --git a/src/views/collection-panel/collection-panel.tsx b/src/views/collection-panel/collection-panel.tsx
index c4221937..64de885f 100644
--- a/src/views/collection-panel/collection-panel.tsx
+++ b/src/views/collection-panel/collection-panel.tsx
@@ -11,7 +11,7 @@ import { connect, DispatchProp } from "react-redux";
import { RouteComponentProps } from 'react-router';
import { ArvadosTheme } from '~/common/custom-theme';
import { RootState } from '~/store/store';
-import { MoreOptionsIcon, CollectionIcon } from '~/components/icon/icon';
+import { MoreOptionsIcon, CollectionIcon, ReadOnlyIcon } from '~/components/icon/icon';
import { DetailsAttribute } from '~/components/details-attribute/details-attribute';
import { CollectionResource } from '~/models/collection';
import { CollectionPanelFiles } from '~/views-components/collection-panel-files/collection-panel-files';
@@ -25,8 +25,11 @@ import { openDetailsPanel } from '~/store/details-panel/details-panel-action';
import { snackbarActions, SnackbarKind } from '~/store/snackbar/snackbar-actions';
import { getPropertyChip } from '~/views-components/resource-properties-form/property-chip';
import { IllegalNamingWarning } from '~/components/warning/warning';
+import { GroupResource } from '~/models/group';
+import { UserResource } from '~/models/user';
+import { getUserUuid } from '~/common/getuser';
-type CssRules = 'card' | 'iconHeader' | 'tag' | 'label' | 'value' | 'link';
+type CssRules = 'card' | 'iconHeader' | 'tag' | 'label' | 'value' | 'link' | 'centeredLabel';
const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
card: {
@@ -43,6 +46,10 @@ const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
label: {
fontSize: '0.875rem'
},
+ centeredLabel: {
+ fontSize: '0.875rem',
+ textAlign: 'center'
+ },
value: {
textTransform: 'none',
fontSize: '0.875rem'
@@ -58,6 +65,7 @@ const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
interface CollectionPanelDataProps {
item: CollectionResource;
+ isWritable: boolean;
}
type CollectionPanelProps = CollectionPanelDataProps & DispatchProp
@@ -65,13 +73,22 @@ type CollectionPanelProps = CollectionPanelDataProps & DispatchProp
export const CollectionPanel = withStyles(styles)(
connect((state: RootState, props: RouteComponentProps<{ id: string }>) => {
- const item = getResource(props.match.params.id)(state.resources);
- return { item };
+ const currentUserUUID = getUserUuid(state);
+ const item = getResource<CollectionResource>(props.match.params.id)(state.resources);
+ let isWritable = false;
+ if (item && item.ownerUuid === currentUserUUID) {
+ isWritable = true;
+ } else if (item) {
+ const itemOwner = getResource<GroupResource|UserResource>(item.ownerUuid)(state.resources);
+ if (itemOwner) {
+ isWritable = itemOwner.writableBy.indexOf(currentUserUUID || '') >= 0;
+ }
+ }
+ return { item, isWritable };
})(
class extends React.Component<CollectionPanelProps> {
-
render() {
- const { classes, item, dispatch } = this.props;
+ const { classes, item, dispatch, isWritable } = this.props;
return item
? <>
<Card className={classes.card}>
@@ -81,7 +98,11 @@ export const CollectionPanel = withStyles(styles)(
<CollectionIcon className={classes.iconHeader} />
</IconButton>
}
- action={
+ action={<div>
+ {isWritable === false &&
+ <Tooltip title="This collection is read-only">
+ <ReadOnlyIcon />
+ </Tooltip>}
<Tooltip title="More options" disableFocusListener>
<IconButton
aria-label="More options"
@@ -89,26 +110,26 @@ export const CollectionPanel = withStyles(styles)(
<MoreOptionsIcon />
</IconButton>
</Tooltip>
- }
- title={item && <span><IllegalNamingWarning name={item.name}/>{item.name}</span>}
+ </div>}
+ title={<span><IllegalNamingWarning name={item.name}/>{item.name}</span>}
titleTypographyProps={this.titleProps}
- subheader={item && item.description}
+ subheader={item.description}
subheaderTypographyProps={this.titleProps} />
<CardContent>
<Grid container direction="column">
<Grid item xs={10}>
<DetailsAttribute classLabel={classes.label} classValue={classes.value}
label='Collection UUID'
- linkToUuid={item && item.uuid} />
+ linkToUuid={item.uuid} />
<DetailsAttribute classLabel={classes.label} classValue={classes.value}
label='Portable data hash'
- linkToUuid={item && item.portableDataHash} />
+ linkToUuid={item.portableDataHash} />
<DetailsAttribute classLabel={classes.label} classValue={classes.value}
- label='Number of files' value={item && item.fileCount} />
+ label='Number of files' value={item.fileCount} />
<DetailsAttribute classLabel={classes.label} classValue={classes.value}
- label='Content size' value={item && formatFileSize(item.fileSizeTotal)} />
+ label='Content size' value={formatFileSize(item.fileSizeTotal)} />
<DetailsAttribute classLabel={classes.label} classValue={classes.value}
- label='Owner' linkToUuid={item && item.ownerUuid} />
+ label='Owner' linkToUuid={item.ownerUuid} />
{(item.properties.container_request || item.properties.containerRequest) &&
<span onClick={() => dispatch<any>(navigateToProcess(item.properties.container_request || item.properties.containerRequest))}>
<DetailsAttribute classLabel={classes.link} label='Link to process' />
@@ -123,28 +144,35 @@ export const CollectionPanel = withStyles(styles)(
<CardHeader title="Properties" />
<CardContent>
<Grid container direction="column">
- <Grid item xs={12}>
+ {isWritable && <Grid item xs={12}>
<CollectionTagForm />
- </Grid>
+ </Grid>}
<Grid item xs={12}>
- {Object.keys(item.properties).map(k =>
+ { Object.keys(item.properties).length > 0
+ ? Object.keys(item.properties).map(k =>
Array.isArray(item.properties[k])
? item.properties[k].map((v: string) =>
getPropertyChip(
k, v,
- this.handleDelete(k, v),
+ isWritable
+ ? this.handleDelete(k, item.properties[k])
+ : undefined,
classes.tag))
: getPropertyChip(
k, item.properties[k],
- this.handleDelete(k, item.properties[k]),
+ isWritable
+ ? this.handleDelete(k, item.properties[k])
+ : undefined,
classes.tag)
- )}
+ )
+ : <div className={classes.centeredLabel}>No properties set on this collection.</div>
+ }
</Grid>
</Grid>
</CardContent>
</Card>
<div className={classes.card}>
- <CollectionPanelFiles />
+ <CollectionPanelFiles isWritable={isWritable} />
</div>
</>
: null;
@@ -152,15 +180,18 @@ export const CollectionPanel = withStyles(styles)(
handleContextMenu = (event: React.MouseEvent<any>) => {
const { uuid, ownerUuid, name, description, kind, isTrashed } = this.props.item;
+ const { isWritable } = this.props;
const resource = {
uuid,
ownerUuid,
name,
description,
kind,
- menuKind: isTrashed
- ? ContextMenuKind.TRASHED_COLLECTION
- : ContextMenuKind.COLLECTION
+ menuKind: isWritable
+ ? isTrashed
+ ? ContextMenuKind.TRASHED_COLLECTION
+ : ContextMenuKind.COLLECTION
+ : ContextMenuKind.READONLY_COLLECTION
};
this.props.dispatch<any>(openContextMenu(event, resource));
}
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list