1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { RunProcessPanelAction, runProcessPanelActions } from '~/store/run-process-panel/run-process-panel-actions';
6 import { WorkflowResource, CommandInputParameter, getWorkflowInputs, parseWorkflowDefinition } from '~/models/workflow';
8 interface RunProcessPanel {
9 processOwnerUuid: string;
11 workflows: WorkflowResource[];
12 selectedWorkflow: WorkflowResource | undefined;
13 inputs: CommandInputParameter[];
16 const initialState: RunProcessPanel = {
20 selectedWorkflow: undefined,
24 export const runProcessPanelReducer = (state = initialState, action: RunProcessPanelAction): RunProcessPanel =>
25 runProcessPanelActions.match(action, {
26 SET_PROCESS_OWNER_UUID: processOwnerUuid => ({ ...state, processOwnerUuid }),
27 SET_CURRENT_STEP: currentStep => ({ ...state, currentStep }),
28 SET_WORKFLOWS: workflows => ({ ...state, workflows }),
29 SET_SELECTED_WORKFLOW: selectedWorkflow => ({
32 inputs: getWorkflowInputs(parseWorkflowDefinition(selectedWorkflow)) || [],