X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/519b431a41a9ab4815a1e4180ee78395b74a85de..4cad4c0d882111b0eb5576005108a62ff30b143d:/src/store/collections/collection-create-actions.ts diff --git a/src/store/collections/collection-create-actions.ts b/src/store/collections/collection-create-actions.ts index 8d1e9ba5..e077b2a5 100644 --- a/src/store/collections/collection-create-actions.ts +++ b/src/store/collections/collection-create-actions.ts @@ -5,6 +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 @@ export const openCollectionCreateDialog = (ownerUuid: string) => 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 @@ export const createCollection = (data: CollectionCreateFormDialogData) => 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));