X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/02fe86a56f080ed1d5770ad6c6856a15f50ab508..f0a64666816383d2641d5fa7ea22019441ac4464:/src/store/projects/project-move-actions.ts diff --git a/src/store/projects/project-move-actions.ts b/src/store/projects/project-move-actions.ts index 441b8a6c..4dcaf2f5 100644 --- a/src/store/projects/project-move-actions.ts +++ b/src/store/projects/project-move-actions.ts @@ -7,6 +7,7 @@ import { dialogActions } from "~/store/dialog/dialog-actions"; 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 @@ export const openMoveProjectDialog = (resource: { name: string, uuid: string }) 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 @@ export const moveProject = (resource: MoveToFormDialogData) => 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));