1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { MultiSelectMenuAction, MultiSelectMenuActionSet, msCommonActionSet } from 'views-components/multiselect-toolbar/ms-menu-actions';
6 import { ContextMenuActionNames } from "views-components/context-menu/context-menu-action-set";
7 import { openMoveProjectDialog } from 'store/projects/project-move-actions';
8 import { toggleProjectTrashed } from 'store/trash/trash-actions';
16 } from 'components/icon/icon';
17 import { RestoreFromTrashIcon, TrashIcon, FolderSharedIcon, Link } from 'components/icon/icon';
18 import { getResource } from 'store/resources/resources';
19 import { openProjectCreateDialog } from 'store/projects/project-create-actions';
20 import { openProjectUpdateDialog } from 'store/projects/project-update-actions';
21 import { freezeProject, unfreezeProject } from 'store/projects/project-lock-actions';
22 import { openWebDavS3InfoDialog } from 'store/collections/collection-info-actions';
23 import { copyToClipboardAction } from 'store/open-in-new-tab/open-in-new-tab.actions';
24 import { openSharingDialog } from 'store/sharing-dialog/sharing-dialog-actions';
28 ADD_TO_PUBLIC_FAVORITES,
30 COPY_LINK_TO_CLIPBOARD,
33 OPEN_WITH_3RD_PARTY_CLIENT,
40 } = ContextMenuActionNames;
42 const msCopyToClipboardMenuAction: MultiSelectMenuAction = {
43 name: COPY_LINK_TO_CLIPBOARD,
47 execute: (dispatch, resources) => {
48 dispatch<any>(copyToClipboardAction(resources));
52 const msEditProjectAction: MultiSelectMenuAction = {
57 execute: (dispatch, resources) => {
58 dispatch<any>(openProjectUpdateDialog(resources[0]));
62 const msMoveToAction: MultiSelectMenuAction = {
67 execute: (dispatch, resource) => {
68 dispatch<any>(openMoveProjectDialog(resource[0]));
72 const msOpenWith3rdPartyClientAction: MultiSelectMenuAction = {
73 name: OPEN_WITH_3RD_PARTY_CLIENT,
74 icon: FolderSharedIcon,
77 execute: (dispatch, resources) => {
78 dispatch<any>(openWebDavS3InfoDialog(resources[0].uuid));
82 export const msToggleTrashAction: MultiSelectMenuAction = {
86 altName: 'Restore from Trash',
87 altIcon: RestoreFromTrashIcon,
89 useAlts: (uuid, iconProps) => {
90 return uuid ? (getResource(uuid)(iconProps.resources) as any)?.isTrashed : false;
92 execute: (dispatch, resources) => {
93 for (const resource of [...resources]) {
94 dispatch<any>(toggleProjectTrashed(resource.uuid, resource.ownerUuid, resource.isTrashed!!, resources.length > 1));
99 const msFreezeProjectAction: MultiSelectMenuAction = {
100 name: FREEZE_PROJECT,
103 altName: 'Unfreeze Project',
104 altIcon: UnfreezeIcon,
106 useAlts: (uuid, iconProps) => {
107 return uuid ? !!(getResource(uuid)(iconProps.resources) as any).frozenByUuid : false;
109 execute: (dispatch, resources) => {
110 if ((resources[0] as any).frozenByUuid) {
111 dispatch<any>(unfreezeProject(resources[0].uuid));
113 dispatch<any>(freezeProject(resources[0].uuid));
118 const msNewProjectAction: MultiSelectMenuAction = {
120 icon: NewProjectIcon,
123 execute: (dispatch, resources): void => {
124 dispatch<any>(openProjectCreateDialog(resources[0].uuid));
128 const msShareAction: MultiSelectMenuAction = {
133 execute: (dispatch, resources) => {
134 dispatch<any>(openSharingDialog(resources[0].uuid));
138 export const msProjectActionSet: MultiSelectMenuActionSet = [
140 ...msCommonActionSet,
145 msFreezeProjectAction,
146 msOpenWith3rdPartyClientAction,
147 msCopyToClipboardMenuAction,
152 export const msCommonProjectActionFilter = new Set<string>([
156 COPY_LINK_TO_CLIPBOARD,
162 OPEN_WITH_3RD_PARTY_CLIENT,
166 export const msReadOnlyProjectActionFilter = new Set<string>([ADD_TO_FAVORITES, API_DETAILS, COPY_LINK_TO_CLIPBOARD, OPEN_IN_NEW_TAB, OPEN_WITH_3RD_PARTY_CLIENT, VIEW_DETAILS,]);
167 export const msFrozenProjectActionFilter = new Set<string>([ADD_TO_FAVORITES, API_DETAILS, COPY_LINK_TO_CLIPBOARD, OPEN_IN_NEW_TAB, OPEN_WITH_3RD_PARTY_CLIENT, VIEW_DETAILS, SHARE, FREEZE_PROJECT])
168 export const msAdminFrozenProjectActionFilter = new Set<string>([ADD_TO_FAVORITES, API_DETAILS, COPY_LINK_TO_CLIPBOARD, OPEN_IN_NEW_TAB, OPEN_WITH_3RD_PARTY_CLIENT, VIEW_DETAILS, SHARE, FREEZE_PROJECT, ADD_TO_PUBLIC_FAVORITES])
170 export const msFilterGroupActionFilter = new Set<string>([ADD_TO_FAVORITES, API_DETAILS, COPY_LINK_TO_CLIPBOARD, OPEN_IN_NEW_TAB, OPEN_WITH_3RD_PARTY_CLIENT, VIEW_DETAILS, SHARE, MOVE_TO_TRASH, EDIT_PROJECT, MOVE_TO])
171 export const msAdminFilterGroupActionFilter = new Set<string>([ADD_TO_FAVORITES, API_DETAILS, COPY_LINK_TO_CLIPBOARD, OPEN_IN_NEW_TAB, OPEN_WITH_3RD_PARTY_CLIENT, VIEW_DETAILS, SHARE, MOVE_TO_TRASH, EDIT_PROJECT, MOVE_TO, ADD_TO_PUBLIC_FAVORITES])