[ARVADOS-WORKBENCH2] created: 1.4.1-366-g61e9b818

Git user git at public.arvados.org
Tue Jun 23 18:35:55 UTC 2020


        at  61e9b81814696ee7cb9b0245e292a7e5dc691667 (commit)


commit 61e9b81814696ee7cb9b0245e292a7e5dc691667
Author: Lucas Di Pentima <lucas at di-pentima.com.ar>
Date:   Tue May 26 10:28:14 2020 -0300

    16472: Adds parameter to commonService.get to avoid showing errors.
    
    Sometimes errors will be handled and a service layer UI error indication isn't
    needed. Confuses users, and also could affect testing.
    
    Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas at di-pentima.com.ar>
    
    16472: Fixes param passing avoiding key mapping to camelCase.
    
    Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas at di-pentima.com.ar>

diff --git a/src/index.tsx b/src/index.tsx
index 2cee0540..1a58dad1 100644
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -103,15 +103,17 @@ fetchConfig()
             progressFn: (id, working) => {
                 store.dispatch(progressIndicatorActions.TOGGLE_WORKING({ id, working }));
             },
-            errorFn: (id, error) => {
-                console.error("Backend error:", error);
-                store.dispatch(snackbarActions.OPEN_SNACKBAR({
-                    message: `${error.errors
-                        ? error.errors[0]
-                        : error.message}`,
-                    kind: SnackbarKind.ERROR,
-                    hideDuration: 8000})
-                );
+            errorFn: (id, error, showSnackBar) => {
+                if (showSnackBar) {
+                    console.error("Backend error:", error);
+                    store.dispatch(snackbarActions.OPEN_SNACKBAR({
+                        message: `${error.errors
+                            ? error.errors[0]
+                            : error.message}`,
+                        kind: SnackbarKind.ERROR,
+                        hideDuration: 8000})
+                    );
+                }
             }
         });
         const store = configureStore(history, services);
diff --git a/src/services/ancestors-service/ancestors-service.ts b/src/services/ancestors-service/ancestors-service.ts
index 23e7729f..8f5b9032 100644
--- a/src/services/ancestors-service/ancestors-service.ts
+++ b/src/services/ancestors-service/ancestors-service.ts
@@ -27,7 +27,7 @@ export class AncestorService {
         const service = this.getService(extractUuidObjectType(startUuid));
         if (service) {
             try {
-                const resource = await service.get(startUuid);
+                const resource = await service.get(startUuid, false);
                 if (startUuid === endUuid) {
                     return [resource];
                 } else {
@@ -39,9 +39,8 @@ export class AncestorService {
             } catch (e) {
                 return [];
             }
-        } else {
-            return [];
         }
+        return [];
     }
 
     private getService = (objectType?: string) => {
diff --git a/src/services/api/api-actions.ts b/src/services/api/api-actions.ts
index f986786d..00b18229 100644
--- a/src/services/api/api-actions.ts
+++ b/src/services/api/api-actions.ts
@@ -3,7 +3,7 @@
 // SPDX-License-Identifier: AGPL-3.0
 
 export type ProgressFn = (id: string, working: boolean) => void;
-export type ErrorFn = (id: string, error: any) => void;
+export type ErrorFn = (id: string, error: any, showSnackBar?: boolean) => void;
 
 export interface ApiActions {
     progressFn: ProgressFn;
diff --git a/src/services/common-service/common-service.ts b/src/services/common-service/common-service.ts
index 44233eb1..e00a3d7d 100644
--- a/src/services/common-service/common-service.ts
+++ b/src/services/common-service/common-service.ts
@@ -66,7 +66,7 @@ export class CommonService<T> {
             }
         }
 
-    static defaultResponse<R>(promise: AxiosPromise<R>, actions: ApiActions, mapKeys = true): Promise<R> {
+    static defaultResponse<R>(promise: AxiosPromise<R>, actions: ApiActions, mapKeys = true, showErrors = true): Promise<R> {
         const reqId = uuid();
         actions.progressFn(reqId, true);
         return promise
@@ -80,7 +80,7 @@ export class CommonService<T> {
             .catch(({ response }) => {
                 actions.progressFn(reqId, false);
                 const errors = CommonService.mapResponseKeys(response) as Errors;
-                actions.errorFn(reqId, errors);
+                actions.errorFn(reqId, errors, showErrors);
                 throw errors;
             });
     }
@@ -101,11 +101,13 @@ export class CommonService<T> {
         );
     }
 
-    get(uuid: string) {
+    get(uuid: string, showErrors?: boolean) {
         return CommonService.defaultResponse(
             this.serverApi
                 .get<T>(this.resourceType + '/' + uuid),
-            this.actions
+            this.actions,
+            true, // mapKeys
+            showErrors
         );
     }
 

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list