[ARVADOS-WORKBENCH2] created: 1.2.0-739-g7cf841b

Git user git at public.curoverse.com
Thu Oct 25 09:01:57 EDT 2018


        at  7cf841b66c30a9d39d08e50a230edf18dfbd5b81 (commit)


commit 7cf841b66c30a9d39d08e50a230edf18dfbd5b81
Author: Pawel Kowalczyk <pawel.kowalczyk at contractors.roche.com>
Date:   Thu Oct 25 15:01:40 2018 +0200

    creating-a-new-project-or-collection-anywhere-in-the-app-creates-it-in-projects-folder
    
    Feature #14402
    
    Arvados-DCO-1.1-Signed-off-by: Pawel Kowalczyk <pawel.kowalczyk at contractors.roche.com>

diff --git a/src/store/collections/collection-create-actions.ts b/src/store/collections/collection-create-actions.ts
index 05249b4..b05945c 100644
--- a/src/store/collections/collection-create-actions.ts
+++ b/src/store/collections/collection-create-actions.ts
@@ -11,7 +11,7 @@ import { getCommonResourceServiceError, CommonResourceServiceError } from "~/ser
 import { uploadCollectionFiles } from './collection-upload-actions';
 import { fileUploaderActions } from '~/store/file-uploader/file-uploader-actions';
 import { progressIndicatorActions } from "~/store/progress-indicator/progress-indicator-actions";
-import { isNotProjectItem } from '~/store/projects/project-create-actions';
+import { isItemNotInProject, isProjectOrRunProcessRoute } from '~/store/projects/project-create-actions';
 
 export interface CollectionCreateFormDialogData {
     ownerUuid: string;
@@ -23,7 +23,9 @@ export const COLLECTION_CREATE_FORM_NAME = "collectionCreateFormName";
 
 export const openCollectionCreateDialog = (ownerUuid: string) =>
     (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
-        if (isNotProjectItem) {
+        const router = getState();
+        const properties = getState().properties;
+        if (isItemNotInProject(properties) || !isProjectOrRunProcessRoute(router)) {
             const userUuid = getState().auth.user!.uuid;
             dispatch(initialize(COLLECTION_CREATE_FORM_NAME, { userUuid }));
         } else {
diff --git a/src/store/projects/project-create-actions.ts b/src/store/projects/project-create-actions.ts
index 92994d6..1fd1be0 100644
--- a/src/store/projects/project-create-actions.ts
+++ b/src/store/projects/project-create-actions.ts
@@ -9,7 +9,7 @@ import { dialogActions } from "~/store/dialog/dialog-actions";
 import { getCommonResourceServiceError, CommonResourceServiceError } from '~/services/common-service/common-resource-service';
 import { ProjectResource } from '~/models/project';
 import { ServiceRepository } from '~/services/services';
-import { matchProjectRoute } from '~/routes/routes';
+import { matchProjectRoute, matchRunProcessRoute } from '~/routes/routes';
 
 export interface ProjectCreateFormDialogData {
     ownerUuid: string;
@@ -19,32 +19,26 @@ export interface ProjectCreateFormDialogData {
 
 export const PROJECT_CREATE_FORM_NAME = 'projectCreateFormName';
 
-export const isProjectRoute = ({ router }: RootState) => {
+export const isProjectOrRunProcessRoute = ({ router }: RootState) => {
     const pathname = router.location ? router.location.pathname : '';
-    const match = matchProjectRoute(pathname);
-    return !!match;
+    const matchProject = matchProjectRoute(pathname);
+    const matchRunProcess = matchRunProcessRoute(pathname);
+    return Boolean(matchProject || matchRunProcess);
 };
 
-interface Properties {
-    breadcrumbs: Array<{ uuid: string, label: string }>;
-}
-
-export const isItemNotInProject = (properties: Properties) => {
+export const isItemNotInProject = (properties: any) => {
     if (properties.breadcrumbs) {
-        const isItemSharedWithMe = properties.breadcrumbs[0].label !== 'Projects';
-        return isItemSharedWithMe;
+        return Boolean(properties.breadcrumbs[0].label !== 'Projects');
     } else {
-        return false;
+        return ;
     }
 };
 
-export const isNotProjectItem = () => {
-    return isItemNotInProject || !isProjectRoute;
-};
-
 export const openProjectCreateDialog = (ownerUuid: string) =>
     (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
-        if (isNotProjectItem) {
+        const router = getState();
+        const properties = getState().properties;
+        if (isItemNotInProject(properties) || !isProjectOrRunProcessRoute(router)) {
             const userUuid = getState().auth.user!.uuid;
             dispatch(initialize(PROJECT_CREATE_FORM_NAME, { userUuid }));
         } else {
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 19a5450..ae89c94 100644
--- a/src/store/run-process-panel/run-process-panel-actions.ts
+++ b/src/store/run-process-panel/run-process-panel-actions.ts
@@ -15,7 +15,8 @@ import { createWorkflowMounts } from '~/models/process';
 import { ContainerRequestState } from '~/models/container-request';
 import { navigateToProcess } from '../navigation/navigation-action';
 import { RunProcessAdvancedFormData, RUN_PROCESS_ADVANCED_FORM } from '~/views/run-process-panel/run-process-advanced-form';
-import { isNotProjectItem } from '~/store/projects/project-create-actions';
+import { isItemNotInProject, isProjectOrRunProcessRoute } from '~/store/projects/project-create-actions';
+import { matchProjectRoute } from '~/routes/routes';
 
 export const runProcessPanelActions = unionize({
     SET_PROCESS_OWNER_UUID: ofType<string>(),
@@ -53,16 +54,24 @@ export const setWorkflow = (workflow: WorkflowResource) =>
 
 export const goToStep = (step: number) => runProcessPanelActions.SET_CURRENT_STEP(step);
 
+const isRunProcessRoute = ({ router }: RootState) => {
+    const pathname = router.location ? router.location.pathname : '';
+    const match = matchProjectRoute(pathname);
+    return !!match;
+};
+
 export const runProcess = async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
     const state = getState();
     const basicForm = getFormValues(RUN_PROCESS_BASIC_FORM)(state) as RunProcessBasicFormData;
     const inputsForm = getFormValues(RUN_PROCESS_INPUTS_FORM)(state) as WorkflowInputsData;
     const advancedForm = getFormValues(RUN_PROCESS_ADVANCED_FORM)(state) as RunProcessAdvancedFormData;
     const userUuid = getState().auth.user!.uuid;
+    const router = getState();
+    const properties = getState().properties;
     const { processOwnerUuid, selectedWorkflow } = state.runProcessPanel;
     if (selectedWorkflow) {
         const newProcessData = {
-            ownerUuid: isNotProjectItem ? userUuid : processOwnerUuid,
+            ownerUuid: isItemNotInProject(properties) || !isProjectOrRunProcessRoute(router) ? userUuid : processOwnerUuid,
             name: basicForm.name,
             description: basicForm.description,
             state: ContainerRequestState.COMMITTED,

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list