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 return services.groupsService.untrash(resource.uuid).then(() => {
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",
27 dispatch(snackbarActions.OPEN_SNACKBAR({ message: "Moving to trash..." }));
28 return services.groupsService.trash(resource.uuid).then(() => {
29 dispatch<any>(loadSidePanelTreeProjects(resource.ownerUuid!!));
30 dispatch(snackbarActions.CLOSE_SNACKBAR());
31 dispatch(snackbarActions.OPEN_SNACKBAR({
32 message: "Added to trash",
39 export const toggleCollectionTrashed = (resource: { uuid: string; name: string, isTrashed?: boolean, ownerUuid?: string }) =>
40 async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository): Promise<any> => {
41 if (resource.isTrashed) {
42 dispatch(snackbarActions.OPEN_SNACKBAR({ message: "Restoring from trash..." }));
43 return services.collectionService.untrash(resource.uuid).then(() => {
44 dispatch(trashPanelActions.REQUEST_ITEMS());
45 dispatch(snackbarActions.OPEN_SNACKBAR({
46 message: "Restored from trash",
51 dispatch(snackbarActions.OPEN_SNACKBAR({ message: "Moving to trash..." }));
52 return services.collectionService.trash(resource.uuid).then(() => {
53 dispatch(projectPanelActions.REQUEST_ITEMS());
54 dispatch(snackbarActions.OPEN_SNACKBAR({
55 message: "Added to trash",