1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { ContextMenuActionSet, ContextMenuActionNames } from "../context-menu-action-set";
6 import { NewProjectIcon, RenameIcon, MoveToIcon, DetailsIcon, AdvancedIcon, OpenIcon, Link, FolderSharedIcon } from "components/icon/icon";
7 import { ToggleFavoriteAction } from "../actions/favorite-action";
8 import { toggleFavorite } from "store/favorites/favorites-actions";
9 import { favoritePanelActions } from "store/favorite-panel/favorite-panel-action";
10 import { openMoveProjectDialog } from "store/projects/project-move-actions";
11 import { openProjectCreateDialog } from "store/projects/project-create-actions";
12 import { openProjectUpdateDialog } from "store/projects/project-update-actions";
13 import { ToggleTrashAction } from "views-components/context-menu/actions/trash-action";
14 import { toggleProjectTrashed } from "store/trash/trash-actions";
15 import { ShareIcon } from "components/icon/icon";
16 import { openSharingDialog } from "store/sharing-dialog/sharing-dialog-actions";
17 import { openAdvancedTabDialog } from "store/advanced-tab/advanced-tab";
18 import { openDetailsPanel } from "store/details-panel/details-panel-action";
19 import { copyToClipboardAction, openInNewTabAction } from "store/open-in-new-tab/open-in-new-tab.actions";
20 import { openWebDavS3InfoDialog } from "store/collections/collection-info-actions";
21 import { ToggleLockAction } from "../actions/lock-action";
22 import { freezeProject, unfreezeProject } from "store/projects/project-lock-actions";
24 export const toggleFavoriteAction = {
25 component: ToggleFavoriteAction,
26 name: ContextMenuActionNames.ADD_TO_FAVORITES,
27 execute: (dispatch, resources) => {
28 dispatch(toggleFavorite(resources[0])).then(() => {
29 dispatch(favoritePanelActions.REQUEST_ITEMS());
34 export const openInNewTabMenuAction = {
36 name: ContextMenuActionNames.OPEN_IN_NEW_TAB,
37 execute: (dispatch, resources) => {
38 dispatch(openInNewTabAction(resources[0]));
42 export const copyToClipboardMenuAction = {
44 name: ContextMenuActionNames.COPY_LINK_TO_CLIPBOARD,
45 execute: (dispatch, resources) => {
46 dispatch(copyToClipboardAction(resources));
50 export const viewDetailsAction = {
52 name: ContextMenuActionNames.VIEW_DETAILS,
53 execute: (dispatch, resources) => {
54 dispatch(openDetailsPanel(resources[0].uuid));
58 export const advancedAction = {
60 name: ContextMenuActionNames.API_DETAILS,
61 execute: (dispatch, resources) => {
62 dispatch(openAdvancedTabDialog(resources[0].uuid));
66 export const openWith3rdPartyClientAction = {
67 icon: FolderSharedIcon,
68 name: ContextMenuActionNames.OPEN_WITH_3RD_PARTY_CLIENT,
69 execute: (dispatch, resources) => {
70 dispatch(openWebDavS3InfoDialog(resources[0].uuid));
74 export const editProjectAction = {
76 name: ContextMenuActionNames.EDIT_PROJECT,
77 execute: (dispatch, resources) => {
78 dispatch(openProjectUpdateDialog(resources[0]));
82 export const shareAction = {
84 name: ContextMenuActionNames.SHARE,
85 execute: (dispatch, resources) => {
86 dispatch(openSharingDialog(resources[0].uuid));
90 export const moveToAction = {
92 name: ContextMenuActionNames.MOVE_TO,
93 execute: (dispatch, resource) => {
94 dispatch(openMoveProjectDialog(resource[0]));
98 export const toggleTrashAction = {
99 component: ToggleTrashAction,
100 name: ContextMenuActionNames.MOVE_TO_TRASH,
101 execute: (dispatch, resources) => {
102 dispatch(toggleProjectTrashed(resources[0].uuid, resources[0].ownerUuid, resources[0].isTrashed!!, resources.length > 1));
106 export const freezeProjectAction = {
107 component: ToggleLockAction,
108 name: ContextMenuActionNames.FREEZE_PROJECT,
109 execute: (dispatch, resources) => {
110 if (resources[0].isFrozen) {
111 dispatch(unfreezeProject(resources[0].uuid));
113 dispatch(freezeProject(resources[0].uuid));
118 export const newProjectAction: any = {
119 icon: NewProjectIcon,
120 name: ContextMenuActionNames.NEW_PROJECT,
121 execute: (dispatch, resources): void => {
122 dispatch(openProjectCreateDialog(resources[0].uuid));
126 export const readOnlyProjectActionSet: ContextMenuActionSet = [
127 [toggleFavoriteAction, openInNewTabMenuAction, copyToClipboardMenuAction, viewDetailsAction, advancedAction, openWith3rdPartyClientAction],
130 export const filterGroupActionSet: ContextMenuActionSet = [
132 toggleFavoriteAction,
133 openInNewTabMenuAction,
134 copyToClipboardMenuAction,
137 openWith3rdPartyClientAction,
145 export const frozenActionSet: ContextMenuActionSet = [
148 toggleFavoriteAction,
149 openInNewTabMenuAction,
150 copyToClipboardMenuAction,
153 openWith3rdPartyClientAction,
158 export const projectActionSet: ContextMenuActionSet = [
160 toggleFavoriteAction,
161 openInNewTabMenuAction,
162 copyToClipboardMenuAction,
165 openWith3rdPartyClientAction,