refs #14265 Merge branch 'origin/14265-search-bar-icon'
[arvados-workbench2.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     SEARCH_WORKFLOWS: ofType<string>()
16 });
17
18 export interface RunProcessSecondStepDataFormProps {
19     name: string;
20     description: string;
21 }
22
23 export const RUN_PROCESS_SECOND_STEP_FORM_NAME = 'runProcessSecondStepFormName';
24
25 export type RunProcessPanelAction = UnionOf<typeof runProcessPanelActions>;
26
27 export const loadRunProcessPanel = () =>
28     async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
29         try {
30             const response = await services.workflowService.list();
31             dispatch(runProcessPanelActions.SET_WORKFLOWS(response.items));
32         } catch (e) {
33             return;
34         }
35     };
36
37 export const setWorkflow = (workflow: WorkflowResource) => 
38     async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
39         dispatch(runProcessPanelActions.SET_SELECTED_WORKFLOW(workflow));
40     };
41
42 export const goToStep = (step: number) => runProcessPanelActions.SET_CURRENT_STEP(step);
43
44 export const searchWorkflows = (term: string) => runProcessPanelActions.SEARCH_WORKFLOWS(term);