X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/3367b1ff2a1d1050bb435f7bc8230c03435b2529..d1c2611350e47527730f6d3b226b998abf15a607:/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 aa79347c..b533717e 100644 --- a/src/store/workflow-panel/workflow-panel-actions.ts +++ b/src/store/workflow-panel/workflow-panel-actions.ts @@ -3,24 +3,82 @@ // SPDX-License-Identifier: AGPL-3.0 import { Dispatch } from 'redux'; -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 { 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 { getProperty } from 'store/properties/properties'; +import { navigateToRunProcess } from 'store/navigation/navigation-action'; +import { goToStep, runProcessPanelActions, loadPresets, getWorkflowRunnerSettings } from 'store/run-process-panel/run-process-panel-actions'; +import { snackbarActions } from 'store/snackbar/snackbar-actions'; +import { initialize } from 'redux-form'; +import { RUN_PROCESS_BASIC_FORM } from 'views/run-process-panel/run-process-basic-form'; +import { RUN_PROCESS_INPUTS_FORM } from 'views/run-process-panel/run-process-inputs-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'; - +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) => propertiesActions.SET_PROPERTY({ key: UUID_PREFIX_PROPERTY_NAME, value: uuidPrefix }); -export const getUuidPrefix = (state: RootState) =>{ +export const getUuidPrefix = (state: RootState) => { return state.properties.uuidPrefix; -}; \ No newline at end of file +}; + +export const openRunProcess = (workflowUuid: string, ownerUuid?: string, name?: string, inputObj?: { [key: string]: any }) => + async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { + const response = await services.workflowService.list(); + dispatch(runProcessPanelActions.SET_WORKFLOWS(response.items)); + + const workflows = getState().runProcessPanel.searchWorkflows; + const workflow = workflows.find(workflow => workflow.uuid === workflowUuid); + 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, getWorkflowRunnerSettings(workflow))); + if (ownerUuid) { + dispatch(runProcessPanelActions.SET_PROCESS_OWNER_UUID(ownerUuid)); + } + if (name) { + dispatch(initialize(RUN_PROCESS_BASIC_FORM, { name })); + } + if (inputObj) { + dispatch(initialize(RUN_PROCESS_INPUTS_FORM, inputObj)); + } + } else { + dispatch(snackbarActions.OPEN_SNACKBAR({ message: `You can't run this process` })); + } + }; + +export const getPublicUserUuid = (state: RootState) => { + const prefix = state.auth.localCluster; + return `${prefix}-tpzed-anonymouspublic`; +}; +export const getPublicGroupUuid = (state: RootState) => { + const prefix = state.auth.localCluster; + return `${prefix}-j7d0g-anonymouspublic`; +}; + +export const showWorkflowDetails = (uuid: string) => + propertiesActions.SET_PROPERTY({ key: WORKFLOW_PANEL_DETAILS_UUID, value: uuid }); + +export const getWorkflowDetails = (state: RootState) => { + const uuid = getProperty(WORKFLOW_PANEL_DETAILS_UUID)(state.properties); + const workflows = state.runProcessPanel.workflows; + const workflow = workflows.find(workflow => workflow.uuid === uuid); + return workflow || undefined; +};