From 052705621ef174796196216a7f8191949a65a981 Mon Sep 17 00:00:00 2001 From: Norman Zhang Date: Sat, 28 Oct 2023 19:51:21 +1100 Subject: [PATCH 1/3] Replace the user ID with user name in Glossary --- .../EntityVersionTimeLine.tsx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityVersionTimeLine/EntityVersionTimeLine.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityVersionTimeLine/EntityVersionTimeLine.tsx index f133798bfa44..368509d102ca 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityVersionTimeLine/EntityVersionTimeLine.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityVersionTimeLine/EntityVersionTimeLine.tsx @@ -19,6 +19,7 @@ import { useTranslation } from 'react-i18next'; import { EntityHistory } from '../../../generated/type/entityHistory'; import { getSummary, isMajorVersion } from '../../../utils/EntityVersionUtils'; import CloseIcon from '../../Modals/CloseIcon.component'; +import { getUserById } from "../../../rest/userAPI"; type Props = { versionList: EntityHistory; @@ -37,6 +38,17 @@ const EntityVersionTimeLine: React.FC = ({ const { t } = useTranslation(); const [versionType] = useState('all'); + const fetchUserName = async (id: string) => { + let nameData: string = " "; + try { + const userData = await getUserById(id, 'displayName'); + nameData = userData.displayName ?? "Unknown User"; + }catch (err) { + nameData = "Unknown User"; + } + return nameData; + } + const versions = useMemo(() => { let versionTypeList = []; const list = versionList.versions ?? []; @@ -78,6 +90,9 @@ const EntityVersionTimeLine: React.FC = ({ return versionTypeList.length ? ( versionTypeList.map((v, i) => { const currV = JSON.parse(v); + const userId: string = currV?.updatedBy; + const userName: string = " "; + {userId == 'admin'?userName='admin':userName=fetchUserName(userId)} const majorVersionChecks = () => { return ( isMajorVersion( From c0a70f7c826f4218f20972503bfc19fa0cfb07a5 Mon Sep 17 00:00:00 2001 From: Norman Zhang Date: Sat, 28 Oct 2023 21:09:58 +1100 Subject: [PATCH 2/3] Replace the user ID with user name in glossary version history tab --- .../EntityVersionTimeLine.tsx | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityVersionTimeLine/EntityVersionTimeLine.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityVersionTimeLine/EntityVersionTimeLine.tsx index 368509d102ca..07d4ec85bacd 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityVersionTimeLine/EntityVersionTimeLine.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityVersionTimeLine/EntityVersionTimeLine.tsx @@ -20,6 +20,8 @@ import { EntityHistory } from '../../../generated/type/entityHistory'; import { getSummary, isMajorVersion } from '../../../utils/EntityVersionUtils'; import CloseIcon from '../../Modals/CloseIcon.component'; import { getUserById } from "../../../rest/userAPI"; +import { AxiosError } from 'axios'; + type Props = { versionList: EntityHistory; @@ -37,17 +39,20 @@ const EntityVersionTimeLine: React.FC = ({ }: Props) => { const { t } = useTranslation(); const [versionType] = useState('all'); + const [uname, setUname] = useState()(' '); const fetchUserName = async (id: string) => { - let nameData: string = " "; try { const userData = await getUserById(id, 'displayName'); - nameData = userData.displayName ?? "Unknown User"; - }catch (err) { - nameData = "Unknown User"; + + if(userData){ + let nameData: string = userData.displayName ?? "Unknown User"; + setUname(nameData); + } + }catch (error: AxiosError) { + setUname(id); } - return nameData; - } + }; const versions = useMemo(() => { let versionTypeList = []; @@ -91,8 +96,8 @@ const EntityVersionTimeLine: React.FC = ({ versionTypeList.map((v, i) => { const currV = JSON.parse(v); const userId: string = currV?.updatedBy; - const userName: string = " "; - {userId == 'admin'?userName='admin':userName=fetchUserName(userId)} + fetchUserName(userId); + {userId == 'admin'?setUname('admin'):" "} const majorVersionChecks = () => { return ( isMajorVersion( @@ -157,7 +162,7 @@ const EntityVersionTimeLine: React.FC = ({ })}

- {currV?.updatedBy} + {uname} {' '} {t('label.updated-on')}{' '} From 5f8bed101840765b47fa1f23997fac388f3e80e0 Mon Sep 17 00:00:00 2001 From: Chirag Madlani <12962843+chirag-madlani@users.noreply.github.com> Date: Tue, 26 Dec 2023 12:14:00 +0530 Subject: [PATCH 3/3] fix tests --- .../EntityVersionTimeLine.tsx | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityVersionTimeLine/EntityVersionTimeLine.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityVersionTimeLine/EntityVersionTimeLine.tsx index 07d4ec85bacd..8157416dcbf5 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityVersionTimeLine/EntityVersionTimeLine.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityVersionTimeLine/EntityVersionTimeLine.tsx @@ -17,11 +17,10 @@ import { capitalize, isEmpty, toString } from 'lodash'; import React, { Fragment, useMemo, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { EntityHistory } from '../../../generated/type/entityHistory'; +import { getUserById } from '../../../rest/userAPI'; +import { getEntityName } from '../../../utils/EntityUtils'; import { getSummary, isMajorVersion } from '../../../utils/EntityVersionUtils'; import CloseIcon from '../../Modals/CloseIcon.component'; -import { getUserById } from "../../../rest/userAPI"; -import { AxiosError } from 'axios'; - type Props = { versionList: EntityHistory; @@ -39,19 +38,17 @@ const EntityVersionTimeLine: React.FC = ({ }: Props) => { const { t } = useTranslation(); const [versionType] = useState('all'); - const [uname, setUname] = useState()(' '); + const [uname, setUname] = useState(''); const fetchUserName = async (id: string) => { try { const userData = await getUserById(id, 'displayName'); - - if(userData){ - let nameData: string = userData.displayName ?? "Unknown User"; - setUname(nameData); - } - }catch (error: AxiosError) { + + const name: string = getEntityName(userData); + setUname(name); + } catch (err) { setUname(id); - } + } }; const versions = useMemo(() => { @@ -97,7 +94,9 @@ const EntityVersionTimeLine: React.FC = ({ const currV = JSON.parse(v); const userId: string = currV?.updatedBy; fetchUserName(userId); - {userId == 'admin'?setUname('admin'):" "} + { + userId === 'admin' ? setUname('admin') : ' '; + } const majorVersionChecks = () => { return ( isMajorVersion(