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';
17 } from 'components/icon/icon';
18 import { RestoreFromTrashIcon, TrashIcon, FolderSharedIcon, Link } from 'components/icon/icon';
19 import { getResource } from 'store/resources/resources';
20 import { openProjectCreateDialog } from 'store/projects/project-create-actions';
21 import { openProjectUpdateDialog } from 'store/projects/project-update-actions';
22 import { freezeProject, unfreezeProject } from 'store/projects/project-lock-actions';
23 import { openWebDavS3InfoDialog } from 'store/collections/collection-info-actions';
24 import { copyToClipboardAction, copyStringToClipboardAction } from 'store/open-in-new-tab/open-in-new-tab.actions';
25 import { openSharingDialog } from 'store/sharing-dialog/sharing-dialog-actions';
29 ADD_TO_PUBLIC_FAVORITES,
31 COPY_LINK_TO_CLIPBOARD,
35 OPEN_WITH_3RD_PARTY_CLIENT,
42 } = ContextMenuActionNames;
44 const msCopyToClipboardMenuAction: MultiSelectMenuAction = {
45 name: COPY_LINK_TO_CLIPBOARD,
49 execute: (dispatch, resources) => {
50 dispatch<any>(copyToClipboardAction(resources));
54 const msCopyUuid: MultiSelectMenuAction = {
59 execute: (dispatch, resources) => {
60 dispatch<any>(copyStringToClipboardAction(resources[0].uuid));
64 const msEditProjectAction: MultiSelectMenuAction = {
69 execute: (dispatch, resources) => {
70 dispatch<any>(openProjectUpdateDialog(resources[0]));
74 const msMoveToAction: MultiSelectMenuAction = {
79 execute: (dispatch, resource) => {
80 dispatch<any>(openMoveProjectDialog(resource[0]));
84 const msOpenWith3rdPartyClientAction: MultiSelectMenuAction = {
85 name: OPEN_WITH_3RD_PARTY_CLIENT,
86 icon: FolderSharedIcon,
89 execute: (dispatch, resources) => {
90 dispatch<any>(openWebDavS3InfoDialog(resources[0].uuid));
94 export const msToggleTrashAction: MultiSelectMenuAction = {
98 altName: 'Restore from Trash',
99 altIcon: RestoreFromTrashIcon,
101 useAlts: (uuid, iconProps) => {
102 return uuid ? (getResource(uuid)(iconProps.resources) as any)?.isTrashed : false;
104 execute: (dispatch, resources) => {
105 for (const resource of [...resources]) {
106 dispatch<any>(toggleProjectTrashed(resource.uuid, resource.ownerUuid, resource.isTrashed!!, resources.length > 1));
111 const msFreezeProjectAction: MultiSelectMenuAction = {
112 name: FREEZE_PROJECT,
115 altName: 'Unfreeze Project',
116 altIcon: UnfreezeIcon,
118 useAlts: (uuid, iconProps) => {
119 return uuid ? !!(getResource(uuid)(iconProps.resources) as any).frozenByUuid : false;
121 execute: (dispatch, resources) => {
122 if ((resources[0] as any).frozenByUuid) {
123 dispatch<any>(unfreezeProject(resources[0].uuid));
125 dispatch<any>(freezeProject(resources[0].uuid));
130 const msNewProjectAction: MultiSelectMenuAction = {
132 icon: NewProjectIcon,
135 execute: (dispatch, resources): void => {
136 dispatch<any>(openProjectCreateDialog(resources[0].uuid));
140 const msShareAction: MultiSelectMenuAction = {
145 execute: (dispatch, resources) => {
146 dispatch<any>(openSharingDialog(resources[0].uuid));
150 export const msProjectActionSet: MultiSelectMenuActionSet = [
152 ...msCommonActionSet,
157 msFreezeProjectAction,
158 msOpenWith3rdPartyClientAction,
159 msCopyToClipboardMenuAction,
165 export const msCommonProjectActionFilter = new Set<string>([
169 COPY_LINK_TO_CLIPBOARD,
175 OPEN_WITH_3RD_PARTY_CLIENT,
180 export const msReadOnlyProjectActionFilter = new Set<string>([ADD_TO_FAVORITES, API_DETAILS, COPY_LINK_TO_CLIPBOARD, COPY_UUID, OPEN_IN_NEW_TAB, OPEN_WITH_3RD_PARTY_CLIENT, VIEW_DETAILS,]);
181 export const msFrozenProjectActionFilter = new Set<string>([ADD_TO_FAVORITES, API_DETAILS, COPY_LINK_TO_CLIPBOARD, COPY_UUID, OPEN_IN_NEW_TAB, OPEN_WITH_3RD_PARTY_CLIENT, VIEW_DETAILS, SHARE, FREEZE_PROJECT])
182 export const msAdminFrozenProjectActionFilter = new Set<string>([ADD_TO_FAVORITES, API_DETAILS, COPY_LINK_TO_CLIPBOARD, COPY_UUID, OPEN_IN_NEW_TAB, OPEN_WITH_3RD_PARTY_CLIENT, VIEW_DETAILS, SHARE, FREEZE_PROJECT, ADD_TO_PUBLIC_FAVORITES])
184 export const msFilterGroupActionFilter = new Set<string>([ADD_TO_FAVORITES, API_DETAILS, COPY_LINK_TO_CLIPBOARD, COPY_UUID, OPEN_IN_NEW_TAB, OPEN_WITH_3RD_PARTY_CLIENT, VIEW_DETAILS, SHARE, MOVE_TO_TRASH, EDIT_PROJECT, MOVE_TO])
185 export const msAdminFilterGroupActionFilter = new Set<string>([ADD_TO_FAVORITES, API_DETAILS, COPY_LINK_TO_CLIPBOARD, COPY_UUID, OPEN_IN_NEW_TAB, OPEN_WITH_3RD_PARTY_CLIENT, VIEW_DETAILS, SHARE, MOVE_TO_TRASH, EDIT_PROJECT, MOVE_TO, ADD_TO_PUBLIC_FAVORITES])