16439: Fixes colletion/project creation placement.
authorLucas Di Pentima <lucas@di-pentima.com.ar>
Tue, 2 Jun 2020 18:47:42 +0000 (15:47 -0300)
committerLucas Di Pentima <lucas@di-pentima.com.ar>
Tue, 2 Jun 2020 18:47:42 +0000 (15:47 -0300)
When the user was placed on other sections than 'Projects' on the side
panel, the newly created collections/projects were going to the user's
home project.

Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas@di-pentima.com.ar>

src/store/collections/collection-create-actions.ts
src/store/projects/project-create-actions.ts

index 140756bfe6f85973688df0eaa04fa35f37435fc8..b6f0ddccf61dfebb61e140728becf1cf4e1d59ab 100644 (file)
@@ -12,7 +12,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 { isItemNotInProject, isProjectOrRunProcessRoute } from '~/store/projects/project-create-actions';
+import { isProjectOrRunProcessRoute } from '~/store/projects/project-create-actions';
 import { snackbarActions, SnackbarKind } from '~/store/snackbar/snackbar-actions';
 import { CollectionResource } from "~/models/collection";
 
@@ -26,9 +26,8 @@ export const COLLECTION_CREATE_FORM_NAME = "collectionCreateFormName";
 
 export const openCollectionCreateDialog = (ownerUuid: string) =>
     (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
-        const router = getState();
-        const properties = getState().properties;
-        if (isItemNotInProject(properties) || !isProjectOrRunProcessRoute(router)) {
+        const { router } = getState();
+        if (!isProjectOrRunProcessRoute(router)) {
             const userUuid = getUserUuid(getState());
             if (!userUuid) { return; }
             dispatch(initialize(COLLECTION_CREATE_FORM_NAME, { ownerUuid: userUuid }));
index 6f45bc38e7858516e1c1571e6dcdd0b694c88d26..583a4bd6978237bfc695fd8fe8f1cdae93bd41a1 100644 (file)
@@ -12,6 +12,7 @@ import { ProjectResource } from '~/models/project';
 import { ServiceRepository } from '~/services/services';
 import { matchProjectRoute, matchRunProcessRoute } from '~/routes/routes';
 import { ResourcePropertiesFormData } from '~/views-components/resource-properties-form/resource-properties-form';
+import { RouterState } from "react-router-redux";
 
 export interface ProjectCreateFormDialogData {
     ownerUuid: string;
@@ -28,26 +29,17 @@ export const PROJECT_CREATE_FORM_NAME = 'projectCreateFormName';
 export const PROJECT_CREATE_PROPERTIES_FORM_NAME = 'projectCreatePropertiesFormName';
 export const PROJECT_CREATE_FORM_SELECTOR = formValueSelector(PROJECT_CREATE_FORM_NAME);
 
-export const isProjectOrRunProcessRoute = ({ router }: RootState) => {
+export const isProjectOrRunProcessRoute = (router: RouterState) => {
     const pathname = router.location ? router.location.pathname : '';
     const matchProject = matchProjectRoute(pathname);
     const matchRunProcess = matchRunProcessRoute(pathname);
     return Boolean(matchProject || matchRunProcess);
 };
 
-export const isItemNotInProject = (properties: any) => {
-    if (properties.breadcrumbs) {
-        return Boolean(properties.breadcrumbs[0].label !== 'Projects');
-    } else {
-        return;
-    }
-};
-
 export const openProjectCreateDialog = (ownerUuid: string) =>
     (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
-        const router = getState();
-        const properties = getState().properties;
-        if (isItemNotInProject(properties) || !isProjectOrRunProcessRoute(router)) {
+        const { router } = getState();
+        if (!isProjectOrRunProcessRoute(router)) {
             const userUuid = getUserUuid(getState());
             if (!userUuid) { return; }
             dispatch(initialize(PROJECT_CREATE_FORM_NAME, { ownerUuid: userUuid }));