15856: Merge branch 'master' into 15856-illegal-chars-warning 15856-illegal-chars-warning
authorLucas Di Pentima <ldipentima@veritasgenetics.com>
Tue, 3 Dec 2019 18:09:52 +0000 (15:09 -0300)
committerLucas Di Pentima <ldipentima@veritasgenetics.com>
Tue, 3 Dec 2019 18:34:59 +0000 (15:34 -0300)
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <ldipentima@veritasgenetics.com>

1  2 
src/store/collections/collection-create-actions.ts
src/store/projects/project-create-actions.ts
src/store/projects/project-move-actions.ts
src/store/workbench/workbench-actions.ts

index a9534c6bb132c18a811a991285574a18ab9f88dc,c7dc2ae8ff7bb316410401c4d1662ad0c5ecc405..e077b2a5b33c47b717630baf51c2f83b7bb600a7
@@@ -5,6 -5,7 +5,7 @@@
  import { Dispatch } from "redux";
  import { reset, startSubmit, stopSubmit, initialize, FormErrors } from 'redux-form';
  import { RootState } from '~/store/store';
+ import { getUserUuid } from "~/common/getuser";
  import { dialogActions } from "~/store/dialog/dialog-actions";
  import { ServiceRepository } from '~/services/services';
  import { getCommonResourceServiceError, CommonResourceServiceError } from "~/services/common-service/common-resource-service";
