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 { MultiSelectMenuActionNames } from "views-components/multiselect-toolbar/ms-menu-actions";
7 import { openMoveProjectDialog } from 'store/projects/project-move-actions';
8 import { toggleProjectTrashed } from 'store/trash/trash-actions';
15 } from 'components/icon/icon';
16 import { RestoreFromTrashIcon, TrashIcon, FolderSharedIcon, Link } from 'components/icon/icon';
17 import { getResource } from 'store/resources/resources';
18 import { openProjectCreateDialog } from 'store/projects/project-create-actions';
19 import { openProjectUpdateDialog } from 'store/projects/project-update-actions';
20 import { freezeProject, unfreezeProject } from 'store/projects/project-lock-actions';
21 import { openWebDavS3InfoDialog } from 'store/collections/collection-info-actions';
22 import { copyToClipboardAction } from 'store/open-in-new-tab/open-in-new-tab.actions';
26 ADD_TO_PUBLIC_FAVORITES,
31 OPEN_W_3RD_PARTY_CLIENT,
38 } = MultiSelectMenuActionNames;
40 const msCopyToClipboardMenuAction: MultiSelectMenuAction = {
41 name: COPY_TO_CLIPBOARD,
45 execute: (dispatch, resources) => {
46 dispatch<any>(copyToClipboardAction(resources));
50 const msEditProjectAction: MultiSelectMenuAction = {
55 execute: (dispatch, resources) => {
56 dispatch<any>(openProjectUpdateDialog(resources[0]));
60 const msMoveToAction: MultiSelectMenuAction = {
65 execute: (dispatch, resource) => {
66 dispatch<any>(openMoveProjectDialog(resource[0]));
70 const msOpenWith3rdPartyClientAction: MultiSelectMenuAction = {
71 name: OPEN_W_3RD_PARTY_CLIENT,
72 icon: FolderSharedIcon,
75 execute: (dispatch, resources) => {
76 dispatch<any>(openWebDavS3InfoDialog(resources[0].uuid));
80 export const msToggleTrashAction: MultiSelectMenuAction = {
84 altName: 'Restore from Trash',
85 altIcon: RestoreFromTrashIcon,
87 useAlts: (uuid, iconProps) => {
88 return uuid ? (getResource(uuid)(iconProps.resources) as any).isTrashed : false;
90 execute: (dispatch, resources) => {
91 for (const resource of [...resources]) {
92 dispatch<any>(toggleProjectTrashed(resource.uuid, resource.ownerUuid, resource.isTrashed!!, resources.length > 1));
97 const msFreezeProjectAction: MultiSelectMenuAction = {
101 altName: 'Unfreeze Project',
102 altIcon: UnfreezeIcon,
104 useAlts: (uuid, iconProps) => {
105 return uuid ? !!(getResource(uuid)(iconProps.resources) as any).frozenByUuid : false;
107 execute: (dispatch, resources) => {
108 if ((resources[0] as any).frozenByUuid) {
109 dispatch<any>(unfreezeProject(resources[0].uuid));
111 dispatch<any>(freezeProject(resources[0].uuid));
116 const msNewProjectAction: MultiSelectMenuAction = {
118 icon: NewProjectIcon,
121 execute: (dispatch, resources): void => {
122 dispatch<any>(openProjectCreateDialog(resources[0].uuid));
126 export const msProjectActionSet: MultiSelectMenuActionSet = [
128 ...msCommonActionSet,
133 msFreezeProjectAction,
134 msOpenWith3rdPartyClientAction,
135 msCopyToClipboardMenuAction
139 export const msCommonProjectActionFilter = new Set<string>([
149 OPEN_W_3RD_PARTY_CLIENT,
153 export const msReadOnlyProjectActionFilter = new Set<string>([ADD_TO_FAVORITES, API_DETAILS, COPY_TO_CLIPBOARD, OPEN_IN_NEW_TAB, OPEN_W_3RD_PARTY_CLIENT, VIEW_DETAILS,]);
154 export const msFrozenProjectActionFilter = new Set<string>([ADD_TO_FAVORITES, API_DETAILS, COPY_TO_CLIPBOARD, OPEN_IN_NEW_TAB, OPEN_W_3RD_PARTY_CLIENT, VIEW_DETAILS, SHARE, FREEZE_PROJECT])
155 export const msAdminFrozenProjectActionFilter = new Set<string>([ADD_TO_FAVORITES, API_DETAILS, COPY_TO_CLIPBOARD, OPEN_IN_NEW_TAB, OPEN_W_3RD_PARTY_CLIENT, VIEW_DETAILS, SHARE, FREEZE_PROJECT, ADD_TO_PUBLIC_FAVORITES])
157 export const msFilterGroupActionFilter = new Set<string>([ADD_TO_FAVORITES, API_DETAILS, COPY_TO_CLIPBOARD, OPEN_IN_NEW_TAB, OPEN_W_3RD_PARTY_CLIENT, VIEW_DETAILS, SHARE, MOVE_TO_TRASH, EDIT_PROJECT, MOVE_TO])
158 export const msAdminFilterGroupActionFilter = new Set<string>([ADD_TO_FAVORITES, API_DETAILS, COPY_TO_CLIPBOARD, OPEN_IN_NEW_TAB, OPEN_W_3RD_PARTY_CLIENT, VIEW_DETAILS, SHARE, MOVE_TO_TRASH, EDIT_PROJECT, MOVE_TO, ADD_TO_PUBLIC_FAVORITES])