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 } from '~/models/workflow';
8 interface RunProcessPanel {
10 workflows: WorkflowResource[];
11 searchWorkflows: WorkflowResource[];
12 selectedWorkflow: WorkflowResource | undefined;
15 const initialState: RunProcessPanel = {
19 selectedWorkflow: undefined
22 export const runProcessPanelReducer = (state = initialState, action: RunProcessPanelAction): RunProcessPanel =>
23 runProcessPanelActions.match(action, {
24 SET_CURRENT_STEP: currentStep => ({ ...state, currentStep }),
25 SET_WORKFLOWS: workflows => ({ ...state, workflows, searchWorkflows: workflows }),
26 SET_SELECTED_WORKFLOW: selectedWorkflow => ({ ...state, selectedWorkflow }),
27 SEARCH_WORKFLOWS: term => ({ ...state, searchWorkflows: state.workflows.filter(workflow => workflow.name.includes(term)) }),