@@@ -28,7 -29,8 +29,8 @@@ export const openCollectionCreateDialo
          const router = getState();
          const properties = getState().properties;
          if (isItemNotInProject(properties) || !isProjectOrRunProcessRoute(router)) {
-             const userUuid = getState().auth.user!.uuid;
+             const userUuid = getUserUuid(getState());
+             if (!userUuid) { return; }
              dispatch(initialize(COLLECTION_CREATE_FORM_NAME, { userUuid }));
          } else {
              dispatch(initialize(COLLECTION_CREATE_FORM_NAME, { ownerUuid }));
@@@ -51,7 -53,7 +53,7 @@@ export const createCollection = (data: 
              return newCollection;
          } catch (e) {
              const error = getCommonResourceServiceError(e);
 -            if (error === CommonResourceServiceError.UNIQUE_VIOLATION) {
 +            if (error === CommonResourceServiceError.UNIQUE_NAME_VIOLATION) {
                  dispatch(stopSubmit(COLLECTION_CREATE_FORM_NAME, { name: 'Collection with the same name already exists.' } as FormErrors));
              } else if (error === CommonResourceServiceError.NONE) {
                  dispatch(stopSubmit(COLLECTION_CREATE_FORM_NAME));
index 1796fcf81614687ee63c47f0eb187cc0ced48785,7f12b7cfeeb1fd7526267be2cc613689a82395b1..a303b5518dc7a5b43ceb28cc7028c89764dea4c7
@@@ -5,6 -5,7 +5,7 @@@
  import { Dispatch } from "redux";
  import { reset, startSubmit, stopSubmit, initialize, FormErrors, formValueSelector, change } from 'redux-form';
  import { RootState } from '~/store/store';
+ import { getUserUuid } from "~/common/getuser";
  import { dialogActions } from "~/store/dialog/dialog-actions";
  import { getCommonResourceServiceError, CommonResourceServiceError } from '~/services/common-service/common-resource-service';
  import { ProjectResource } from '~/models/project';
@@@ -38,7 -39,7 +39,7 @@@ export const isItemNotInProject = (prop
      if (properties.breadcrumbs) {
          return Boolean(properties.breadcrumbs[0].label !== 'Projects');
      } else {
-         return ;
+         return;
      }
  };
  
@@@ -47,7 -48,8 +48,8 @@@ export const openProjectCreateDialog = 
          const router = getState();
          const properties = getState().properties;
          if (isItemNotInProject(properties) || !isProjectOrRunProcessRoute(router)) {
-             const userUuid = getState().auth.user!.uuid;
+             const userUuid = getUserUuid(getState());
+             if (!userUuid) { return; }
              dispatch(initialize(PROJECT_CREATE_FORM_NAME, { userUuid }));
          } else {
              dispatch(initialize(PROJECT_CREATE_FORM_NAME, { ownerUuid }));
@@@ -65,7 -67,7 +67,7 @@@ export const createProject = (project: 
              return newProject;
          } catch (e) {
              const error = getCommonResourceServiceError(e);
 -            if (error === CommonResourceServiceError.UNIQUE_VIOLATION) {
 +            if (error === CommonResourceServiceError.UNIQUE_NAME_VIOLATION) {
                  dispatch(stopSubmit(PROJECT_CREATE_FORM_NAME, { name: 'Project with the same name already exists.' } as FormErrors));
              }
              return undefined;
@@@ -76,12 -78,12 +78,12 @@@ export const addPropertyToCreateProject
      (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
          const properties = { ...PROJECT_CREATE_FORM_SELECTOR(getState(), 'properties') };
          properties[data.key] = data.value;
-         dispatch(change(PROJECT_CREATE_FORM_NAME, 'properties', properties ));
+         dispatch(change(PROJECT_CREATE_FORM_NAME, 'properties', properties));
      };
  
  export const removePropertyFromCreateProjectForm = (key: string) =>
      (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
          const properties = { ...PROJECT_CREATE_FORM_SELECTOR(getState(), 'properties') };
          delete properties[key];
-         dispatch(change(PROJECT_CREATE_FORM_NAME, 'properties', properties ));
-     };
+         dispatch(change(PROJECT_CREATE_FORM_NAME, 'properties', properties));
+     };
index a018f3d39de691d985e802b1eb5395eacd7eb3db,d8eebb8194c05576a33e6eac6f37c4b6e7fed8e0..4dcaf2f514c914a17c6525fb88f2abb9fc9f1cd3
@@@ -7,6 -7,7 +7,7 @@@ import { dialogActions } from "~/store/
  import { startSubmit, stopSubmit, initialize, FormErrors } from 'redux-form';
  import { ServiceRepository } from '~/services/services';
  import { RootState } from '~/store/store';
+ import { getUserUuid } from "~/common/getuser";
  import { getCommonResourceServiceError, CommonResourceServiceError } from "~/services/common-service/common-resource-service";
  import { MoveToFormDialogData } from '~/store/move-to-dialog/move-to-dialog';
  import { resetPickerProjectTree } from '~/store/project-tree-picker/project-tree-picker-actions';
@@@ -26,7 -27,8 +27,8 @@@ export const openMoveProjectDialog = (r
  
  export const moveProject = (resource: MoveToFormDialogData) =>
      async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
-         const userUuid = getState().auth.user!.uuid;
+         const userUuid = getUserUuid(getState());
+         if (!userUuid) { return; }
          dispatch(startSubmit(PROJECT_MOVE_FORM_NAME));
          try {
              const newProject = await services.projectService.update(resource.uuid, { ownerUuid: resource.ownerUuid });
@@@ -36,7 -38,7 +38,7 @@@
              return newProject;
          } catch (e) {
              const error = getCommonResourceServiceError(e);
 -            if (error === CommonResourceServiceError.UNIQUE_VIOLATION) {
 +            if (error === CommonResourceServiceError.UNIQUE_NAME_VIOLATION) {
                  dispatch(stopSubmit(PROJECT_MOVE_FORM_NAME, { ownerUuid: 'A project with the same name already exists in the target project.' } as FormErrors));
              } else if (error === CommonResourceServiceError.OWNERSHIP_CYCLE) {
                  dispatch(stopSubmit(PROJECT_MOVE_FORM_NAME, { ownerUuid: 'Cannot move a project into itself.' } as FormErrors));
index f514d2b38ac4cea073c92bcfaeef78109fa6b04a,4f3317566a0d86dc85ec5dd7f18beec767dbc4f4..81e84ac52951542b2b5647e538a7ec637a5ac342
@@@ -4,6 -4,7 +4,7 @@@
  
  import { Dispatch } from 'redux';
  import { RootState } from "~/store/store";
+ import { getUserUuid } from "~/common/getuser"; 
  import { loadDetailsPanel } from '~/store/details-panel/details-panel-action';
  import { snackbarActions, SnackbarKind } from '~/store/snackbar/snackbar-actions';
  import { favoritePanelActions, loadFavoritePanel } from '~/store/favorite-panel/favorite-panel-action';
@@@ -177,7 -178,7 +178,7 @@@ export const loadTrash = () =
  export const loadProject = (uuid: string) =>
      handleFirstTimeLoad(
          async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
-             const userUuid = services.authService.getUuid();
+             const userUuid = getUserUuid(getState());
              dispatch(setIsProjectPanelTrashed(false));
              if (userUuid) {
                  if (extractUuidKind(uuid) === ResourceKind.USER && userUuid !== uuid) {
@@@ -260,7 -261,7 +261,7 @@@ export const updateProject = (data: pro
  export const loadCollection = (uuid: string) =>
      handleFirstTimeLoad(
          async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
-             const userUuid = services.authService.getUuid();
+             const userUuid = getUserUuid(getState());
              if (userUuid) {
                  const match = await loadGroupContentsResource({ uuid, userUuid, services });
                  match({
@@@ -306,19 -307,15 +307,19 @@@ export const createCollection = (data: 
  
  export const updateCollection = (data: collectionUpdateActions.CollectionUpdateFormDialogData) =>
      async (dispatch: Dispatch) => {
 -        const collection = await dispatch<any>(collectionUpdateActions.updateCollection(data));
 -        if (collection) {
 -            dispatch(snackbarActions.OPEN_SNACKBAR({
 -                message: "Collection has been successfully updated.",
 -                hideDuration: 2000,
 -                kind: SnackbarKind.SUCCESS
 -            }));
 -            dispatch<any>(updateResources([collection]));
 -            dispatch<any>(reloadProjectMatchingUuid([collection.ownerUuid]));
 +        try {
 +            const collection = await dispatch<any>(collectionUpdateActions.updateCollection(data));
 +            if (collection) {
 +                dispatch(snackbarActions.OPEN_SNACKBAR({
 +                    message: "Collection has been successfully updated.",
 +                    hideDuration: 2000,
 +                    kind: SnackbarKind.SUCCESS
 +                }));
 +                dispatch<any>(updateResources([collection]));
 +                dispatch<any>(reloadProjectMatchingUuid([collection.ownerUuid]));
 +            }
 +        } catch (e) {
 +            dispatch(snackbarActions.OPEN_SNACKBAR({ message: e.errors.join(''), hideDuration: 2000, kind: SnackbarKind.ERROR }));
          }
      };