Merge branch 'master' of git.curoverse.com:arvados-workbench2 into 13861-run-process...
[arvados.git] / src / store / run-process-panel / run-process-panel-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 { unionize, ofType, UnionOf } from "~/common/unionize";
7 import { ServiceRepository } from "~/services/services";
8 import { RootState } from '~/store/store';
9 import { WorkflowResource } from '~/models/workflow';
10
11 export const runProcessPanelActions = unionize({
12     SET_CURRENT_STEP: ofType<number>(),
13     SET_WORKFLOWS: ofType<WorkflowResource[]>(),
14     SET_SELECTED_WORKFLOW: ofType<WorkflowResource>(),
15 });
16
17 export interface RunProcessSecondStepDataFormProps {
18     name: string;
19     description: string;
20 }
21
22 export const RUN_PROCESS_SECOND_STEP_FORM_NAME = 'runProcessSecondStepFormName';
23
24 export type RunProcessPanelAction = UnionOf<typeof runProcessPanelActions>;
25
26 export const loadRunProcessPanel = () =>
27     async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
28         try {
29             const response = await services.workflowService.list();
30             dispatch(runProcessPanelActions.SET_WORKFLOWS(response.items));
31         } catch (e) {
32             return;
33         }
34     };
35
36 export const setWorkflow = (workflow: WorkflowResource) => 
37     async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
38         dispatch(runProcessPanelActions.SET_SELECTED_WORKFLOW(workflow));
39     };
40
41 export const goToStep = (step: number) => runProcessPanelActions.SET_CURRENT_STEP(step);