refs #14848-inproper-location-for-new-processes-fix
authorPawel Kowalczyk <pawel.kowalczyk@contractors.roche.com>
Tue, 19 Feb 2019 13:05:55 +0000 (14:05 +0100)
committerPawel Kowalczyk <pawel.kowalczyk@contractors.roche.com>
Tue, 19 Feb 2019 13:05:55 +0000 (14:05 +0100)
Arvados-DCO-1.1-Signed-off-by: Pawel Kowalczyk <pawel.kowalczyk@contractors.roche.com>

src/store/run-process-panel/run-process-panel-actions.ts
src/store/run-process-panel/run-process-panel-reducer.ts
src/views-components/side-panel-button/side-panel-button.tsx

index df2f4f2df2d9b83cf6f3498165a8782cdbe7408b..94759483032180507ba02c659ae40e9b69b1db23 100644 (file)
@@ -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<string>(),
     SET_PROCESS_OWNER_UUID: ofType<string>(),
     SET_CURRENT_STEP: ofType<number>(),
     SET_STEP_CHANGED: ofType<boolean>(),
@@ -45,7 +46,6 @@ export const loadRunProcessPanel = () =>
     async (dispatch: Dispatch<any>, 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<any>, 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,
index 12c8988bdaccdaba37043631c0f38b49df8c174a..9c7169990b117b3eaa9a5a84ae334b0302d6444c 100644 (file)
@@ -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 }),
index 61e72d08fc48ae2bf7d6aa8d0810d61f6677db8c..0f79759078d1ca2009a69643c2a7ab7681d467ca 100644 (file)
@@ -34,6 +34,7 @@ const styles: StyleRulesCallback<CssRules> = (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<SidePanelProps> {
 
@@ -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<any>(navigateToRunProcess);
             }