X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/0259b9ba3e4b296fd4d360a7f48f6d9ac53ce38e..a5e78803ff259ce6467ecbc286ee970f1bfda4aa:/src/store/workflow-panel/workflow-panel-actions.ts diff --git a/src/store/workflow-panel/workflow-panel-actions.ts b/src/store/workflow-panel/workflow-panel-actions.ts index cc2469d7..bfd899fd 100644 --- a/src/store/workflow-panel/workflow-panel-actions.ts +++ b/src/store/workflow-panel/workflow-panel-actions.ts @@ -7,10 +7,12 @@ import { RootState } from '~/store/store'; import { ServiceRepository } from '~/services/services'; import { bindDataExplorerActions } from '~/store/data-explorer/data-explorer-action'; import { propertiesActions } from '~/store/properties/properties-actions'; -import { getResource } from '../resources/resources'; import { getProperty } from '~/store/properties/properties'; -import { WorkflowResource } from '../../models/workflow'; -import { ResourceObjectType } from '~/models/resource'; +import { navigateToRunProcess } from '~/store/navigation/navigation-action'; +import { goToStep, runProcessPanelActions, loadPresets, DEFAULT_ADVANCED_FORM_VALUES } from '~/store/run-process-panel/run-process-panel-actions'; +import { snackbarActions } from '~/store/snackbar/snackbar-actions'; +import { initialize } from 'redux-form'; +import { RUN_PROCESS_ADVANCED_FORM } from '~/views/run-process-panel/run-process-advanced-form'; export const WORKFLOW_PANEL_ID = "workflowPanel"; const UUID_PREFIX_PROPERTY_NAME = 'uuidPrefix'; @@ -18,8 +20,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) => @@ -29,12 +33,28 @@ export const getUuidPrefix = (state: RootState) => { return state.properties.uuidPrefix; }; +export const openRunProcess = (uuid: string) => + (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { + const workflows = getState().runProcessPanel.searchWorkflows; + const workflow = workflows.find(workflow => workflow.uuid === uuid); + if (workflow) { + dispatch(navigateToRunProcess); + dispatch(goToStep(1)); + dispatch(runProcessPanelActions.SET_STEP_CHANGED(true)); + dispatch(runProcessPanelActions.SET_SELECTED_WORKFLOW(workflow)); + dispatch(loadPresets(workflow.uuid)); + dispatch(initialize(RUN_PROCESS_ADVANCED_FORM, DEFAULT_ADVANCED_FORM_VALUES)); + } else { + dispatch(snackbarActions.OPEN_SNACKBAR({ message: `You can't run this process` })); + } + }; + export const getPublicUserUuid = (state: RootState) => { - const prefix = getProperty(UUID_PREFIX_PROPERTY_NAME)(state.properties); + const prefix = state.auth.localCluster; return `${prefix}-tpzed-anonymouspublic`; }; export const getPublicGroupUuid = (state: RootState) => { - const prefix = getProperty(UUID_PREFIX_PROPERTY_NAME)(state.properties); + const prefix = state.auth.localCluster; return `${prefix}-j7d0g-anonymouspublic`; }; @@ -43,5 +63,7 @@ export const showWorkflowDetails = (uuid: string) => export const getWorkflowDetails = (state: RootState) => { const uuid = getProperty(WORKFLOW_PANEL_DETAILS_UUID)(state.properties); - return uuid ? getResource(uuid)(state.resources) : undefined; + const workflows = state.runProcessPanel.workflows; + const workflow = workflows.find(workflow => workflow.uuid === uuid); + return workflow || undefined; };