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 { ContextMenuResource } from "store/context-menu/context-menu-actions";
16 import { checkFavorite } from "store/favorites/favorites-reducer";
18 export const msToggleFavoriteAction = {
19 name: MultiSelectMenuActionNames.TOGGLE_FAVORITE_ACTION,
20 defaultText: 'Add to Favorites',
21 altText: 'Remove from Favorites',
22 icon: AddFavoriteIcon,
23 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 = {
36 name: MultiSelectMenuActionNames.COPY_TO_CLIPBOARD,
37 execute: (dispatch, resources) => {
38 dispatch(copyToClipboardAction(resources));
42 export const msMoveToAction = {
44 name: MultiSelectMenuActionNames.MOVE_TO,
45 execute: (dispatch, resource) => {
46 dispatch(openMoveProjectDialog(resource[0]));
50 export const msToggleTrashAction = {
51 name: MultiSelectMenuActionNames.TOGGLE_TRASH_ACTION,
52 defaultText: 'Add to Trash',
53 altText: 'Restore from Trash',
55 altIcon: RestoreFromTrashIcon,
56 isDefault: (uuid, resources, favorites = []) => {
57 return uuid ? !(getResource(uuid)(resources) as any).isTrashed : true;
59 execute: (dispatch, resources) => {
60 for (const resource of [...resources]) {
61 dispatch(toggleProjectTrashed(resource.uuid, resource.ownerUuid, resource.isTrashed!!, resources.length > 1));
66 export const msProjectActionSet: MultiSelectMenuAction[][] = [[msCopyToClipboardMenuAction, msMoveToAction, msToggleTrashAction, msToggleFavoriteAction]];