1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { MultiSelectMenuAction, MultiSelectMenuActionNames } from "views-components/multiselect-toolbar/ms-menu-action-set";
6 import { MoveToIcon, Link } from "components/icon/icon";
7 import { openMoveProjectDialog } from "store/projects/project-move-actions";
8 import { toggleProjectTrashed } from "store/trash/trash-actions";
9 import { copyToClipboardAction } from "store/open-in-new-tab/open-in-new-tab.actions";
10 import { toggleFavorite } from "store/favorites/favorites-actions";
11 import { favoritePanelActions } from "store/favorite-panel/favorite-panel-action";
12 import { AddFavoriteIcon, RemoveFavoriteIcon } from "components/icon/icon";
13 import { RestoreFromTrashIcon, TrashIcon } from "components/icon/icon";
14 import { getResource } from "store/resources/resources";
15 import { checkFavorite } from "store/favorites/favorites-reducer";
17 export const msToggleFavoriteAction = {
18 name: MultiSelectMenuActionNames.ADD_TO_FAVORITES,
19 icon: AddFavoriteIcon,
21 altText: 'Remove from Favorites',
22 altIcon: RemoveFavoriteIcon,
24 isDefault: (uuid, resources, favorites)=>{
25 return !checkFavorite(uuid, favorites);
27 execute: (dispatch, resources) => {
28 dispatch(toggleFavorite(resources[0])).then(() => {
29 dispatch(favoritePanelActions.REQUEST_ITEMS());
34 export const msCopyToClipboardMenuAction = {
35 name: MultiSelectMenuActionNames.COPY_TO_CLIPBOARD,
39 execute: (dispatch, resources) => {
40 dispatch(copyToClipboardAction(resources));
44 export const msMoveToAction = {
45 name: MultiSelectMenuActionNames.MOVE_TO,
49 execute: (dispatch, resource) => {
50 dispatch(openMoveProjectDialog(resource[0]));
54 export const msToggleTrashAction = {
55 name: MultiSelectMenuActionNames.ADD_TO_TRASH,
58 altText: 'Restore from Trash',
59 altIcon: RestoreFromTrashIcon,
61 isDefault: (uuid, resources, favorites = []) => {
62 return uuid ? !(getResource(uuid)(resources) as any).isTrashed : true;
64 execute: (dispatch, resources) => {
65 for (const resource of [...resources]) {
66 dispatch(toggleProjectTrashed(resource.uuid, resource.ownerUuid, resource.isTrashed!!, resources.length > 1));
71 export const msProjectActionSet: MultiSelectMenuAction[][] = [[msCopyToClipboardMenuAction, msMoveToAction, msToggleTrashAction, msToggleFavoriteAction]];