Skip to content

Commit

Permalink
Correct display name for users in UI (datahub-project#4323)
Browse files Browse the repository at this point in the history
  • Loading branch information
jjoyce0510 authored Mar 5, 2022
1 parent 787a7e6 commit b48b215
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions datahub-web-react/src/app/entity/user/UserProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ import React from 'react';
import styled from 'styled-components';
import useUserParams from '../../shared/entitySearch/routingUtils/useUserParams';
import { useGetUserQuery } from '../../../graphql/user.generated';
import { EntityRelationshipsResult } from '../../../types.generated';
import { EntityRelationshipsResult, EntityType } from '../../../types.generated';
import UserGroups from './UserGroups';
import { RoutedTabs } from '../../shared/RoutedTabs';
import { UserAssets } from './UserAssets';
import { decodeUrn } from '../shared/utils';
import UserInfoSideBar from './UserInfoSideBar';
import { useEntityRegistry } from '../../useEntityRegistry';

export interface Props {
onTabChange: (selectedTab: string) => void;
Expand Down Expand Up @@ -55,6 +56,7 @@ export const EmptyValue = styled.div`
export default function UserProfile() {
const { urn: encodedUrn } = useUserParams();
const urn = decodeUrn(encodedUrn);
const entityRegistry = useEntityRegistry();

const { loading, error, data, refetch } = useGetUserQuery({ variables: { urn, groupsCount: GROUP_PAGE_SIZE } });

Expand Down Expand Up @@ -98,7 +100,10 @@ export default function UserProfile() {
data?.corpUser?.info?.displayName ||
data?.corpUser?.info?.fullName ||
data?.corpUser?.urn,
name: data?.corpUser?.editableProperties?.displayName || data?.corpUser?.info?.fullName || undefined,
name:
data?.corpUser?.editableProperties?.displayName ||
(data?.corpUser && entityRegistry.getDisplayName(EntityType.CorpUser, data?.corpUser)) ||
undefined,
role: data?.corpUser?.editableProperties?.title || data?.corpUser?.info?.title || undefined,
team: data?.corpUser?.editableProperties?.teams?.join(',') || undefined,
email: data?.corpUser?.editableProperties?.email || data?.corpUser?.info?.email || undefined,
Expand Down

0 comments on commit b48b215

Please sign in to comment.