[ARVADOS-WORKBENCH2] created: 1.2.0-436-g9efef44
Git user
git at public.curoverse.com
Tue Sep 25 05:06:19 EDT 2018
at 9efef4484a8c28b97dae64e785e2dd7c38687cca (commit)
commit 9efef4484a8c28b97dae64e785e2dd7c38687cca
Author: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
Date: Tue Sep 25 11:06:05 2018 +0200
Update loadCollection action to handle trashed and shared collections
Feature #14244
Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
diff --git a/src/store/workbench/workbench-actions.ts b/src/store/workbench/workbench-actions.ts
index d56b6c3..4dd4169 100644
--- a/src/store/workbench/workbench-actions.ts
+++ b/src/store/workbench/workbench-actions.ts
@@ -41,10 +41,10 @@ import { loadSharedWithMePanel } from '../shared-with-me-panel/shared-with-me-pa
import { CopyFormDialogData } from '~/store/copy-dialog/copy-dialog';
import { progressIndicatorActions } from '~/store/progress-indicator/progress-indicator-actions';
import { getProgressIndicator } from '../progress-indicator/progress-indicator-reducer';
-import { ResourceKind } from '~/models/resource';
+import { ResourceKind, extractUuidKind } from '~/models/resource';
import { FilterBuilder } from '~/services/api/filter-builder';
import { ProjectResource } from '~/models/project';
-
+import { CollectionResource } from '~/models/collection';
export const WORKBENCH_LOADING_SCREEN = 'workbenchLoadingScreen';
@@ -189,7 +189,7 @@ export const moveProject = (data: MoveToFormDialogData) =>
};
export const updateProject = (data: projectUpdateActions.ProjectUpdateFormDialogData) =>
- async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+ async (dispatch: Dispatch) => {
const updatedProject = await dispatch<any>(projectUpdateActions.updateProject(data));
if (updatedProject) {
dispatch(snackbarActions.OPEN_SNACKBAR({
@@ -203,11 +203,45 @@ export const updateProject = (data: projectUpdateActions.ProjectUpdateFormDialog
export const loadCollection = (uuid: string) =>
handleFirstTimeLoad(
- async (dispatch: Dispatch) => {
- const collection = await dispatch<any>(loadCollectionPanel(uuid));
- await dispatch<any>(activateSidePanelTreeItem(collection.ownerUuid));
- dispatch<any>(setCollectionBreadcrumbs(collection.uuid));
- dispatch(loadDetailsPanel(uuid));
+ async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
+ const userUuid = services.authService.getUuid();
+ if (userUuid) {
+ let collection: CollectionResource | null = null;
+
+ if (extractUuidKind(uuid) === ResourceKind.COLLECTION) {
+ /**
+ * Use of /group/contents API is the only way to get trashed item
+ * A get method of a service will throw an exception with 404 status for resources that are trashed
+ */
+ const resource = await loadGroupContentsResource(uuid, userUuid, services);
+ if (resource) {
+ if (resource.kind === ResourceKind.COLLECTION) {
+ collection = resource;
+ if (collection.isTrashed) {
+ dispatch(setTrashBreadcrumbs(''));
+ dispatch(activateSidePanelTreeItem(SidePanelTreeCategory.TRASH));
+ } else {
+ await dispatch(activateSidePanelTreeItem(collection.ownerUuid));
+ dispatch(setSidePanelBreadcrumbs(collection.ownerUuid));
+ }
+ }
+ } else {
+ /**
+ * If item is not accesible using loadGroupContentsResource,
+ * but it can be obtained using the get method of the service
+ * then it is shared with the user
+ */
+ collection = await services.collectionService.get(uuid);
+ if (collection) {
+ dispatch<any>(setSharedWithMeBreadcrumbs(collection.ownerUuid));
+ dispatch(activateSidePanelTreeItem(SidePanelTreeCategory.SHARED_WITH_ME));
+ }
+ }
+ if (collection) {
+ dispatch(updateResources([collection]));
+ }
+ }
+ }
});
export const createCollection = (data: collectionCreateActions.CollectionCreateFormDialogData) =>
diff --git a/src/views/collection-panel/collection-panel.tsx b/src/views/collection-panel/collection-panel.tsx
index 0b264b6..6724937 100644
--- a/src/views/collection-panel/collection-panel.tsx
+++ b/src/views/collection-panel/collection-panel.tsx
@@ -70,65 +70,67 @@ export const CollectionPanel = withStyles(styles)(
class extends React.Component<CollectionPanelProps> {
render() {
const { classes, item } = this.props;
- return <div>
- <Card className={classes.card}>
- <CardHeader
- avatar={<CollectionIcon className={classes.iconHeader} />}
- action={
- <Tooltip title="More options">
- <IconButton
- aria-label="More options"
- onClick={this.handleContextMenu}>
- <MoreOptionsIcon />
- </IconButton>
- </Tooltip>
- }
- title={item && item.name}
- subheader={item && item.description} />
- <CardContent>
- <Grid container direction="column">
- <Grid item xs={6}>
- <DetailsAttribute classLabel={classes.label} classValue={classes.value}
- label='Collection UUID'
- value={item && item.uuid}>
- <Tooltip title="Copy uuid">
- <CopyToClipboard text={item && item.uuid} onCopy={() => this.onCopy()}>
- <CopyIcon className={classes.copyIcon} />
- </CopyToClipboard>
- </Tooltip>
- </DetailsAttribute>
- <DetailsAttribute classLabel={classes.label} classValue={classes.value}
- label='Number of files' value='14' />
- <DetailsAttribute classLabel={classes.label} classValue={classes.value}
- label='Content size' value='54 MB' />
- <DetailsAttribute classLabel={classes.label} classValue={classes.value}
- label='Owner' value={item && item.ownerUuid} />
+ return item
+ ? <>
+ <Card className={classes.card}>
+ <CardHeader
+ avatar={<CollectionIcon className={classes.iconHeader} />}
+ action={
+ <Tooltip title="More options">
+ <IconButton
+ aria-label="More options"
+ onClick={this.handleContextMenu}>
+ <MoreOptionsIcon />
+ </IconButton>
+ </Tooltip>
+ }
+ title={item && item.name}
+ subheader={item && item.description} />
+ <CardContent>
+ <Grid container direction="column">
+ <Grid item xs={6}>
+ <DetailsAttribute classLabel={classes.label} classValue={classes.value}
+ label='Collection UUID'
+ value={item && item.uuid}>
+ <Tooltip title="Copy uuid">
+ <CopyToClipboard text={item && item.uuid} onCopy={() => this.onCopy()}>
+ <CopyIcon className={classes.copyIcon} />
+ </CopyToClipboard>
+ </Tooltip>
+ </DetailsAttribute>
+ <DetailsAttribute classLabel={classes.label} classValue={classes.value}
+ label='Number of files' value='14' />
+ <DetailsAttribute classLabel={classes.label} classValue={classes.value}
+ label='Content size' value='54 MB' />
+ <DetailsAttribute classLabel={classes.label} classValue={classes.value}
+ label='Owner' value={item && item.ownerUuid} />
+ </Grid>
</Grid>
- </Grid>
- </CardContent>
- </Card>
+ </CardContent>
+ </Card>
- <Card className={classes.card}>
- <CardHeader title="Properties" />
- <CardContent>
- <Grid container direction="column">
- <Grid item xs={12}><CollectionTagForm /></Grid>
- <Grid item xs={12}>
- {
- Object.keys(item.properties).map( key => {
- return <Chip key={key} className={classes.tag}
- onDelete={this.handleDelete(key)}
- label={`${key}: ${item.properties[key]}`} />;
- })
- }
+ <Card className={classes.card}>
+ <CardHeader title="Properties" />
+ <CardContent>
+ <Grid container direction="column">
+ <Grid item xs={12}><CollectionTagForm /></Grid>
+ <Grid item xs={12}>
+ {
+ Object.keys(item.properties).map(key => {
+ return <Chip key={key} className={classes.tag}
+ onDelete={this.handleDelete(key)}
+ label={`${key}: ${item.properties[key]}`} />;
+ })
+ }
+ </Grid>
</Grid>
- </Grid>
- </CardContent>
- </Card>
- <div className={classes.card}>
- <CollectionPanelFiles />
- </div>
- </div>;
+ </CardContent>
+ </Card>
+ <div className={classes.card}>
+ <CollectionPanelFiles />
+ </div>
+ </>
+ : null;
}
handleContextMenu = (event: React.MouseEvent<any>) => {
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list