[arvados] updated: 2.7.0-6264-gb41a884bde

git repository hosting git at public.arvados.org
Thu Mar 28 17:38:00 UTC 2024


Summary of changes:
 services/workbench2/src/common/menu-item-sort.ts   | 74 ++++++++++++++++++++++
 .../multiselect-toolbar/MultiselectToolbar.tsx     | 43 +++++++------
 .../ms-toolbar-action-filters.ts                   | 51 +--------------
 .../views-components/context-menu/context-menu.tsx |  1 +
 4 files changed, 99 insertions(+), 70 deletions(-)
 create mode 100644 services/workbench2/src/common/menu-item-sort.ts

       via  b41a884bdeb7f18ad923d23ffed8be0f0a85e452 (commit)
      from  3a4994a4a3f1f9a52e38f70335e8845e09849846 (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 b41a884bdeb7f18ad923d23ffed8be0f0a85e452
Author: Lisa Knox <lisaknox83 at gmail.com>
Date:   Thu Mar 28 13:37:54 2024 -0400

    21448: initial sorting algo in place Arvados-DCO-1.1-Signed-off-by: Lisa Knox <lisa.knox at curii.com>

diff --git a/services/workbench2/src/common/menu-item-sort.ts b/services/workbench2/src/common/menu-item-sort.ts
new file mode 100644
index 0000000000..6cf8c9f677
--- /dev/null
+++ b/services/workbench2/src/common/menu-item-sort.ts
@@ -0,0 +1,74 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { ContextMenuAction } from '../views-components/context-menu/context-menu-action-set';
+import { ContextMenuActionNames } from 'views-components/context-menu/context-menu-action-set';
+
+const {
+    ACCOUNT_SETTINGS,
+    ACTIVATE_USER,
+    ADD_TO_FAVORITES,
+    ADD_TO_PUBLIC_FAVORITES,
+    ATTRIBUTES,
+    API_DETAILS,
+    CANCEL,
+    COPY_AND_RERUN_PROCESS,
+    COPY_ITEM_INTO_EXISTING_COLLECTION,
+    COPY_ITEM_INTO_NEW_COLLECTION,
+    COPY_SELECTED_INTO_EXISTING_COLLECTION,
+    COPY_SELECTED_INTO_SEPARATE_COLLECTIONS,
+    COPY_SELECTED_INTO_NEW_COLLECTION,
+    COPY_TO_CLIPBOARD,
+    DEACTIVATE_USER,
+    DELETE_WORKFLOW,
+    DOWNLOAD,
+    EDIT_COLLECTION,
+    EDIT_PROCESS,
+    EDIT_PROJECT,
+    FREEZE_PROJECT,
+    HOME_PROJECT,
+    LOGIN_AS_USER,
+    MAKE_A_COPY,
+    MANAGE,
+    MOVE_ITEM_INTO_EXISTING_COLLECTION,
+    MOVE_ITEM_INTO_NEW_COLLECTION,
+    MOVE_SELECTED_INTO_EXISTING_COLLECTION,
+    MOVE_SELECTED_INTO_NEW_COLLECTION,
+    MOVE_SELECTED_INTO_SEPARATE_COLLECTIONS,
+    MOVE_TO,
+    MOVE_TO_TRASH,
+    NEW_COLLECTION,
+    NEW_PROJECT,
+    OPEN_IN_NEW_TAB,
+    OPEN_WITH_3RD_PARTY_CLIENT,
+    OUTPUTS,
+    PROVENANCE_GRAPH,
+    READ,
+    REMOVE,
+    REMOVE_SELECTED,
+    RENAME,
+    RESTORE,
+    RESTORE_VERSION,
+    RUN_WORKFLOW,
+    SELECT_ALL,
+    SETUP_USER,
+    SHARE,
+    UNSELECT_ALL,
+    VIEW_DETAILS,
+    WRITE,
+} = ContextMenuActionNames;
+
+const processOrder = [VIEW_DETAILS, OPEN_IN_NEW_TAB, OUTPUTS, API_DETAILS, EDIT_PROCESS, COPY_AND_RERUN_PROCESS, MOVE_TO, REMOVE, ADD_TO_FAVORITES, ADD_TO_PUBLIC_FAVORITES];
+
+const kindToOrder: Record<string, ContextMenuActionNames[]> = {
+    "ProcessResource": processOrder,
+};
+
+export const sortMenuItems = (menuKind:string, menuItems: ContextMenuAction[]) => {
+    const order = kindToOrder[menuKind] || [];
+    const bucketMap = new Map();
+    order.forEach((name) => bucketMap.set(name, null));
+    menuItems.forEach((item) => {if (bucketMap.has(item.name)) bucketMap.set(item.name, item)});
+    console.log(Array.from(bucketMap.values()));
+};
\ No newline at end of file
diff --git a/services/workbench2/src/components/multiselect-toolbar/MultiselectToolbar.tsx b/services/workbench2/src/components/multiselect-toolbar/MultiselectToolbar.tsx
index 7b44d675a2..ae22050f33 100644
--- a/services/workbench2/src/components/multiselect-toolbar/MultiselectToolbar.tsx
+++ b/services/workbench2/src/components/multiselect-toolbar/MultiselectToolbar.tsx
@@ -15,7 +15,7 @@ import { getResource } from "store/resources/resources";
 import { ResourcesState } from "store/resources/resources";
 import { MultiSelectMenuAction, MultiSelectMenuActionSet } from "views-components/multiselect-toolbar/ms-menu-actions";
 import { ContextMenuAction, ContextMenuActionNames } from "views-components/context-menu/context-menu-action-set";
-import { multiselectActionsFilters, TMultiselectActionsFilters, msMenuResourceKind } from "./ms-toolbar-action-filters";
+import { multiselectActionsFilters, TMultiselectActionsFilters } from "./ms-toolbar-action-filters";
 import { kindToActionSet, findActionByName } from "./ms-kind-action-differentiator";
 import { msToggleTrashAction } from "views-components/multiselect-toolbar/ms-project-action-set";
 import { copyToClipboardAction } from "store/open-in-new-tab/open-in-new-tab.actions";
@@ -34,6 +34,7 @@ import { Process } from "store/processes/process";
 import { PublicFavoritesState } from "store/public-favorites/public-favorites-reducer";
 import { isExactlyOneSelected } from "store/multiselect/multiselect-actions";
 import { IntersectionObserverWrapper } from "./ms-toolbar-overflow-wrapper";
+import { ContextMenuKind } from "views-components/context-menu/context-menu";
 
 const WIDTH_TRANSITION = 150
 
@@ -211,7 +212,7 @@ function filterActions(actionArray: MultiSelectMenuActionSet, filters: Set<strin
     return actionArray[0].filter(action => filters.has(action.name as string));
 }
 
-const resourceToMsResourceKind = (uuid: string, resources: ResourcesState, user: User | null, readonly = false): (msMenuResourceKind | ResourceKind) | undefined => {
+const resourceToMsResourceKind = (uuid: string, resources: ResourcesState, user: User | null, readonly = false): (ContextMenuKind | ResourceKind) | undefined => {
     if (!user) return;
     const resource = getResourceWithEditableStatus<GroupResource & EditableResource>(uuid, user.uuid)(resources);
     const { isAdmin } = user;
@@ -223,18 +224,18 @@ const resourceToMsResourceKind = (uuid: string, resources: ResourcesState, user:
     switch (kind) {
         case ResourceKind.PROJECT:
             if (isFrozen) {
-                return isAdmin ? msMenuResourceKind.FROZEN_PROJECT_ADMIN : msMenuResourceKind.FROZEN_PROJECT;
+                return isAdmin ? ContextMenuKind.FROZEN_PROJECT_ADMIN : ContextMenuKind.FROZEN_PROJECT;
             }
 
             return isAdmin && !readonly
                 ? resource && resource.groupClass !== GroupClass.FILTER
-                    ? msMenuResourceKind.PROJECT_ADMIN
-                    : msMenuResourceKind.FILTER_GROUP_ADMIN
+                    ? ContextMenuKind.PROJECT_ADMIN
+                    : ContextMenuKind.FILTER_GROUP_ADMIN
                 : isEditable
                 ? resource && resource.groupClass !== GroupClass.FILTER
-                    ? msMenuResourceKind.PROJECT
-                    : msMenuResourceKind.FILTER_GROUP
-                : msMenuResourceKind.READONLY_PROJECT;
+                    ? ContextMenuKind.PROJECT
+                    : ContextMenuKind.FILTER_GROUP
+                : ContextMenuKind.READONLY_PROJECT;
         case ResourceKind.COLLECTION:
             const c = getResource<CollectionResource>(uuid)(resources);
             if (c === undefined) {
@@ -243,30 +244,30 @@ const resourceToMsResourceKind = (uuid: string, resources: ResourcesState, user:
             const isOldVersion = c.uuid !== c.currentVersionUuid;
             const isTrashed = c.isTrashed;
             return isOldVersion
-                ? msMenuResourceKind.OLD_VERSION_COLLECTION
+                ? ContextMenuKind.OLD_VERSION_COLLECTION
                 : isTrashed && isEditable
-                ? msMenuResourceKind.TRASHED_COLLECTION
+                ? ContextMenuKind.TRASHED_COLLECTION
                 : isAdmin && isEditable
-                ? msMenuResourceKind.COLLECTION_ADMIN
+                ? ContextMenuKind.COLLECTION_ADMIN
                 : isEditable
-                ? msMenuResourceKind.COLLECTION
-                : msMenuResourceKind.READONLY_COLLECTION;
+                ? ContextMenuKind.COLLECTION
+                : ContextMenuKind.READONLY_COLLECTION;
         case ResourceKind.PROCESS:
             return isAdmin && isEditable
                 ? resource && isProcessCancelable(getProcess(resource.uuid)(resources) as Process)
-                    ? msMenuResourceKind.RUNNING_PROCESS_ADMIN
-                    : msMenuResourceKind.PROCESS_ADMIN
+                    ? ContextMenuKind.RUNNING_PROCESS_ADMIN
+                    : ContextMenuKind.PROCESS_ADMIN
                 : readonly
-                ? msMenuResourceKind.READONLY_PROCESS_RESOURCE
+                ? ContextMenuKind.READONLY_PROCESS_RESOURCE
                 : resource && isProcessCancelable(getProcess(resource.uuid)(resources) as Process)
-                ? msMenuResourceKind.RUNNING_PROCESS_RESOURCE
-                : msMenuResourceKind.PROCESS_RESOURCE;
+                ? ContextMenuKind.RUNNING_PROCESS_RESOURCE
+                : ContextMenuKind.PROCESS_RESOURCE;
         case ResourceKind.USER:
-            return msMenuResourceKind.ROOT_PROJECT;
+            return ContextMenuKind.ROOT_PROJECT;
         case ResourceKind.LINK:
-            return msMenuResourceKind.LINK;
+            return ContextMenuKind.LINK;
         case ResourceKind.WORKFLOW:
-            return isEditable ? msMenuResourceKind.WORKFLOW : msMenuResourceKind.READONLY_WORKFLOW;
+            return isEditable ? ContextMenuKind.WORKFLOW : ContextMenuKind.READONLY_WORKFLOW;
         default:
             return;
     }
diff --git a/services/workbench2/src/components/multiselect-toolbar/ms-toolbar-action-filters.ts b/services/workbench2/src/components/multiselect-toolbar/ms-toolbar-action-filters.ts
index b34cc22cb9..a5498e7a53 100644
--- a/services/workbench2/src/components/multiselect-toolbar/ms-toolbar-action-filters.ts
+++ b/services/workbench2/src/components/multiselect-toolbar/ms-toolbar-action-filters.ts
@@ -16,54 +16,7 @@ import {
 import { msProcessActionSet, msCommonProcessActionFilter, msAdminProcessActionFilter, msRunningProcessActionFilter } from 'views-components/multiselect-toolbar/ms-process-action-set';
 import { msWorkflowActionSet, msWorkflowActionFilter, msReadOnlyWorkflowActionFilter } from 'views-components/multiselect-toolbar/ms-workflow-action-set';
 import { ResourceKind } from 'models/resource';
-
-export enum msMenuResourceKind {
-    API_CLIENT_AUTHORIZATION = 'ApiClientAuthorization',
-    ROOT_PROJECT = 'RootProject',
-    PROJECT = 'Project',
-    FILTER_GROUP = 'FilterGroup',
-    READONLY_PROJECT = 'ReadOnlyProject',
-    FROZEN_PROJECT = 'FrozenProject',
-    FROZEN_PROJECT_ADMIN = 'FrozenProjectAdmin',
-    PROJECT_ADMIN = 'ProjectAdmin',
-    FILTER_GROUP_ADMIN = 'FilterGroupAdmin',
-    RESOURCE = 'Resource',
-    FAVORITE = 'Favorite',
-    TRASH = 'Trash',
-    COLLECTION_FILES = 'CollectionFiles',
-    COLLECTION_FILES_MULTIPLE = 'CollectionFilesMultiple',
-    READONLY_COLLECTION_FILES = 'ReadOnlyCollectionFiles',
-    READONLY_COLLECTION_FILES_MULTIPLE = 'ReadOnlyCollectionFilesMultiple',
-    COLLECTION_FILES_NOT_SELECTED = 'CollectionFilesNotSelected',
-    COLLECTION_FILE_ITEM = 'CollectionFileItem',
-    COLLECTION_DIRECTORY_ITEM = 'CollectionDirectoryItem',
-    READONLY_COLLECTION_FILE_ITEM = 'ReadOnlyCollectionFileItem',
-    READONLY_COLLECTION_DIRECTORY_ITEM = 'ReadOnlyCollectionDirectoryItem',
-    COLLECTION = 'Collection',
-    COLLECTION_ADMIN = 'CollectionAdmin',
-    READONLY_COLLECTION = 'ReadOnlyCollection',
-    OLD_VERSION_COLLECTION = 'OldVersionCollection',
-    TRASHED_COLLECTION = 'TrashedCollection',
-    PROCESS = 'Process',
-    RUNNING_PROCESS_ADMIN = 'RunningProcessAdmin',
-    PROCESS_ADMIN = 'ProcessAdmin',
-    RUNNING_PROCESS_RESOURCE = 'RunningProcessResource',
-    PROCESS_RESOURCE = 'ProcessResource',
-    READONLY_PROCESS_RESOURCE = 'ReadOnlyProcessResource',
-    PROCESS_LOGS = 'ProcessLogs',
-    REPOSITORY = 'Repository',
-    SSH_KEY = 'SshKey',
-    VIRTUAL_MACHINE = 'VirtualMachine',
-    KEEP_SERVICE = 'KeepService',
-    USER = 'User',
-    GROUPS = 'Group',
-    GROUP_MEMBER = 'GroupMember',
-    PERMISSION_EDIT = 'PermissionEdit',
-    LINK = 'Link',
-    WORKFLOW = 'Workflow',
-    READONLY_WORKFLOW = 'ReadOnlyWorkflow',
-    SEARCH_RESULTS = 'SearchResults',
-}
+import { ContextMenuKind } from 'views-components/context-menu/context-menu';
 
 const {
     COLLECTION,
@@ -82,7 +35,7 @@ const {
     FILTER_GROUP_ADMIN,
     WORKFLOW,
     READONLY_WORKFLOW,
-} = msMenuResourceKind;
+} = ContextMenuKind;
 
 export type TMultiselectActionsFilters = Record<string, [MultiSelectMenuActionSet, Set<string>]>;
 
diff --git a/services/workbench2/src/views-components/context-menu/context-menu.tsx b/services/workbench2/src/views-components/context-menu/context-menu.tsx
index aeb69de762..565785c11e 100644
--- a/services/workbench2/src/views-components/context-menu/context-menu.tsx
+++ b/services/workbench2/src/views-components/context-menu/context-menu.tsx
@@ -11,6 +11,7 @@ import { ContextMenuActionSet, ContextMenuAction } from "./context-menu-action-s
 import { Dispatch } from "redux";
 import { memoize } from "lodash";
 import { sortByProperty } from "common/array-utils";
+import { sortMenuItems } from "common/menu-item-sort";
 
 type DataProps = Pick<ContextMenuProps, "anchorEl" | "items" | "open"> & { resource?: ContextMenuResource };
 

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list