merge master
[arvados-workbench2.git] / src / store / run-process-panel / run-process-panel-reducer.ts
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import { RunProcessPanelAction, runProcessPanelActions } from '~/store/run-process-panel/run-process-panel-actions';
6 import { WorkflowResource } from '~/models/workflow';
7
8 interface RunProcessPanel {
9     currentStep: number;
10     workflows: WorkflowResource[];
11     selectedWorkflow: WorkflowResource | undefined;
12 }
13
14 const initialState: RunProcessPanel = {
15     currentStep: 0,
16     workflows: [],
17     selectedWorkflow: undefined
18 };
19
20 export const runProcessPanelReducer = (state = initialState, action: RunProcessPanelAction): RunProcessPanel =>
21     runProcessPanelActions.match(action, {
22         SET_CURRENT_STEP: currentStep => ({ ...state, currentStep }),
23         SET_WORKFLOWS: workflows => ({ ...state, workflows }), 
24         SET_SELECTED_WORKFLOW: selectedWorkflow => ({ ...state, selectedWorkflow }),
25         default: () => state
26     });