[ARVADOS-WORKBENCH2] updated: 2.1.0-257-g377e37a3

Git user git at public.arvados.org
Thu Mar 18 21:40:38 UTC 2021


Summary of changes:
 src/store/context-menu/context-menu-actions.ts | 35 ++++++++++++++++++--------
 1 file changed, 25 insertions(+), 10 deletions(-)

       via  377e37a3c0c4f376cffb44709640a112df180323 (commit)
      from  a5f102e85afefd36d70f3460fdab5b6b95305e33 (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 377e37a3c0c4f376cffb44709640a112df180323
Author: Ward Vandewege <ward at curii.com>
Date:   Thu Mar 18 17:38:55 2021 -0400

    17119: fix unit tests (process resources do not have a writable_by field
           so isEditable is always false), and fix a bug where the type of
    the last project visited would affect editable state of objects at other
    routes (e.g. "Shared with me").
    
    Arvados-DCO-1.1-Signed-off-by: Ward Vandewege <ward at curii.com>

diff --git a/src/store/context-menu/context-menu-actions.ts b/src/store/context-menu/context-menu-actions.ts
index 876cb951..9a5b3099 100644
--- a/src/store/context-menu/context-menu-actions.ts
+++ b/src/store/context-menu/context-menu-actions.ts
@@ -21,6 +21,8 @@ import { CollectionResource } from '~/models/collection';
 import { GroupClass, GroupResource } from '~/models/group';
 import { GroupContentsResource } from '~/services/groups-service/groups-service';
 import { getProjectPanelCurrentUuid } from '~/store/project-panel/project-panel-action';
+import { matchProjectRoute } from '~/routes/routes';
+import { RouterState } from "react-router-redux";
 
 export const contextMenuActions = unionize({
     OPEN_CONTEXT_MENU: ofType<{ position: ContextMenuPosition, resource: ContextMenuResource }>(),
@@ -202,24 +204,37 @@ export const openProcessContextMenu = (event: React.MouseEvent<HTMLElement>, pro
         }
     };
 
+export const isProjectRoute = (router: RouterState) => {
+    if (router === undefined) {
+      return false;
+    }
+    const pathname = router.location ? router.location.pathname : '';
+    const matchProject = matchProjectRoute(pathname);
+    return Boolean(matchProject);
+};
+
 export const resourceUuidToContextMenuKind = (uuid: string) =>
     (dispatch: Dispatch, getState: () => RootState) => {
         const { isAdmin: isAdminUser, uuid: userUuid } = getState().auth.user!;
         const kind = extractUuidKind(uuid);
         const resource = getResourceWithEditableStatus<GroupResource & EditableResource>(uuid, userUuid)(getState().resources);
+
         // When viewing the contents of a filter group, all contents should be treated as read only.
         let inFilterGroup = false;
-        const projectUuid = getProjectPanelCurrentUuid(getState());
-        if (projectUuid !== undefined) {
-          const project = getResource<GroupResource>(projectUuid)(getState().resources);
-          if (project) {
-            if (project.groupClass === GroupClass.FILTER) {
-              inFilterGroup = true;
+        const { router } = getState();
+        if (isProjectRoute(router)) {
+          const projectUuid = getProjectPanelCurrentUuid(getState());
+          if (projectUuid !== undefined) {
+            const project = getResource<GroupResource>(projectUuid)(getState().resources);
+            if (project) {
+              if (project.groupClass === GroupClass.FILTER) {
+                inFilterGroup = true;
+              }
             }
           }
         }
-        const isEditable = (isAdminUser || (resource || {} as EditableResource).isEditable) && !inFilterGroup;
 
+        const isEditable = (isAdminUser || (resource || {} as EditableResource).isEditable) && !inFilterGroup;
         switch (kind) {
             case ResourceKind.PROJECT:
                 return (isAdminUser && !inFilterGroup)
@@ -246,9 +261,9 @@ export const resourceUuidToContextMenuKind = (uuid: string) =>
             case ResourceKind.PROCESS:
                 return (isAdminUser && !inFilterGroup)
                     ? ContextMenuKind.PROCESS_ADMIN
-                    : isEditable
-                        ? ContextMenuKind.PROCESS_RESOURCE
-                        : ContextMenuKind.READONLY_PROCESS_RESOURCE;
+                    : inFilterGroup
+                        ? ContextMenuKind.READONLY_PROCESS_RESOURCE
+                        : ContextMenuKind.PROCESS_RESOURCE;
             case ResourceKind.USER:
                 return ContextMenuKind.ROOT_PROJECT;
             case ResourceKind.LINK:

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list