mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-10-30 01:59:23 +00:00
ui: fixed re-render issue in glossary term page (#14051)
This commit is contained in:
parent
dc1d465b7e
commit
06d9ca3f49
@ -18,6 +18,7 @@ import { Glossary } from '../../../../generated/entity/data/glossary';
|
|||||||
import { GlossaryTerm } from '../../../../generated/entity/data/glossaryTerm';
|
import { GlossaryTerm } from '../../../../generated/entity/data/glossaryTerm';
|
||||||
import { ChangeDescription } from '../../../../generated/entity/type';
|
import { ChangeDescription } from '../../../../generated/entity/type';
|
||||||
import { TagLabel } from '../../../../generated/type/tagLabel';
|
import { TagLabel } from '../../../../generated/type/tagLabel';
|
||||||
|
import { getEntityName } from '../../../../utils/EntityUtils';
|
||||||
import {
|
import {
|
||||||
getEntityVersionByField,
|
getEntityVersionByField,
|
||||||
getEntityVersionTags,
|
getEntityVersionTags,
|
||||||
@ -109,7 +110,7 @@ const GlossaryOverviewTab = ({
|
|||||||
<Col span={24}>
|
<Col span={24}>
|
||||||
<DescriptionV1
|
<DescriptionV1
|
||||||
description={glossaryDescription}
|
description={glossaryDescription}
|
||||||
entityName={selectedData?.displayName ?? selectedData?.name}
|
entityName={getEntityName(selectedData)}
|
||||||
entityType={EntityType.GLOSSARY}
|
entityType={EntityType.GLOSSARY}
|
||||||
hasEditAccess={permissions.EditDescription || permissions.EditAll}
|
hasEditAccess={permissions.EditDescription || permissions.EditAll}
|
||||||
isEdit={isDescriptionEditable}
|
isEdit={isDescriptionEditable}
|
||||||
|
|||||||
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
import { AxiosError } from 'axios';
|
import { AxiosError } from 'axios';
|
||||||
import { compare } from 'fast-json-patch';
|
import { compare } from 'fast-json-patch';
|
||||||
import React, { useEffect, useMemo, useState } from 'react';
|
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { useHistory, useParams } from 'react-router-dom';
|
import { useHistory, useParams } from 'react-router-dom';
|
||||||
import ErrorPlaceHolder from '../../../components/common/ErrorWithPlaceholder/ErrorPlaceHolder';
|
import ErrorPlaceHolder from '../../../components/common/ErrorWithPlaceholder/ErrorPlaceHolder';
|
||||||
@ -248,28 +248,31 @@ const GlossaryPage = () => {
|
|||||||
.finally(() => setDeleteStatus(LOADING_STATE.INITIAL));
|
.finally(() => setDeleteStatus(LOADING_STATE.INITIAL));
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleGlossaryTermUpdate = async (updatedData: GlossaryTerm) => {
|
const handleGlossaryTermUpdate = useCallback(
|
||||||
const jsonPatch = compare(selectedData as GlossaryTerm, updatedData);
|
async (updatedData: GlossaryTerm) => {
|
||||||
try {
|
const jsonPatch = compare(selectedData as GlossaryTerm, updatedData);
|
||||||
const response = await patchGlossaryTerm(
|
try {
|
||||||
selectedData?.id as string,
|
const response = await patchGlossaryTerm(
|
||||||
jsonPatch
|
selectedData?.id as string,
|
||||||
);
|
jsonPatch
|
||||||
if (response) {
|
);
|
||||||
setSelectedData(response);
|
if (response) {
|
||||||
if (selectedData?.name !== updatedData.name) {
|
setSelectedData(response);
|
||||||
history.push(getGlossaryPath(response.fullyQualifiedName));
|
if (selectedData?.name !== updatedData.name) {
|
||||||
fetchGlossaryList();
|
history.push(getGlossaryPath(response.fullyQualifiedName));
|
||||||
|
fetchGlossaryList();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw t('server.entity-updating-error', {
|
||||||
|
entity: t('label.glossary-term'),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} catch (error) {
|
||||||
throw t('server.entity-updating-error', {
|
showErrorToast(error as AxiosError);
|
||||||
entity: t('label.glossary-term'),
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
},
|
||||||
showErrorToast(error as AxiosError);
|
[selectedData]
|
||||||
}
|
);
|
||||||
};
|
|
||||||
|
|
||||||
const handleGlossaryTermDelete = (id: string) => {
|
const handleGlossaryTermDelete = (id: string) => {
|
||||||
setDeleteStatus(LOADING_STATE.WAITING);
|
setDeleteStatus(LOADING_STATE.WAITING);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user