1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { MultiSelectMenuActionSet, MultiSelectMenuActionNames } from 'views-components/multiselect-toolbar/ms-menu-actions';
6 import { msCollectionActionSet, msCommonCollectionActionFilter, msReadOnlyCollectionActionFilter } from 'views-components/multiselect-toolbar/ms-collection-action-set';
9 msCommonProjectActionFilter,
10 msReadOnlyProjectActionFilter,
11 msFilterGroupActionFilter,
12 msFrozenProjectActionFilter,
13 } from 'views-components/multiselect-toolbar/ms-project-action-set';
14 import { msProcessActionSet } from 'views-components/multiselect-toolbar/ms-process-action-set';
15 import { msWorkflowActionSet, msWorkflowActionFilter, msReadOnlyWorkflowActionFilter } from 'views-components/multiselect-toolbar/ms-workflow-action-set';
16 import { ResourceKind } from 'models/resource';
19 const { MOVE_TO, REMOVE } = MultiSelectMenuActionNames;
21 const allActionNames = (actionSet: MultiSelectMenuActionSet): Set<string> => new Set(actionSet[0].map((action) => action.name));
23 const processResourceMSActionsFilter = new Set([MOVE_TO, REMOVE]);
25 export enum msMenuResourceKind {
26 API_CLIENT_AUTHORIZATION = 'ApiClientAuthorization',
27 ROOT_PROJECT = 'RootProject',
29 FILTER_GROUP = 'FilterGroup',
30 READONLY_PROJECT = 'ReadOnlyProject',
31 FROZEN_PROJECT = 'FrozenProject',
32 FROZEN_PROJECT_ADMIN = 'FrozenProjectAdmin',
33 PROJECT_ADMIN = 'ProjectAdmin',
34 FILTER_GROUP_ADMIN = 'FilterGroupAdmin',
35 RESOURCE = 'Resource',
36 FAVORITE = 'Favorite',
38 COLLECTION_FILES = 'CollectionFiles',
39 COLLECTION_FILES_MULTIPLE = 'CollectionFilesMultiple',
40 READONLY_COLLECTION_FILES = 'ReadOnlyCollectionFiles',
41 READONLY_COLLECTION_FILES_MULTIPLE = 'ReadOnlyCollectionFilesMultiple',
42 COLLECTION_FILES_NOT_SELECTED = 'CollectionFilesNotSelected',
43 COLLECTION_FILE_ITEM = 'CollectionFileItem',
44 COLLECTION_DIRECTORY_ITEM = 'CollectionDirectoryItem',
45 READONLY_COLLECTION_FILE_ITEM = 'ReadOnlyCollectionFileItem',
46 READONLY_COLLECTION_DIRECTORY_ITEM = 'ReadOnlyCollectionDirectoryItem',
47 COLLECTION = 'Collection',
48 COLLECTION_ADMIN = 'CollectionAdmin',
49 READONLY_COLLECTION = 'ReadOnlyCollection',
50 OLD_VERSION_COLLECTION = 'OldVersionCollection',
51 TRASHED_COLLECTION = 'TrashedCollection',
53 RUNNING_PROCESS_ADMIN = 'RunningProcessAdmin',
54 PROCESS_ADMIN = 'ProcessAdmin',
55 RUNNING_PROCESS_RESOURCE = 'RunningProcessResource',
56 PROCESS_RESOURCE = 'ProcessResource',
57 READONLY_PROCESS_RESOURCE = 'ReadOnlyProcessResource',
58 PROCESS_LOGS = 'ProcessLogs',
59 REPOSITORY = 'Repository',
61 VIRTUAL_MACHINE = 'VirtualMachine',
62 KEEP_SERVICE = 'KeepService',
65 GROUP_MEMBER = 'GroupMember',
66 PERMISSION_EDIT = 'PermissionEdit',
68 WORKFLOW = 'Workflow',
69 READONLY_WORKFLOW = 'ReadOnlyWorkflow',
70 SEARCH_RESULTS = 'SearchResults',
73 const { COLLECTION, COLLECTION_ADMIN, READONLY_COLLECTION, PROCESS, PROCESS_ADMIN, PROJECT, PROJECT_ADMIN, FROZEN_PROJECT, FROZEN_PROJECT_ADMIN, READONLY_PROJECT, FILTER_GROUP, WORKFLOW, READONLY_WORKFLOW } = msMenuResourceKind;
75 export type TMultiselectActionsFilters = Record<string, [MultiSelectMenuActionSet, Set<string>]>;
77 export const multiselectActionsFilters: TMultiselectActionsFilters = {
78 [COLLECTION]: [msCollectionActionSet, msCommonCollectionActionFilter],
79 [READONLY_COLLECTION]: [msCollectionActionSet, msReadOnlyCollectionActionFilter],
80 [ResourceKind.COLLECTION]: [msCollectionActionSet, msCommonCollectionActionFilter],
81 [COLLECTION_ADMIN]: [msCollectionActionSet, allActionNames(msCollectionActionSet)],
82 [PROCESS]: [msProcessActionSet, processResourceMSActionsFilter],
83 [ResourceKind.PROCESS]: [msProcessActionSet, processResourceMSActionsFilter],
84 [PROCESS_ADMIN]: [msProcessActionSet, processResourceMSActionsFilter],
85 [PROJECT]: [msProjectActionSet, msCommonProjectActionFilter],
86 [ResourceKind.PROJECT]: [msProjectActionSet, msCommonProjectActionFilter],
87 [PROJECT_ADMIN]: [msProjectActionSet, allActionNames(msProjectActionSet)],
88 [FROZEN_PROJECT]: [msProjectActionSet, msFrozenProjectActionFilter],
89 [FROZEN_PROJECT_ADMIN]: [msProjectActionSet, msFrozenProjectActionFilter],
90 [READONLY_PROJECT]: [msProjectActionSet, msReadOnlyProjectActionFilter],
91 [FILTER_GROUP]: [msProjectActionSet, msFilterGroupActionFilter],
92 [WORKFLOW]: [msWorkflowActionSet, msWorkflowActionFilter],
93 [READONLY_WORKFLOW]: [msWorkflowActionSet, msReadOnlyWorkflowActionFilter],