Merge branch '21128-toolbar-context-menu'
[arvados.git] / services / workbench2 / src / store / projects / project-lock-actions.ts
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import { Dispatch } from "redux";
6 import { ServiceRepository } from "services/services";
7 import { projectPanelActions } from "store/project-panel/project-panel-action-bind";
8 import { loadResource } from "store/resources/resources-actions";
9 import { RootState } from "store/store";
10 import { MultiSelectMenuActionNames } from "views-components/multiselect-toolbar/ms-menu-actions";
11 import { addDisabledButton, removeDisabledButton } from "store/multiselect/multiselect-actions";
12
13 export const freezeProject = (uuid: string) => async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
14     dispatch<any>(addDisabledButton(MultiSelectMenuActionNames.FREEZE_PROJECT))
15     const userUUID = getState().auth.user!.uuid;
16     
17     const updatedProject = await services.projectService.update(uuid, {
18         frozenByUuid: userUUID,
19     });
20     
21     dispatch(projectPanelActions.REQUEST_ITEMS());
22     dispatch<any>(loadResource(uuid, false));
23     dispatch<any>(removeDisabledButton(MultiSelectMenuActionNames.FREEZE_PROJECT))
24     return updatedProject;
25 };
26
27 export const unfreezeProject = (uuid: string) => async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
28     dispatch<any>(addDisabledButton(MultiSelectMenuActionNames.FREEZE_PROJECT))
29     const updatedProject = await services.projectService.update(uuid, {
30         frozenByUuid: null,
31     });
32
33     dispatch(projectPanelActions.REQUEST_ITEMS());
34     dispatch<any>(loadResource(uuid, false));
35     dispatch<any>(removeDisabledButton(MultiSelectMenuActionNames.FREEZE_PROJECT))
36     return updatedProject;
37 };