[ARVADOS-WORKBENCH2] created: 1.4.1-340-g4bed7c3d
Git user
git at public.arvados.org
Mon May 18 13:46:33 UTC 2020
at 4bed7c3d982b8d9198186a37a1edbdf746b1e0e2 (commit)
commit 4bed7c3d982b8d9198186a37a1edbdf746b1e0e2
Author: Lucas Di Pentima <lucas at di-pentima.com.ar>
Date: Mon May 18 10:45:55 2020 -0300
16118: Fixes webdav tests by handling baseURLs with or without trailing slash.
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas at di-pentima.com.ar>
diff --git a/src/common/webdav.ts b/src/common/webdav.ts
index 3f55a841..b2f43348 100644
--- a/src/common/webdav.ts
+++ b/src/common/webdav.ts
@@ -61,7 +61,11 @@ export class WebDAV {
private request = (config: RequestConfig) => {
return new Promise<XMLHttpRequest>((resolve, reject) => {
const r = this.createRequest();
- r.open(config.method, `${this.defaults.baseURL}/${config.url}`);
+ this.defaults.baseURL = this.defaults.baseURL.replace(/\/+$/, '');
+ r.open(config.method,
+ `${this.defaults.baseURL
+ ? this.defaults.baseURL+'/'
+ : ''}${config.url}`);
const headers = { ...this.defaults.headers, ...config.headers };
Object
.keys(headers)
commit fc898afbfa340c57062887083c96bc197fc283d0
Author: Lucas Di Pentima <lucas at di-pentima.com.ar>
Date: Mon May 18 10:12:23 2020 -0300
16118: Adds test checking writable/readonly collection UI changes.
WIP: There's deactivated code that shows a snackbar whenever a service request
returns an error, no matter if the error is handled somewhere up in the stack.
I think that isn't a good approach, also it prevents the 'readonly' case to
work because the snackbar appears in fron of a menu button and cannot be
clicked.
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas at di-pentima.com.ar>
diff --git a/cypress/integration/collection-panel.spec.js b/cypress/integration/collection-panel.spec.js
index 287bfe10..0ae72809 100644
--- a/cypress/integration/collection-panel.spec.js
+++ b/cypress/integration/collection-panel.spec.js
@@ -28,21 +28,90 @@ describe('Collection panel tests', function() {
cy.clearLocalStorage()
})
- it('shows a collection by URL', function() {
+ it('shows collection by URL', function() {
cy.loginAs(activeUser);
- cy.createCollection(adminUser.token, {
- name: 'Test collection',
- owner_uuid: activeUser.user.uuid,
- manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"})
- .as('testCollection').then(function() {
- cy.visit(`/collections/${this.testCollection.uuid}`);
- cy.get('[data-cy=collection-info-panel]')
- .should('contain', this.testCollection.name)
- .and('contain', this.testCollection.uuid);
- cy.get('[data-cy=collection-files-panel]')
- .should('contain', 'bar');
+ [true, false].map(function(isWritable) {
+ // Creates the collection using the admin token so we can set up
+ // a bogus manifest text without block signatures.
+ cy.createCollection(adminUser.token, {
+ name: 'Test collection',
+ owner_uuid: isWritable
+ ? activeUser.user.uuid
+ : adminUser.user.uuid,
+ properties: {someKey: 'someValue'},
+ manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"})
+ .as('testCollection').then(function() {
+ if (isWritable === false) {
+ // Share collection as read-only
+ cy.do_request('POST', '/arvados/v1/links', {
+ link: JSON.stringify({
+ name: 'can_read',
+ link_class: 'permission',
+ head_uuid: this.testCollection.uuid,
+ tail_uuid: activeUser.user.uuid
+ })
+ }, null, adminUser.token, null);
+ }
+ cy.visit(`/collections/${this.testCollection.uuid}`);
+ // Check that name & uuid are correct.
+ cy.get('[data-cy=collection-info-panel]')
+ .should('contain', this.testCollection.name)
+ .and(`${isWritable ? 'not.': ''}contain`, 'Read-only')
+ .and('contain', this.testCollection.uuid);
+ // Check that both read and write operations are available on
+ // the 'More options' menu.
+ cy.get('[data-cy=collection-panel-options-btn]')
+ .click()
+ cy.get('[data-cy=context-menu]')
+ .should('contain', 'Add to favorites')
+ .and(`${isWritable ? '' : 'not.'}contain`, 'Edit collection')
+ .type('{esc}'); // Collapse the options menu
+ cy.get('[data-cy=collection-properties-panel]')
+ .should('contain', 'someKey')
+ .and('contain', 'someValue')
+ .and('not.contain', 'anotherKey')
+ .and('not.contain', 'anotherValue')
+ // Check that properties can be added.
+ if (isWritable === true) {
+ cy.get('[data-cy=collection-properties-form]').within(() => {
+ cy.get('[data-cy=property-field-key]').within(() => {
+ cy.get('input').type('anotherKey');
+ });
+ cy.get('[data-cy=property-field-value]').within(() => {
+ cy.get('input').type('anotherValue');
+ });
+ cy.root().submit();
+ })
+ cy.get('[data-cy=collection-properties-panel]')
+ .should('contain', 'anotherKey')
+ .and('contain', 'anotherValue')
+ }
+ // Check that the file listing show both read & write operations
+ cy.get('[data-cy=collection-files-panel]').within(() => {
+ cy.root().should('contain', 'bar');
+ cy.get('[data-cy=upload-button]')
+ .should(`${isWritable ? '' : 'not.'}contain`, 'Upload data');
+ });
+ // Hamburger 'more options' menu button
+ cy.get('[data-cy=collection-files-panel-options-btn]')
+ .click()
+ cy.get('[data-cy=context-menu]')
+ .should('contain', 'Select all')
+ .click()
+ cy.get('[data-cy=collection-files-panel-options-btn]')
+ .click()
+ cy.get('[data-cy=context-menu]')
+ .should('contain', 'Download selected')
+ .and(`${isWritable ? '' : 'not.'}contain`, 'Remove selected')
+ .type('{esc}'); // Collapse the options menu
+ // File item 'more options' button
+ cy.get('[data-cy=file-item-options-btn')
+ .click()
+ cy.get('[data-cy=context-menu]')
+ .should('contain', 'Download')
+ .and(`${isWritable ? '' : 'not.'}contain`, 'Remove')
+ .type('{esc}'); // Collapse
+ })
})
})
-
- // it('')
})
\ No newline at end of file
diff --git a/src/components/collection-panel-files/collection-panel-files.tsx b/src/components/collection-panel-files/collection-panel-files.tsx
index 3de4068f..48b36be1 100644
--- a/src/components/collection-panel-files/collection-panel-files.tsx
+++ b/src/components/collection-panel-files/collection-panel-files.tsx
@@ -50,12 +50,15 @@ const styles: StyleRulesCallback<CssRules> = theme => ({
export const CollectionPanelFiles =
withStyles(styles)(
({ onItemMenuOpen, onOptionsMenuOpen, onUploadDataClick, classes, isWritable, ...treeProps }: CollectionPanelFilesProps & WithStyles<CssRules>) =>
- <Card className={classes.root}>
+ <Card data-cy='collection-files-panel' className={classes.root}>
<CardHeader
title="Files"
classes={{ action: classes.button }}
action={
- isWritable && <Button onClick={onUploadDataClick}
+ isWritable &&
+ <Button
+ data-cy='upload-button'
+ onClick={onUploadDataClick}
variant='contained'
color='primary'
size='small'>
@@ -67,7 +70,9 @@ export const CollectionPanelFiles =
className={classes.cardSubheader}
action={
<Tooltip title="More options" disableFocusListener>
- <IconButton onClick={(ev) => onOptionsMenuOpen(ev, isWritable)}>
+ <IconButton
+ data-cy='collection-files-panel-options-btn'
+ onClick={(ev) => onOptionsMenuOpen(ev, isWritable)}>
<CustomizeTableIcon />
</IconButton>
</Tooltip>
diff --git a/src/components/context-menu/context-menu.tsx b/src/components/context-menu/context-menu.tsx
index 98456dad..ecade812 100644
--- a/src/components/context-menu/context-menu.tsx
+++ b/src/components/context-menu/context-menu.tsx
@@ -32,7 +32,7 @@ export class ContextMenu extends React.PureComponent<ContextMenuProps> {
transformOrigin={DefaultTransformOrigin}
anchorOrigin={DefaultTransformOrigin}
onContextMenu={this.handleContextMenu}>
- <List dense>
+ <List data-cy='context-menu' dense>
{items.map((group, groupIndex) =>
<React.Fragment key={groupIndex}>
{group.map((item, actionIndex) =>
diff --git a/src/components/file-tree/file-tree-item.tsx b/src/components/file-tree/file-tree-item.tsx
index dc8f09b9..23273dac 100644
--- a/src/components/file-tree/file-tree-item.tsx
+++ b/src/components/file-tree/file-tree-item.tsx
@@ -53,6 +53,7 @@ export const FileTreeItem = withStyles(fileTreeItemStyle)(
variant="caption">{formatFileSize(item.data.size)}</Typography>
<Tooltip title="More options" disableFocusListener>
<IconButton
+ data-cy='file-item-options-btn'
className={classes.button}
onClick={this.handleClick}>
<MoreOptionsIcon className={classes.moreOptions} />
diff --git a/src/index.tsx b/src/index.tsx
index 16759b7f..eec60dc1 100644
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -104,18 +104,14 @@ fetchConfig()
},
errorFn: (id, error) => {
console.error("Backend error:", error);
- if (error.errors) {
+ if (false) { // WIP: Should we mix backend with UI code?
store.dispatch(snackbarActions.OPEN_SNACKBAR({
- message: `${error.errors[0]}`,
+ message: `${error.errors
+ ? error.errors[0]
+ : error.message}`,
kind: SnackbarKind.ERROR,
- hideDuration: 8000
- }));
- } else {
- store.dispatch(snackbarActions.OPEN_SNACKBAR({
- message: `${error.message}`,
- kind: SnackbarKind.ERROR,
- hideDuration: 8000
- }));
+ hideDuration: 8000})
+ );
}
}
});
diff --git a/src/views-components/resource-properties-form/property-key-field.tsx b/src/views-components/resource-properties-form/property-key-field.tsx
index 1f921188..d17f50d4 100644
--- a/src/views-components/resource-properties-form/property-key-field.tsx
+++ b/src/views-components/resource-properties-form/property-key-field.tsx
@@ -16,11 +16,13 @@ export const PROPERTY_KEY_FIELD_ID = 'keyID';
export const PropertyKeyField = connectVocabulary(
({ vocabulary, skipValidation }: VocabularyProp & ValidationProp) =>
+ <span data-cy='property-field-key'>
<Field
name={PROPERTY_KEY_FIELD_NAME}
component={PropertyKeyInput}
vocabulary={vocabulary}
validate={skipValidation ? undefined : getValidation(vocabulary)} />
+ </span>
);
const PropertyKeyInput = ({ vocabulary, ...props }: WrappedFieldProps & VocabularyProp) =>
diff --git a/src/views-components/resource-properties-form/property-value-field.tsx b/src/views-components/resource-properties-form/property-value-field.tsx
index 99745199..c5a5071f 100644
--- a/src/views-components/resource-properties-form/property-value-field.tsx
+++ b/src/views-components/resource-properties-form/property-value-field.tsx
@@ -28,11 +28,13 @@ const connectVocabularyAndPropertyKey = compose(
export const PropertyValueField = connectVocabularyAndPropertyKey(
({ skipValidation, ...props }: PropertyValueFieldProps) =>
+ <span data-cy='property-field-value'>
<Field
name={PROPERTY_VALUE_FIELD_NAME}
component={PropertyValueInput}
validate={skipValidation ? undefined : getValidation(props)}
{...props} />
+ </span>
);
const PropertyValueInput = ({ vocabulary, propertyKey, ...props }: WrappedFieldProps & PropertyValueFieldProps) =>
diff --git a/src/views-components/resource-properties-form/resource-properties-form.tsx b/src/views-components/resource-properties-form/resource-properties-form.tsx
index db40e4a7..0632b97c 100644
--- a/src/views-components/resource-properties-form/resource-properties-form.tsx
+++ b/src/views-components/resource-properties-form/resource-properties-form.tsx
@@ -20,7 +20,7 @@ export interface ResourcePropertiesFormData {
export type ResourcePropertiesFormProps = InjectedFormProps<ResourcePropertiesFormData> & WithStyles<GridClassKey>;
export const ResourcePropertiesForm = ({ handleSubmit, submitting, invalid, classes }: ResourcePropertiesFormProps ) =>
- <form onSubmit={handleSubmit}>
+ <form data-cy='collection-properties-form' onSubmit={handleSubmit}>
<Grid container spacing={16} classes={classes}>
<Grid item xs>
<PropertyKeyField />
diff --git a/src/views/collection-panel/collection-panel.tsx b/src/views/collection-panel/collection-panel.tsx
index be2afc72..defe73b9 100644
--- a/src/views/collection-panel/collection-panel.tsx
+++ b/src/views/collection-panel/collection-panel.tsx
@@ -29,7 +29,7 @@ import { GroupResource } from '~/models/group';
import { UserResource } from '~/models/user';
import { getUserUuid } from '~/common/getuser';
-type CssRules = 'card' | 'iconHeader' | 'tag' | 'label' | 'value' | 'link' | 'centeredLabel';
+type CssRules = 'card' | 'iconHeader' | 'tag' | 'label' | 'value' | 'link' | 'centeredLabel' | 'readOnlyChip';
const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
card: {
@@ -60,6 +60,9 @@ const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
'&:hover': {
cursor: 'pointer'
}
+ },
+ readOnlyChip: {
+ marginLeft: theme.spacing.unit
}
});
@@ -101,6 +104,7 @@ export const CollectionPanel = withStyles(styles)(
action={
<Tooltip title="More options" disableFocusListener>
<IconButton
+ data-cy='collection-panel-options-btn'
aria-label="More options"
onClick={this.handleContextMenu}>
<MoreOptionsIcon />
@@ -111,7 +115,7 @@ export const CollectionPanel = withStyles(styles)(
<span>
<IllegalNamingWarning name={item.name}/>
{item.name}
- {isWritable || <Chip variant="outlined" icon={<ReadOnlyIcon />} label="Read-only"/>}
+ {isWritable || <Chip variant="outlined" icon={<ReadOnlyIcon />} label="Read-only" className={classes.readOnlyChip} />}
</span>
}
titleTypographyProps={this.titleProps}
@@ -142,7 +146,7 @@ export const CollectionPanel = withStyles(styles)(
</CardContent>
</Card>
- <Card className={classes.card}>
+ <Card data-cy='collection-properties-panel' className={classes.card}>
<CardHeader title="Properties" />
<CardContent>
<Grid container direction="column">
@@ -173,7 +177,7 @@ export const CollectionPanel = withStyles(styles)(
</Grid>
</CardContent>
</Card>
- <div className={classes.card} data-cy="collection-files-panel">
+ <div className={classes.card}>
<CollectionPanelFiles isWritable={isWritable} />
</div>
</>
commit 4c6f753bed0deee685b469be0b399bd61d457de8
Author: Lucas Di Pentima <lucas at di-pentima.com.ar>
Date: Fri May 15 11:21:18 2020 -0300
16118: Fixes WebDAV request URL.
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas at di-pentima.com.ar>
diff --git a/src/common/webdav.ts b/src/common/webdav.ts
index a09e8fdd..3f55a841 100644
--- a/src/common/webdav.ts
+++ b/src/common/webdav.ts
@@ -61,7 +61,7 @@ export class WebDAV {
private request = (config: RequestConfig) => {
return new Promise<XMLHttpRequest>((resolve, reject) => {
const r = this.createRequest();
- r.open(config.method, this.defaults.baseURL + config.url);
+ r.open(config.method, `${this.defaults.baseURL}/${config.url}`);
const headers = { ...this.defaults.headers, ...config.headers };
Object
.keys(headers)
commit ca7a29e2ac03703afeff3248d1b909f42b89ab19
Merge: bc49fa26 366e40d9
Author: Lucas Di Pentima <lucas at di-pentima.com.ar>
Date: Thu May 14 20:46:57 2020 -0300
16118: Merge branch '15881-ldap' into 16118-readonly-collections-lucas
Need this before it gets merged to master to successfully run e2e test.
commit bc49fa261517a5027980570a903b6b6aa5c1f82a
Author: Lucas Di Pentima <lucas at di-pentima.com.ar>
Date: Mon May 11 16:53:27 2020 -0300
16118: Changes read-only padlock icon with an explicit legend.
Also adds cypress-specific attributes to be able to get UI elements in a more
readable way.
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas at di-pentima.com.ar>
diff --git a/src/components/icon/icon.tsx b/src/components/icon/icon.tsx
index 163010e4..a5fa5ddd 100644
--- a/src/components/icon/icon.tsx
+++ b/src/components/icon/icon.tsx
@@ -53,7 +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 ErrorOutline from '@material-ui/icons/ErrorOutline';
import VpnKey from '@material-ui/icons/VpnKey';
export type IconType = React.SFC<{ className?: string, style?: object }>;
@@ -97,7 +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 ReadOnlyIcon: IconType = (props) => <ErrorOutline {...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/views/collection-panel/collection-panel.tsx b/src/views/collection-panel/collection-panel.tsx
index 64de885f..be2afc72 100644
--- a/src/views/collection-panel/collection-panel.tsx
+++ b/src/views/collection-panel/collection-panel.tsx
@@ -5,7 +5,7 @@
import * as React from 'react';
import {
StyleRulesCallback, WithStyles, withStyles, Card,
- CardHeader, IconButton, CardContent, Grid, Tooltip
+ CardHeader, IconButton, CardContent, Grid, Tooltip, Chip
} from '@material-ui/core';
import { connect, DispatchProp } from "react-redux";
import { RouteComponentProps } from 'react-router';
@@ -91,18 +91,14 @@ export const CollectionPanel = withStyles(styles)(
const { classes, item, dispatch, isWritable } = this.props;
return item
? <>
- <Card className={classes.card}>
+ <Card data-cy='collection-info-panel' className={classes.card}>
<CardHeader
avatar={
<IconButton onClick={this.openCollectionDetails}>
<CollectionIcon className={classes.iconHeader} />
</IconButton>
}
- action={<div>
- {isWritable === false &&
- <Tooltip title="This collection is read-only">
- <ReadOnlyIcon />
- </Tooltip>}
+ action={
<Tooltip title="More options" disableFocusListener>
<IconButton
aria-label="More options"
@@ -110,8 +106,14 @@ export const CollectionPanel = withStyles(styles)(
<MoreOptionsIcon />
</IconButton>
</Tooltip>
- </div>}
- title={<span><IllegalNamingWarning name={item.name}/>{item.name}</span>}
+ }
+ title={
+ <span>
+ <IllegalNamingWarning name={item.name}/>
+ {item.name}
+ {isWritable || <Chip variant="outlined" icon={<ReadOnlyIcon />} label="Read-only"/>}
+ </span>
+ }
titleTypographyProps={this.titleProps}
subheader={item.description}
subheaderTypographyProps={this.titleProps} />
@@ -171,7 +173,7 @@ export const CollectionPanel = withStyles(styles)(
</Grid>
</CardContent>
</Card>
- <div className={classes.card}>
+ <div className={classes.card} data-cy="collection-files-panel">
<CollectionPanelFiles isWritable={isWritable} />
</div>
</>
commit ee9dac4509683f2fbe5fda146bd9c18f4b765337
Author: Lucas Di Pentima <lucas at di-pentima.com.ar>
Date: Mon May 11 16:50:21 2020 -0300
16118: Adds collection's integration test suite (WIP)
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas at di-pentima.com.ar>
diff --git a/cypress/integration/collection-panel.spec.js b/cypress/integration/collection-panel.spec.js
new file mode 100644
index 00000000..287bfe10
--- /dev/null
+++ b/cypress/integration/collection-panel.spec.js
@@ -0,0 +1,48 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+describe('Collection panel tests', function() {
+ let activeUser;
+ let adminUser;
+
+ before(function() {
+ // Only set up common users once. These aren't set up as aliases because
+ // aliases are cleaned up after every test. Also it doesn't make sense
+ // to set the same users on beforeEach() over and over again, so we
+ // separate a little from Cypress' 'Best Practices' here.
+ cy.getUser('admin', 'Admin', 'User', true, true)
+ .as('adminUser').then(function() {
+ adminUser = this.adminUser;
+ }
+ );
+ cy.getUser('collectionuser1', 'Collection', 'User', false, true)
+ .as('activeUser').then(function() {
+ activeUser = this.activeUser;
+ }
+ );
+ })
+
+ beforeEach(function() {
+ cy.clearCookies()
+ cy.clearLocalStorage()
+ })
+
+ it('shows a collection by URL', function() {
+ cy.loginAs(activeUser);
+ cy.createCollection(adminUser.token, {
+ name: 'Test collection',
+ owner_uuid: activeUser.user.uuid,
+ manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"})
+ .as('testCollection').then(function() {
+ cy.visit(`/collections/${this.testCollection.uuid}`);
+ cy.get('[data-cy=collection-info-panel]')
+ .should('contain', this.testCollection.name)
+ .and('contain', this.testCollection.uuid);
+ cy.get('[data-cy=collection-files-panel]')
+ .should('contain', 'bar');
+ })
+ })
+
+ // it('')
+})
\ No newline at end of file
diff --git a/cypress/support/commands.js b/cypress/support/commands.js
index 68ce6870..8c6fd462 100644
--- a/cypress/support/commands.js
+++ b/cypress/support/commands.js
@@ -92,3 +92,25 @@ Cypress.Commands.add(
})
}
)
+
+Cypress.Commands.add(
+ "createCollection", (token, collection) => {
+ return cy.do_request('POST', '/arvados/v1/collections', {
+ collection: JSON.stringify(collection),
+ ensure_unique_name: true
+ }, null, token, true)
+ .its('body').as('collection')
+ .then(function() {
+ return this.collection;
+ })
+ }
+)
+
+Cypress.Commands.add(
+ "loginAs", (user) => {
+ cy.visit(`/token/?api_token=${user.token}`);
+ cy.url().should('contain', '/projects/');
+ cy.get('div#root').should('contain', 'Arvados Workbench (zzzzz)');
+ cy.get('div#root').should('not.contain', 'Your account is inactive');
+ }
+)
\ No newline at end of file
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