add-option-to-run-a-process-from-workflow-view
[arvados-workbench2.git] / src / store / workflow-panel / workflow-panel-actions.ts
index da0da54ddb46e8de55d9d7743145b5a49fb29da9..3d51cbb8dbff61db38620569ff19d6087b78287a 100644 (file)
@@ -9,7 +9,9 @@ import { bindDataExplorerActions } from '~/store/data-explorer/data-explorer-act
 import { propertiesActions } from '~/store/properties/properties-actions';
 import { getResource } from '../resources/resources';
 import { getProperty } from '~/store/properties/properties';
-import { WorkflowResource } from '../../models/workflow';
+import { WorkflowResource } from '~/models/workflow';
+import { navigateToRunProcess } from '~/store/navigation/navigation-action';
+import { goToStep, runProcessPanelActions } from '~/store/run-process-panel/run-process-panel-actions';
 
 export const WORKFLOW_PANEL_ID = "workflowPanel";
 const UUID_PREFIX_PROPERTY_NAME = 'uuidPrefix';
@@ -17,8 +19,10 @@ const WORKFLOW_PANEL_DETAILS_UUID = 'workflowPanelDetailsUuid';
 export const workflowPanelActions = bindDataExplorerActions(WORKFLOW_PANEL_ID);
 
 export const loadWorkflowPanel = () =>
-    (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+    async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
         dispatch(workflowPanelActions.REQUEST_ITEMS());
+        const response = await services.workflowService.list();
+        dispatch(runProcessPanelActions.SET_WORKFLOWS(response.items));
     };
 
 export const setUuidPrefix = (uuidPrefix: string) =>
@@ -28,6 +32,17 @@ export const getUuidPrefix = (state: RootState) => {
     return state.properties.uuidPrefix;
 };
 
+export const openRunProcess = (uuid: string) =>
+    async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {  
+        const workflows = getState().runProcessPanel.searchWorkflows;
+        const workflow = workflows.find(workflow => workflow.uuid === uuid);
+        dispatch<any>(navigateToRunProcess);
+        dispatch(runProcessPanelActions.RESET_RUN_PROCESS_PANEL()); 
+        dispatch<any>(goToStep(1));
+        dispatch(runProcessPanelActions.SET_STEP_CHANGED(true));
+        dispatch(runProcessPanelActions.SET_SELECTED_WORKFLOW(workflow!));       
+    };
+
 export const getPublicUserUuid = (state: RootState) => {
     const prefix = getProperty<string>(UUID_PREFIX_PROPERTY_NAME)(state.properties);
     return `${prefix}-tpzed-anonymouspublic`;