[ARVADOS-WORKBENCH2] created: 1.4.1-344-gf80e70ea

Git user git at public.arvados.org
Tue May 26 13:44:25 UTC 2020


        at  f80e70eac27c648c35145af0394dadef939f8b64 (commit)


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

    16118: Adds parameter to commonService.get to avoid showing errors. (WIP)
    
    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>

diff --git a/src/index.tsx b/src/index.tsx
index a12dabfa..e843ce37 100644
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -102,15 +102,18 @@ 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) => {
+                console.error("Backend error:", error, showSnackBar);
+                // console.trace();
+                if (showSnackBar) {
+                    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..41de915e 100644
--- a/src/services/ancestors-service/ancestors-service.ts
+++ b/src/services/ancestors-service/ancestors-service.ts
@@ -27,7 +27,8 @@ export class AncestorService {
         const service = this.getService(extractUuidObjectType(startUuid));
         if (service) {
             try {
-                const resource = await service.get(startUuid);
+                console.log('Calling commoService GET with showErrors: FALSE');
+                const resource = await service.get(startUuid, false);
                 if (startUuid === endUuid) {
                     return [resource];
                 } else {
@@ -39,9 +40,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..d7920814 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,16 @@ export class CommonService<T> {
         );
     }
 
-    get(uuid: string) {
+    get(uuid: string, showErrors?: boolean) {
+        console.log('Calling CommonService GET with showErrors: ', showErrors);
+        if (showErrors === undefined) {
+            console.trace();
+        }
         return CommonService.defaultResponse(
             this.serverApi
                 .get<T>(this.resourceType + '/' + uuid),
-            this.actions
+            this.actions,
+            showErrors
         );
     }
 

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list