1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { Dispatch } from "redux";
6 import { ServiceRepository } from "services/services";
7 import { projectPanelDataActions } from "store/project-panel/project-panel-action-bind";
8 import { loadResource } from "store/resources/resources-actions";
9 import { RootState } from "store/store";
10 import { ContextMenuActionNames } from "views-components/context-menu/context-menu-action-set";
11 import { addDisabledButton, removeDisabledButton } from "store/multiselect/multiselect-actions";
12 import { snackbarActions, SnackbarKind } from "store/snackbar/snackbar-actions";
14 export const freezeProject = (uuid: string) => async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
15 dispatch<any>(addDisabledButton(ContextMenuActionNames.FREEZE_PROJECT))
16 const userUUID = getState().auth.user!.uuid;
20 updatedProject = await services.projectService.update(uuid, {
21 frozenByUuid: userUUID,
25 dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Could not freeze project', hideDuration: 4000, kind: SnackbarKind.ERROR }));
28 dispatch(projectPanelDataActions.REQUEST_ITEMS());
29 dispatch<any>(loadResource(uuid, false));
30 dispatch<any>(removeDisabledButton(ContextMenuActionNames.FREEZE_PROJECT))
31 return updatedProject;
35 export const unfreezeProject = (uuid: string) => async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
36 dispatch<any>(addDisabledButton(ContextMenuActionNames.FREEZE_PROJECT))
37 const updatedProject = await services.projectService.update(uuid, {
41 dispatch(projectPanelDataActions.REQUEST_ITEMS());
42 dispatch<any>(loadResource(uuid, false));
43 dispatch<any>(removeDisabledButton(ContextMenuActionNames.FREEZE_PROJECT))
44 return updatedProject;