Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #13382: Replace the user ID with user name in Glossary Term #13753

Merged
merged 5 commits into from
Dec 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ 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';

Expand All @@ -36,6 +38,18 @@ const EntityVersionTimeLine: React.FC<Props> = ({
}: Props) => {
const { t } = useTranslation();
const [versionType] = useState<VersionType>('all');
const [uname, setUname] = useState<string>('');

const fetchUserName = async (id: string) => {
try {
const userData = await getUserById(id, 'displayName');

const name: string = getEntityName(userData);
setUname(name);
} catch (err) {
setUname(id);
}
};

const versions = useMemo(() => {
let versionTypeList = [];
Expand Down Expand Up @@ -78,6 +92,11 @@ const EntityVersionTimeLine: React.FC<Props> = ({
return versionTypeList.length ? (
versionTypeList.map((v, i) => {
const currV = JSON.parse(v);
const userId: string = currV?.updatedBy;
fetchUserName(userId);
{
userId === 'admin' ? setUname('admin') : ' ';
}
const majorVersionChecks = () => {
return (
isMajorVersion(
Expand Down Expand Up @@ -142,7 +161,7 @@ const EntityVersionTimeLine: React.FC<Props> = ({
})}
</div>
<p className="text-xs font-italic">
<span className="font-medium">{currV?.updatedBy}</span>
<span className="font-medium">{uname}</span>
<span className="text-grey-muted">
{' '}
{t('label.updated-on')}{' '}
Expand Down
Loading