X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/6b562ae2431132439e488f509d698800ee8ebe7d..47f421fa743e2b4b09d4f0fbfbead00545e327d4:/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 3d51cbb8..03ddf341 100644 --- a/src/store/workflow-panel/workflow-panel-actions.ts +++ b/src/store/workflow-panel/workflow-panel-actions.ts @@ -7,11 +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 { getResource } from '~/store/resources/resources'; import { getProperty } from '~/store/properties/properties'; import { WorkflowResource } from '~/models/workflow'; import { navigateToRunProcess } from '~/store/navigation/navigation-action'; import { goToStep, runProcessPanelActions } from '~/store/run-process-panel/run-process-panel-actions'; +import { snackbarActions } from '~/store/snackbar/snackbar-actions'; export const WORKFLOW_PANEL_ID = "workflowPanel"; const UUID_PREFIX_PROPERTY_NAME = 'uuidPrefix'; @@ -33,14 +34,17 @@ export const getUuidPrefix = (state: RootState) => { }; export const openRunProcess = (uuid: string) => - async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { + (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { const workflows = getState().runProcessPanel.searchWorkflows; const workflow = workflows.find(workflow => workflow.uuid === uuid); - dispatch(navigateToRunProcess); - dispatch(runProcessPanelActions.RESET_RUN_PROCESS_PANEL()); - dispatch(goToStep(1)); - dispatch(runProcessPanelActions.SET_STEP_CHANGED(true)); - dispatch(runProcessPanelActions.SET_SELECTED_WORKFLOW(workflow!)); + if (workflow) { + dispatch(navigateToRunProcess); + dispatch(goToStep(1)); + dispatch(runProcessPanelActions.SET_STEP_CHANGED(true)); + dispatch(runProcessPanelActions.SET_SELECTED_WORKFLOW(workflow)); + } else { + dispatch(snackbarActions.OPEN_SNACKBAR({ message: `You can't run this process` })); + } }; export const getPublicUserUuid = (state: RootState) => { @@ -57,5 +61,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; };