From ee68b6a5e88e383dbc2126124eef0f8c6ba37d2d Mon Sep 17 00:00:00 2001 From: Lucas Di Pentima Date: Mon, 2 Dec 2019 17:19:46 -0300 Subject: [PATCH] 15856: Enhances error constant naming. Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima --- src/services/common-service/common-resource-service.ts | 4 ++-- src/store/collections/collection-copy-actions.ts | 2 +- src/store/collections/collection-create-actions.ts | 2 +- src/store/collections/collection-move-actions.ts | 2 +- src/store/collections/collection-partial-copy-actions.ts | 2 +- src/store/collections/collection-update-actions.ts | 2 +- src/store/groups-panel/groups-panel-actions.ts | 6 +++--- src/store/processes/process-move-actions.ts | 2 +- src/store/processes/process-update-actions.ts | 2 +- src/store/projects/project-create-actions.ts | 2 +- src/store/projects/project-move-actions.ts | 2 +- src/store/projects/project-update-actions.ts | 2 +- 12 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/services/common-service/common-resource-service.ts b/src/services/common-service/common-resource-service.ts index 17c287d2..d29ea156 100644 --- a/src/services/common-service/common-resource-service.ts +++ b/src/services/common-service/common-resource-service.ts @@ -8,7 +8,7 @@ import { ApiActions } from "~/services/api/api-actions"; import { CommonService } from "~/services/common-service/common-service"; export enum CommonResourceServiceError { - UNIQUE_VIOLATION = 'UniqueViolation', + UNIQUE_NAME_VIOLATION = 'UniqueNameViolation', OWNERSHIP_CYCLE = 'OwnershipCycle', MODIFYING_CONTAINER_REQUEST_FINAL_STATE = 'ModifyingContainerRequestFinalState', NAME_HAS_ALREADY_BEEN_TAKEN = 'NameHasAlreadyBeenTaken', @@ -27,7 +27,7 @@ export const getCommonResourceServiceError = (errorResponse: any) => { const error = errorResponse.errors.join(''); switch (true) { case /UniqueViolation/.test(error): - return CommonResourceServiceError.UNIQUE_VIOLATION; + return CommonResourceServiceError.UNIQUE_NAME_VIOLATION; case /ownership cycle/.test(error): return CommonResourceServiceError.OWNERSHIP_CYCLE; case /Mounts cannot be modified in state 'Final'/.test(error): diff --git a/src/store/collections/collection-copy-actions.ts b/src/store/collections/collection-copy-actions.ts index 0ce92dfa..b13d08aa 100644 --- a/src/store/collections/collection-copy-actions.ts +++ b/src/store/collections/collection-copy-actions.ts @@ -38,7 +38,7 @@ export const copyCollection = (resource: CopyFormDialogData) => return newCollection; } catch (e) { const error = getCommonResourceServiceError(e); - if (error === CommonResourceServiceError.UNIQUE_VIOLATION) { + if (error === CommonResourceServiceError.UNIQUE_NAME_VIOLATION) { dispatch(stopSubmit( COLLECTION_COPY_FORM_NAME, { ownerUuid: 'A collection with the same name already exists in the target project.' } as FormErrors diff --git a/src/store/collections/collection-create-actions.ts b/src/store/collections/collection-create-actions.ts index 8d1e9ba5..a9534c6b 100644 --- a/src/store/collections/collection-create-actions.ts +++ b/src/store/collections/collection-create-actions.ts @@ -51,7 +51,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)); diff --git a/src/store/collections/collection-move-actions.ts b/src/store/collections/collection-move-actions.ts index 0351e746..6ccd0caa 100644 --- a/src/store/collections/collection-move-actions.ts +++ b/src/store/collections/collection-move-actions.ts @@ -38,7 +38,7 @@ export const moveCollection = (resource: MoveToFormDialogData) => return collection; } catch (e) { const error = getCommonResourceServiceError(e); - if (error === CommonResourceServiceError.UNIQUE_VIOLATION) { + if (error === CommonResourceServiceError.UNIQUE_NAME_VIOLATION) { dispatch(stopSubmit(COLLECTION_MOVE_FORM_NAME, { ownerUuid: 'A collection with the same name already exists in the target project.' } as FormErrors)); } else { dispatch(dialogActions.CLOSE_DIALOG({ id: COLLECTION_MOVE_FORM_NAME })); diff --git a/src/store/collections/collection-partial-copy-actions.ts b/src/store/collections/collection-partial-copy-actions.ts index 65561aa4..72374e65 100644 --- a/src/store/collections/collection-partial-copy-actions.ts +++ b/src/store/collections/collection-partial-copy-actions.ts @@ -72,7 +72,7 @@ export const copyCollectionPartial = ({ name, description, projectUuid }: Collec dispatch(progressIndicatorActions.STOP_WORKING(COLLECTION_PARTIAL_COPY_FORM_NAME)); } catch (e) { const error = getCommonResourceServiceError(e); - if (error === CommonResourceServiceError.UNIQUE_VIOLATION) { + if (error === CommonResourceServiceError.UNIQUE_NAME_VIOLATION) { dispatch(stopSubmit(COLLECTION_PARTIAL_COPY_FORM_NAME, { name: 'Collection with this name already exists.' } as FormErrors)); } else if (error === CommonResourceServiceError.UNKNOWN) { dispatch(dialogActions.CLOSE_DIALOG({ id: COLLECTION_PARTIAL_COPY_FORM_NAME })); diff --git a/src/store/collections/collection-update-actions.ts b/src/store/collections/collection-update-actions.ts index c8641e9a..5b176bea 100644 --- a/src/store/collections/collection-update-actions.ts +++ b/src/store/collections/collection-update-actions.ts @@ -41,7 +41,7 @@ export const updateCollection = (collection: Partial) => } catch (e) { dispatch(progressIndicatorActions.STOP_WORKING(COLLECTION_UPDATE_FORM_NAME)); const error = getCommonResourceServiceError(e); - if (error === CommonResourceServiceError.UNIQUE_VIOLATION) { + if (error === CommonResourceServiceError.UNIQUE_NAME_VIOLATION) { dispatch(stopSubmit(COLLECTION_UPDATE_FORM_NAME, { name: 'Collection with the same name already exists.' } as FormErrors)); } else { // Unknown error, handling left to caller. diff --git a/src/store/groups-panel/groups-panel-actions.ts b/src/store/groups-panel/groups-panel-actions.ts index af48b25b..cfd8438c 100644 --- a/src/store/groups-panel/groups-panel-actions.ts +++ b/src/store/groups-panel/groups-panel-actions.ts @@ -101,7 +101,7 @@ export const createGroup = ({ name, users = [] }: CreateGroupFormData) => } catch (e) { const error = getCommonResourceServiceError(e); - if (error === CommonResourceServiceError.UNIQUE_VIOLATION) { + if (error === CommonResourceServiceError.UNIQUE_NAME_VIOLATION) { dispatch(stopSubmit(CREATE_GROUP_FORM, { name: 'Group with the same name already exists.' } as FormErrors)); } @@ -118,9 +118,9 @@ interface AddGroupMemberArgs { } /** - * Group membership is determined by whether the group has can_read permission on an object. + * Group membership is determined by whether the group has can_read permission on an object. * If a group G can_read an object A, then we say A is a member of G. - * + * * [Permission model docs](https://doc.arvados.org/api/permission-model.html) */ export const addGroupMember = async ({ user, group, ...args }: AddGroupMemberArgs) => { diff --git a/src/store/processes/process-move-actions.ts b/src/store/processes/process-move-actions.ts index 475b4c1f..5ad41fd5 100644 --- a/src/store/processes/process-move-actions.ts +++ b/src/store/processes/process-move-actions.ts @@ -41,7 +41,7 @@ export const moveProcess = (resource: MoveToFormDialogData) => return process; } catch (e) { const error = getCommonResourceServiceError(e); - if (error === CommonResourceServiceError.UNIQUE_VIOLATION) { + if (error === CommonResourceServiceError.UNIQUE_NAME_VIOLATION) { dispatch(stopSubmit(PROCESS_MOVE_FORM_NAME, { ownerUuid: 'A process with the same name already exists in the target project.' } as FormErrors)); } else { dispatch(dialogActions.CLOSE_DIALOG({ id: PROCESS_MOVE_FORM_NAME })); diff --git a/src/store/processes/process-update-actions.ts b/src/store/processes/process-update-actions.ts index f8d78bc6..22008d14 100644 --- a/src/store/processes/process-update-actions.ts +++ b/src/store/processes/process-update-actions.ts @@ -41,7 +41,7 @@ export const updateProcess = (resource: ProcessUpdateFormDialogData) => return updatedProcess; } catch (e) { const error = getCommonResourceServiceError(e); - if (error === CommonResourceServiceError.UNIQUE_VIOLATION) { + if (error === CommonResourceServiceError.UNIQUE_NAME_VIOLATION) { dispatch(stopSubmit(PROCESS_UPDATE_FORM_NAME, { name: 'Process with the same name already exists.' } as FormErrors)); } else { dispatch(dialogActions.CLOSE_DIALOG({ id: PROCESS_UPDATE_FORM_NAME })); diff --git a/src/store/projects/project-create-actions.ts b/src/store/projects/project-create-actions.ts index ddcd233f..1796fcf8 100644 --- a/src/store/projects/project-create-actions.ts +++ b/src/store/projects/project-create-actions.ts @@ -65,7 +65,7 @@ export const createProject = (project: Partial) => 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; diff --git a/src/store/projects/project-move-actions.ts b/src/store/projects/project-move-actions.ts index 441b8a6c..a018f3d3 100644 --- a/src/store/projects/project-move-actions.ts +++ b/src/store/projects/project-move-actions.ts @@ -36,7 +36,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)); diff --git a/src/store/projects/project-update-actions.ts b/src/store/projects/project-update-actions.ts index b9206976..2449b9ce 100644 --- a/src/store/projects/project-update-actions.ts +++ b/src/store/projects/project-update-actions.ts @@ -39,7 +39,7 @@ export const updateProject = (project: Partial) => return updatedProject; } catch (e) { const error = getCommonResourceServiceError(e); - if (error === CommonResourceServiceError.UNIQUE_VIOLATION) { + if (error === CommonResourceServiceError.UNIQUE_NAME_VIOLATION) { dispatch(stopSubmit(PROJECT_UPDATE_FORM_NAME, { name: 'Project with the same name already exists.' } as FormErrors)); } return ; -- 2.30.2