21898: changed context menu toggleDetailsPanel to openDetailsPanel
[arvados.git] / services / workbench2 / src / views-components / context-menu / action-sets / project-action-set.ts
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
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";
23
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());
30         });
31     },
32 };
33
34 export const openInNewTabMenuAction = {
35     icon: OpenIcon,
36     name: ContextMenuActionNames.OPEN_IN_NEW_TAB,
37     execute: (dispatch, resources) => {
38         dispatch(openInNewTabAction(resources[0]));
39     },
40 };
41
42 export const copyToClipboardMenuAction = {
43     icon: Link,
44     name: ContextMenuActionNames.COPY_LINK_TO_CLIPBOARD,
45     execute: (dispatch, resources) => {
46         dispatch(copyToClipboardAction(resources));
47     },
48 };
49
50 export const viewDetailsAction = {
51     icon: DetailsIcon,
52     name: ContextMenuActionNames.VIEW_DETAILS,
53     execute: (dispatch, resources) => {
54         dispatch(openDetailsPanel(resources[0].uuid));
55     },
56 };
57
58 export const advancedAction = {
59     icon: AdvancedIcon,
60     name: ContextMenuActionNames.API_DETAILS,
61     execute: (dispatch, resources) => {
62         dispatch(openAdvancedTabDialog(resources[0].uuid));
63     },
64 };
65
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));
71     },
72 };
73
74 export const editProjectAction = {
75     icon: RenameIcon,
76     name: ContextMenuActionNames.EDIT_PROJECT,
77     execute: (dispatch, resources) => {
78         dispatch(openProjectUpdateDialog(resources[0]));
79     },
80 };
81
82 export const shareAction = {
83     icon: ShareIcon,
84     name: ContextMenuActionNames.SHARE,
85     execute: (dispatch, resources) => {
86         dispatch(openSharingDialog(resources[0].uuid));
87     },
88 };
89
90 export const moveToAction = {
91     icon: MoveToIcon,
92     name: ContextMenuActionNames.MOVE_TO,
93     execute: (dispatch, resource) => {
94         dispatch(openMoveProjectDialog(resource[0]));
95     },
96 };
97
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));
103     },
104 };
105
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));
112         } else {
113             dispatch(freezeProject(resources[0].uuid));
114         }
115     },
116 };
117
118 export const newProjectAction: any = {
119     icon: NewProjectIcon,
120     name: ContextMenuActionNames.NEW_PROJECT,
121     execute: (dispatch, resources): void => {
122         dispatch(openProjectCreateDialog(resources[0].uuid));
123     },
124 };
125
126 export const readOnlyProjectActionSet: ContextMenuActionSet = [
127     [toggleFavoriteAction, openInNewTabMenuAction, copyToClipboardMenuAction, viewDetailsAction, advancedAction, openWith3rdPartyClientAction],
128 ];
129
130 export const filterGroupActionSet: ContextMenuActionSet = [
131     [
132         toggleFavoriteAction,
133         openInNewTabMenuAction,
134         copyToClipboardMenuAction,
135         viewDetailsAction,
136         advancedAction,
137         openWith3rdPartyClientAction,
138         editProjectAction,
139         shareAction,
140         moveToAction,
141         toggleTrashAction,
142     ],
143 ];
144
145 export const frozenActionSet: ContextMenuActionSet = [
146     [
147         shareAction,
148         toggleFavoriteAction,
149         openInNewTabMenuAction,
150         copyToClipboardMenuAction,
151         viewDetailsAction,
152         advancedAction,
153         openWith3rdPartyClientAction,
154         freezeProjectAction,
155     ],
156 ];
157
158 export const projectActionSet: ContextMenuActionSet = [
159     [
160         toggleFavoriteAction,
161         openInNewTabMenuAction,
162         copyToClipboardMenuAction,
163         viewDetailsAction,
164         advancedAction,
165         openWith3rdPartyClientAction,
166         editProjectAction,
167         shareAction,
168         moveToAction,
169         toggleTrashAction,
170         newProjectAction,
171         freezeProjectAction,
172     ],
173 ];