X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/2129d2a8fc553a0e89b374bdad2226ff3b3d377e..aa48015966dd61d462f43a1a336b1700c78624aa:/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 85f0b9bccd..66a15a9ee0 100644 --- a/src/store/workflow-panel/workflow-panel-actions.ts +++ b/src/store/workflow-panel/workflow-panel-actions.ts @@ -9,15 +9,22 @@ import { bindDataExplorerActions } from 'store/data-explorer/data-explorer-actio 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 { + 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'; -import { getResource, ResourcesState } from 'store/resources/resources'; +import { getResource } from 'store/resources/resources'; import { ProjectResource } from 'models/project'; import { UserResource } from 'models/user'; +import { getUserUuid } from "common/getuser"; +import { getWorkflowInputs, parseWorkflowDefinition } from 'models/workflow'; export const WORKFLOW_PANEL_ID = "workflowPanel"; const UUID_PREFIX_PROPERTY_NAME = 'uuidPrefix'; @@ -55,12 +62,31 @@ export const openRunProcess = (workflowUuid: string, ownerUuid?: string, name?: dispatch(initialize(RUN_PROCESS_ADVANCED_FORM, getWorkflowRunnerSettings(workflow))); let owner; if (ownerUuid) { - dispatch(runProcessPanelActions.SET_PROCESS_OWNER_UUID(ownerUuid)); + // Must be writable. + const userUuid = getUserUuid(getState()); owner = getResource(ownerUuid)(getState().resources); + if (!owner || !userUuid || owner.writableBy.indexOf(userUuid) === -1) { + owner = undefined; + } + } + if (owner) { + dispatch(runProcessPanelActions.SET_PROCESS_OWNER_UUID(owner.uuid)); } dispatch(initialize(RUN_PROCESS_BASIC_FORM, { name, owner })); + const definition = parseWorkflowDefinition(workflow); + if (definition) { + const inputs = getWorkflowInputs(definition); + if (inputs) { + const values = inputs.reduce((values, input) => ({ + ...values, + [input.id]: input.default, + }), {}); + dispatch(initialize(RUN_PROCESS_INPUTS_FORM, values)); + } + } + if (inputObj) { dispatch(initialize(RUN_PROCESS_INPUTS_FORM, inputObj)); }