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";
17 export const msToggleFavoriteAction = {
18 name: MultiSelectMenuActionNames.TOGGLE_FAVORITE_ACTION,
19 defaultText: 'Add to Favorites',
20 altText: 'Remove from Favorites',
21 icon: AddFavoriteIcon,
22 altIcon: RemoveFavoriteIcon,
23 execute: (dispatch, resources) => {
24 dispatch(toggleFavorite(resources[0])).then(() => {
25 dispatch(favoritePanelActions.REQUEST_ITEMS());
30 export const msCopyToClipboardMenuAction = {
32 name: MultiSelectMenuActionNames.COPY_TO_CLIPBOARD,
33 execute: (dispatch, resources) => {
34 dispatch(copyToClipboardAction(resources));
38 export const msMoveToAction = {
40 name: MultiSelectMenuActionNames.MOVE_TO,
41 execute: (dispatch, resource) => {
42 dispatch(openMoveProjectDialog(resource[0]));
46 export const msToggleTrashAction = {
47 name: MultiSelectMenuActionNames.TOGGLE_TRASH_ACTION,
48 defaultText: 'Add to Trash',
49 altText: 'Restore from Trash',
51 altIcon: RestoreFromTrashIcon,
52 execute: (dispatch, resources) => {
53 for (const resource of [...resources]) {
54 dispatch(toggleProjectTrashed(resource.uuid, resource.ownerUuid, resource.isTrashed!!, resources.length > 1));
59 export const msProjectActionSet: MultiSelectMenuAction[][] = [[msCopyToClipboardMenuAction, msMoveToAction, msToggleTrashAction, msToggleFavoriteAction]];