16594: Added project-uuid when starting workflow
[arvados-workbench2.git] / src / store / run-process-panel / run-process-panel-reducer.ts
index cb272dec7e8c31727ed5ca4bc74d1f718450149f..9c7169990b117b3eaa9a5a84ae334b0302d6444c 100644 (file)
@@ -6,16 +6,20 @@ import { RunProcessPanelAction, runProcessPanelActions } from '~/store/run-proce
 import { WorkflowResource, CommandInputParameter, getWorkflowInputs, parseWorkflowDefinition } from '~/models/workflow';
 
 interface RunProcessPanel {
+    processPathname: string;
     processOwnerUuid: string;
     currentStep: number;
     isStepChanged: boolean;
     workflows: WorkflowResource[];
     searchWorkflows: WorkflowResource[];
     selectedWorkflow: WorkflowResource | undefined;
+    presets?: WorkflowResource[];
+    selectedPreset?: WorkflowResource;
     inputs: CommandInputParameter[];
 }
 
 const initialState: RunProcessPanel = {
+    processPathname: '',
     processOwnerUuid: '',
     currentStep: 0,
     isStepChanged: false,
@@ -27,14 +31,25 @@ const initialState: RunProcessPanel = {
 
 export const runProcessPanelReducer = (state = initialState, action: RunProcessPanelAction): RunProcessPanel =>
     runProcessPanelActions.match(action, {
+        SET_PROCESS_PATHNAME: processPathname => ({ ...state, processPathname }),
         SET_PROCESS_OWNER_UUID: processOwnerUuid => ({ ...state, processOwnerUuid }),
         SET_CURRENT_STEP: currentStep => ({ ...state, currentStep }),
         SET_STEP_CHANGED: isStepChanged => ({ ...state, isStepChanged }),
         SET_SELECTED_WORKFLOW: selectedWorkflow => ({
             ...state,
             selectedWorkflow,
+            presets: undefined,
+            selectedPreset: selectedWorkflow,
             inputs: getWorkflowInputs(parseWorkflowDefinition(selectedWorkflow)) || [],
         }),
+        SET_WORKFLOW_PRESETS: presets => ({
+            ...state,
+            presets,
+        }),
+        SELECT_WORKFLOW_PRESET: selectedPreset => ({
+            ...state,
+            selectedPreset,
+        }),
         SET_WORKFLOWS: workflows => ({ ...state, workflows, searchWorkflows: workflows }),
         SEARCH_WORKFLOWS: term => {
             const termRegex = new RegExp(term, 'i');