Merge branch '14270_warning_message_after_changing_workflow'
[arvados-workbench2.git] / src / store / run-process-panel / run-process-panel-reducer.ts
index 0ad06bee58da253d83e2ad31fbad04a65b1bd7d6..cb272dec7e8c31727ed5ca4bc74d1f718450149f 100644 (file)
@@ -8,6 +8,7 @@ import { WorkflowResource, CommandInputParameter, getWorkflowInputs, parseWorkfl
 interface RunProcessPanel {
     processOwnerUuid: string;
     currentStep: number;
+    isStepChanged: boolean;
     workflows: WorkflowResource[];
     searchWorkflows: WorkflowResource[];
     selectedWorkflow: WorkflowResource | undefined;
@@ -17,6 +18,7 @@ interface RunProcessPanel {
 const initialState: RunProcessPanel = {
     processOwnerUuid: '',
     currentStep: 0,
+    isStepChanged: false,
     workflows: [],
     selectedWorkflow: undefined,
     inputs: [],
@@ -27,12 +29,20 @@ export const runProcessPanelReducer = (state = initialState, action: RunProcessP
     runProcessPanelActions.match(action, {
         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,
             inputs: getWorkflowInputs(parseWorkflowDefinition(selectedWorkflow)) || [],
         }),
-        SET_WORKFLOWS: workflows => ({ ...state, workflows, searchWorkflows: workflows }), 
-        SEARCH_WORKFLOWS: term => ({ ...state, searchWorkflows: state.workflows.filter(workflow => workflow.name.includes(term)) }),
+        SET_WORKFLOWS: workflows => ({ ...state, workflows, searchWorkflows: workflows }),
+        SEARCH_WORKFLOWS: term => {
+            const termRegex = new RegExp(term, 'i');
+            return {
+                ...state,
+                searchWorkflows: state.workflows.filter(workflow => termRegex.test(workflow.name)),
+            };
+        },
+        RESET_RUN_PROCESS_PANEL: () => ({ ...initialState, processOwnerUuid: state.processOwnerUuid }),
         default: () => state
     });
\ No newline at end of file