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 = (uuid: string, ownerUuid: string, isTrashed: boolean) =>
14 async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository): Promise<any> => {
16 dispatch(snackbarActions.OPEN_SNACKBAR({ message: "Restoring from trash..." }));
17 await services.groupsService.untrash(uuid);
18 dispatch<any>(activateSidePanelTreeItem(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(uuid);
28 dispatch<any>(loadSidePanelTreeProjects(ownerUuid));
29 dispatch(snackbarActions.CLOSE_SNACKBAR());
30 dispatch(snackbarActions.OPEN_SNACKBAR({
31 message: "Added to trash",
37 export const toggleCollectionTrashed = (uuid: string, isTrashed: boolean) =>
38 async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository): Promise<any> => {
40 dispatch(snackbarActions.OPEN_SNACKBAR({ message: "Restoring from trash..." }));
41 await services.collectionService.untrash(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(uuid);
50 dispatch(projectPanelActions.REQUEST_ITEMS());
51 dispatch(snackbarActions.OPEN_SNACKBAR({
52 message: "Added to trash",