15856: Enhances error constant naming.
authorLucas Di Pentima <ldipentima@veritasgenetics.com>
Mon, 2 Dec 2019 20:19:46 +0000 (17:19 -0300)
committerLucas Di Pentima <ldipentima@veritasgenetics.com>
Mon, 2 Dec 2019 20:19:46 +0000 (17:19 -0300)
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <ldipentima@veritasgenetics.com>

12 files changed:
src/services/common-service/common-resource-service.ts
src/store/collections/collection-copy-actions.ts
src/store/collections/collection-create-actions.ts
src/store/collections/collection-move-actions.ts
src/store/collections/collection-partial-copy-actions.ts
src/store/collections/collection-update-actions.ts
src/store/groups-panel/groups-panel-actions.ts
src/store/processes/process-move-actions.ts
src/store/processes/process-update-actions.ts
src/store/projects/project-create-actions.ts
src/store/projects/project-move-actions.ts
src/store/projects/project-update-actions.ts

index 17c287d22ebaf6fad2d60b774d0fc400f29af5b7..d29ea15642f47dd51153c4d9ceb6e1986617c4db 100644 (file)
@@ -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):
index 0ce92dfabcecbdc86a3c4cd087b97d4bcee2fddd..b13d08aaad236eb8eae6962a969fc1aaae79e326 100644 (file)
@@ -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
index 8d1e9ba5f247be426fc0b2faabb6d4ec60f858fb..a9534c6bb132c18a811a991285574a18ab9f88dc 100644 (file)
@@ -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));
index 0351e746b3c8a334d0f950a7cc280f7cec40d96b..6ccd0caaf8dba1afeaa6af58358cfd7a5dddb181 100644 (file)
@@ -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 }));
index 65561aa48a33e4bd6f28860332a08e81b9011b86..72374e65970aae31c50a36387d2788107ec30222 100644 (file)
@@ -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 }));
index c8641e9a08c9608c042e523dc6d895ebb46bf6fb..5b176beac5bd6d2c67bcbca2204e70b307e1c369 100644 (file)
@@ -41,7 +41,7 @@ export const updateCollection = (collection: Partial<CollectionResource>) =>
         } 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.
index af48b25b3878e838bd95002441ffcddb00e2f5df..cfd8438cbde246b45b79c89005b908770210f3e1 100644 (file)
@@ -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) => {
index 475b4c1fb80c393aa43f70321de579244463a051..5ad41fd5f7f42d9cde5ea4fd57330494c5d0970a 100644 (file)
@@ -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 }));
index f8d78bc60a0a94930afa8689bf059b85f055b92f..22008d1453c6ee4ba1ed4aa3ddecf2678128e65c 100644 (file)
@@ -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 }));
index ddcd233fd5ad8053dbe60819bdfdf63f364335bb..1796fcf81614687ee63c47f0eb187cc0ced48785 100644 (file)
@@ -65,7 +65,7 @@ export const createProject = (project: Partial<ProjectResource>) =>
             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;
index 441b8a6c7d3b587b4c7c019da67e87b011038456..a018f3d39de691d985e802b1eb5395eacd7eb3db 100644 (file)
@@ -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));
index b92069762a0e300e62044f0f289510fae68911ae..2449b9ce9bf1a049eeb7790cfe1fc84ee2ef6b3b 100644 (file)
@@ -39,7 +39,7 @@ export const updateProject = (project: Partial<ProjectResource>) =>
             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 ;