[ARVADOS-WORKBENCH2] created: 1.4.1-358-g259a52af

Git user git at public.arvados.org
Tue Jun 9 17:44:52 UTC 2020


        at  259a52af355150ad091383b2773bc171146f0499 (commit)


commit 259a52af355150ad091383b2773bc171146f0499
Author: Lucas Di Pentima <lucas at di-pentima.com.ar>
Date:   Tue Jun 9 14:42:45 2020 -0300

    16118: Handles trashed collection view (WIP)
    
    Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas at di-pentima.com.ar>

diff --git a/src/lib/trashable-resource.ts b/src/lib/trashable-resource.ts
new file mode 100644
index 00000000..a5bccb93
--- /dev/null
+++ b/src/lib/trashable-resource.ts
@@ -0,0 +1,22 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { ProjectResource } from "~/models/project";
+import { ResourcesState, getResource } from "~/store/resources/resources";
+import { extractUuidKind, ResourceKind } from "~/models/resource";
+import { CollectionResource } from "~/models/collection";
+
+export const isProjectTrashed = (proj: ProjectResource, resources: ResourcesState): boolean => {
+    if (proj.isTrashed) { return true; }
+    if (extractUuidKind(proj.ownerUuid) === ResourceKind.USER) { return false; }
+    const parentProj = getResource<ProjectResource>(proj.ownerUuid)(resources);
+    return isProjectTrashed(parentProj!, resources);
+};
+
+export const isCollectionTrashed = (coll: CollectionResource, resources: ResourcesState): boolean => {
+    if (coll.isTrashed) { return true; }
+    if (extractUuidKind(coll.ownerUuid) === ResourceKind.USER) { return false; }
+    const parentProj = getResource<ProjectResource>(coll.ownerUuid)(resources);
+    return isProjectTrashed(parentProj!, resources);
+};
\ No newline at end of file
diff --git a/src/views-components/side-panel-button/side-panel-button.tsx b/src/views-components/side-panel-button/side-panel-button.tsx
index 5e547740..d2e22881 100644
--- a/src/views-components/side-panel-button/side-panel-button.tsx
+++ b/src/views-components/side-panel-button/side-panel-button.tsx
@@ -15,9 +15,9 @@ import { navigateToRunProcess } from '~/store/navigation/navigation-action';
 import { runProcessPanelActions } from '~/store/run-process-panel/run-process-panel-actions';
 import { getUserUuid } from '~/common/getuser';
 import { matchProjectRoute } from '~/routes/routes';
-import { GroupResource } from '~/models/group';
 import { ResourcesState, getResource } from '~/store/resources/resources';
-import { extractUuidKind, ResourceKind } from '~/models/resource';
+import { ProjectResource } from '~/models/project';
+import { isProjectTrashed } from '~/lib/trashable-resource';
 
 type CssRules = 'button' | 'menuItem' | 'icon';
 
@@ -54,13 +54,6 @@ const transformOrigin: PopoverOrigin = {
     horizontal: 0
 };
 
-const isProjectTrashed = (proj: GroupResource, resources: ResourcesState): boolean => {
-    if (proj.isTrashed) { return true; }
-    if (extractUuidKind(proj.ownerUuid) === ResourceKind.USER) { return false; }
-    const parentProj = getResource<GroupResource>(proj.ownerUuid)(resources);
-    return isProjectTrashed(parentProj!, resources);
-};
-
 export const SidePanelButton = withStyles(styles)(
     connect((state: RootState) => ({
         currentItemId: state.router.location
@@ -83,7 +76,7 @@ export const SidePanelButton = withStyles(styles)(
                 if (currentItemId === currentUserUUID) {
                     enabled = true;
                 } else if (matchProjectRoute(location ? location.pathname : '')) {
-                    const currentProject = getResource<GroupResource>(currentItemId)(resources);
+                    const currentProject = getResource<ProjectResource>(currentItemId)(resources);
                     if (currentProject &&
                         currentProject.writableBy.indexOf(currentUserUUID || '') >= 0 &&
                         !isProjectTrashed(currentProject, resources)) {
diff --git a/src/views/collection-panel/collection-panel.tsx b/src/views/collection-panel/collection-panel.tsx
index 36625387..6c66e667 100644
--- a/src/views/collection-panel/collection-panel.tsx
+++ b/src/views/collection-panel/collection-panel.tsx
@@ -25,9 +25,10 @@ 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 { ProjectResource } from '~/models/project';
 import { UserResource } from '~/models/user';
 import { getUserUuid } from '~/common/getuser';
+import { isCollectionTrashed } from '~/lib/trashable-resource';
 
 type CssRules = 'card' | 'iconHeader' | 'tag' | 'label' | 'value' | 'link' | 'centeredLabel' | 'readOnlyIcon';
 
@@ -70,6 +71,7 @@ const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
 interface CollectionPanelDataProps {
     item: CollectionResource;
     isWritable: boolean;
+    isTrashed: boolean;
 }
 
 type CollectionPanelProps = CollectionPanelDataProps & DispatchProp
@@ -79,20 +81,28 @@ export const CollectionPanel = withStyles(styles)(
     connect((state: RootState, props: RouteComponentProps<{ id: string }>) => {
         const currentUserUUID = getUserUuid(state);
         const item = getResource<CollectionResource>(props.match.params.id)(state.resources);
-        let isWritable = false;
-        if (item && item.ownerUuid === currentUserUUID) {
+        let isWritable: boolean;
+        let isTrashed = false;
+        if (item === undefined) {
+            isWritable = false;
+        } else if (isCollectionTrashed(item, state.resources)) {
+            isWritable = false;
+            isTrashed = true;
+        } else if (item.ownerUuid === currentUserUUID) {
             isWritable = true;
-        } else if (item) {
-            const itemOwner = getResource<GroupResource|UserResource>(item.ownerUuid)(state.resources);
+        } else {
+            const itemOwner = getResource<ProjectResource|UserResource>(item.ownerUuid)(state.resources);
             if (itemOwner) {
                 isWritable = itemOwner.writableBy.indexOf(currentUserUUID || '') >= 0;
+            } else {
+                isWritable = false;
             }
         }
-        return { item, isWritable };
+        return { item, isWritable, isTrashed };
     })(
         class extends React.Component<CollectionPanelProps> {
             render() {
-                const { classes, item, dispatch, isWritable } = this.props;
+                const { classes, item, dispatch, isWritable, isTrashed } = this.props;
                 return item
                     ? <>
                         <Card data-cy='collection-info-panel' className={classes.card}>

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list