1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { Dispatch } from "redux";
6 import { RootState } from "~/store/store";
7 import { ServiceRepository } from "~/services/services";
8 import { snackbarActions } from "~/store/snackbar/snackbar-actions";
9 import { trashPanelActions } from "~/store/trash-panel/trash-panel-action";
10 import { activateSidePanelTreeItem, loadSidePanelTreeProjects } from "~/store/side-panel-tree/side-panel-tree-actions";
11 import { projectPanelActions } from "~/store/project-panel/project-panel-action";
13 export const toggleProjectTrashed = (resource: { uuid: string; name: string, isTrashed?: boolean, ownerUuid?: string }) =>
14 async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository): Promise<any> => {
15 if (resource.isTrashed) {
16 dispatch(snackbarActions.OPEN_SNACKBAR({ message: "Restoring from trash..." }));
17 await services.groupsService.untrash(resource.uuid);
18 dispatch<any>(activateSidePanelTreeItem(resource.uuid));
19 dispatch(trashPanelActions.REQUEST_ITEMS());
20 dispatch(snackbarActions.CLOSE_SNACKBAR());
21 dispatch(snackbarActions.OPEN_SNACKBAR({
22 message: "Restored from trash",
26 dispatch(snackbarActions.OPEN_SNACKBAR({ message: "Moving to trash..." }));
27 await services.groupsService.trash(resource.uuid);
28 dispatch<any>(loadSidePanelTreeProjects(resource.ownerUuid!!));
29 dispatch(snackbarActions.CLOSE_SNACKBAR());
30 dispatch(snackbarActions.OPEN_SNACKBAR({
31 message: "Added to trash",
37 export const toggleCollectionTrashed = (resource: { uuid: string; name: string, isTrashed?: boolean, ownerUuid?: string }) =>
38 async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository): Promise<any> => {
39 if (resource.isTrashed) {
40 dispatch(snackbarActions.OPEN_SNACKBAR({ message: "Restoring from trash..." }));
41 await services.collectionService.untrash(resource.uuid);
42 dispatch(trashPanelActions.REQUEST_ITEMS());
43 dispatch(snackbarActions.OPEN_SNACKBAR({
44 message: "Restored from trash",
48 dispatch(snackbarActions.OPEN_SNACKBAR({ message: "Moving to trash..." }));
49 await services.collectionService.trash(resource.uuid);
50 dispatch(projectPanelActions.REQUEST_ITEMS());
51 dispatch(snackbarActions.OPEN_SNACKBAR({
52 message: "Added to trash",