From: Pawel Kowalczyk Date: Tue, 19 Feb 2019 13:05:55 +0000 (+0100) Subject: refs #14848-inproper-location-for-new-processes-fix X-Git-Tag: 1.4.0~46 X-Git-Url: https://git.arvados.org/arvados-workbench2.git/commitdiff_plain/4898dc527940f012f2ab70b4550e2f6c9bfe8b01?hp=-c refs #14848-inproper-location-for-new-processes-fix Arvados-DCO-1.1-Signed-off-by: Pawel Kowalczyk --- 4898dc527940f012f2ab70b4550e2f6c9bfe8b01 diff --git a/src/store/run-process-panel/run-process-panel-actions.ts b/src/store/run-process-panel/run-process-panel-actions.ts index df2f4f2d..94759483 100644 --- a/src/store/run-process-panel/run-process-panel-actions.ts +++ b/src/store/run-process-panel/run-process-panel-actions.ts @@ -15,11 +15,12 @@ import { createWorkflowMounts } from '~/models/process'; import { ContainerRequestState } from '~/models/container-request'; import { navigateToProcess } from '../navigation/navigation-action'; import { RunProcessAdvancedFormData, RUN_PROCESS_ADVANCED_FORM, VCPUS_FIELD, RAM_FIELD, RUNTIME_FIELD, OUTPUT_FIELD, API_FIELD } from '~/views/run-process-panel/run-process-advanced-form'; -import { isItemNotInProject, isProjectOrRunProcessRoute } from '~/store/projects/project-create-actions'; import { dialogActions } from '~/store/dialog/dialog-actions'; import { setBreadcrumbs } from '~/store/breadcrumbs/breadcrumbs-actions'; +import { matchProjectRoute } from '~/routes/routes'; export const runProcessPanelActions = unionize({ + SET_PROCESS_PATHNAME: ofType(), SET_PROCESS_OWNER_UUID: ofType(), SET_CURRENT_STEP: ofType(), SET_STEP_CHANGED: ofType(), @@ -45,7 +46,6 @@ export const loadRunProcessPanel = () => async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { try { dispatch(setBreadcrumbs([{ label: 'Run Process' }])); - dispatch(runProcessPanelActions.RESET_RUN_PROCESS_PANEL()); const response = await services.workflowService.list(); dispatch(runProcessPanelActions.SET_WORKFLOWS(response.items)); } catch (e) { @@ -119,12 +119,11 @@ export const runProcess = async (dispatch: Dispatch, getState: () => RootSt const inputsForm = getFormValues(RUN_PROCESS_INPUTS_FORM)(state) as WorkflowInputsData; const advancedForm = getFormValues(RUN_PROCESS_ADVANCED_FORM)(state) as RunProcessAdvancedFormData || DEFAULT_ADVANCED_FORM_VALUES; const userUuid = getState().auth.user!.uuid; - const router = getState(); - const properties = getState().properties; + const pathname = getState().runProcessPanel.processPathname; const { processOwnerUuid, selectedWorkflow } = state.runProcessPanel; if (selectedWorkflow) { const newProcessData = { - ownerUuid: isItemNotInProject(properties) || !isProjectOrRunProcessRoute(router) ? userUuid : processOwnerUuid, + ownerUuid: !matchProjectRoute(pathname) ? userUuid : processOwnerUuid, name: basicForm.name, description: basicForm.description, state: ContainerRequestState.COMMITTED, diff --git a/src/store/run-process-panel/run-process-panel-reducer.ts b/src/store/run-process-panel/run-process-panel-reducer.ts index 12c8988b..9c716999 100644 --- a/src/store/run-process-panel/run-process-panel-reducer.ts +++ b/src/store/run-process-panel/run-process-panel-reducer.ts @@ -6,6 +6,7 @@ import { RunProcessPanelAction, runProcessPanelActions } from '~/store/run-proce import { WorkflowResource, CommandInputParameter, getWorkflowInputs, parseWorkflowDefinition } from '~/models/workflow'; interface RunProcessPanel { + processPathname: string; processOwnerUuid: string; currentStep: number; isStepChanged: boolean; @@ -18,6 +19,7 @@ interface RunProcessPanel { } const initialState: RunProcessPanel = { + processPathname: '', processOwnerUuid: '', currentStep: 0, isStepChanged: false, @@ -29,6 +31,7 @@ const initialState: RunProcessPanel = { export const runProcessPanelReducer = (state = initialState, action: RunProcessPanelAction): RunProcessPanel => runProcessPanelActions.match(action, { + SET_PROCESS_PATHNAME: processPathname => ({ ...state, processPathname }), SET_PROCESS_OWNER_UUID: processOwnerUuid => ({ ...state, processOwnerUuid }), SET_CURRENT_STEP: currentStep => ({ ...state, currentStep }), SET_STEP_CHANGED: isStepChanged => ({ ...state, isStepChanged }), diff --git a/src/views-components/side-panel-button/side-panel-button.tsx b/src/views-components/side-panel-button/side-panel-button.tsx index 61e72d08..0f797590 100644 --- a/src/views-components/side-panel-button/side-panel-button.tsx +++ b/src/views-components/side-panel-button/side-panel-button.tsx @@ -34,6 +34,7 @@ const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ }); interface SidePanelDataProps { + location: any; currentItemId: string; } @@ -50,7 +51,8 @@ const transformOrigin: PopoverOrigin = { export const SidePanelButton = withStyles(styles)( connect((state: RootState) => ({ - currentItemId: getProperty(PROJECT_PANEL_CURRENT_UUID)(state.properties) + currentItemId: getProperty(PROJECT_PANEL_CURRENT_UUID)(state.properties), + location: state.router.location }))( class extends React.Component { @@ -98,7 +100,11 @@ export const SidePanelButton = withStyles(styles)( } handleRunProcessClick = () => { + const location = this.props.location; + this.props.dispatch(runProcessPanelActions.RESET_RUN_PROCESS_PANEL()); + this.props.dispatch(runProcessPanelActions.SET_PROCESS_PATHNAME(location.pathname)); this.props.dispatch(runProcessPanelActions.SET_PROCESS_OWNER_UUID(this.props.currentItemId)); + this.props.dispatch(navigateToRunProcess); }