18559: User breadcrumbs fallback to uuid
authorStephen Smith <stephen@curii.com>
Tue, 29 Mar 2022 12:57:43 +0000 (08:57 -0400)
committerStephen Smith <stephen@curii.com>
Tue, 29 Mar 2022 12:57:43 +0000 (08:57 -0400)
Arvados-DCO-1.1-Signed-off-by: Stephen Smith <stephen@curii.com>

src/store/breadcrumbs/breadcrumbs-actions.ts

index 69179272471ea0395d2a677b4d989aa5e60c4ecc..08e1a132fd12e23f722cb2bc4e88f6c0374caab0 100644 (file)
@@ -137,16 +137,21 @@ export const setUsersBreadcrumbs = () =>
 
 export const setUserProfileBreadcrumbs = (userUuid: string) =>
     async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
-
-        const user = getResource<UserResource>(userUuid)(getState().resources);
-
-        const breadcrumbs: ResourceBreadcrumb[] = [
-            { label: USERS_PANEL_LABEL, uuid: USERS_PANEL_LABEL },
-            { label: user ? user.username : (await services.userService.get(userUuid)).username, uuid: userUuid },
-        ];
-
-        dispatch(setBreadcrumbs(breadcrumbs));
-
+        try {
+            const user = getResource<UserResource>(userUuid)(getState().resources)
+                        || await services.userService.get(userUuid, false);
+            const breadcrumbs: ResourceBreadcrumb[] = [
+                { label: USERS_PANEL_LABEL, uuid: USERS_PANEL_LABEL },
+                { label: user ? user.username : userUuid, uuid: userUuid },
+            ];
+            dispatch(setBreadcrumbs(breadcrumbs));
+        } catch (e) {
+            const breadcrumbs: ResourceBreadcrumb[] = [
+                { label: USERS_PANEL_LABEL, uuid: USERS_PANEL_LABEL },
+                { label: userUuid, uuid: userUuid },
+            ];
+            dispatch(setBreadcrumbs(breadcrumbs));
+        }
     };
 
 export const MY_ACCOUNT_PANEL_LABEL = 'My Account';