mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-10-27 16:55:06 +00:00
* Fixed: [UI] Add support for renaming glossary #8733 * Addressing comments
This commit is contained in:
parent
e19cb77de1
commit
52a8e335a3
@ -250,6 +250,7 @@ const GlossaryV1 = ({
|
||||
updatedDetails = {
|
||||
...selectedData,
|
||||
displayName: displayName?.trim(),
|
||||
name: displayName?.trim() || selectedData.name,
|
||||
};
|
||||
|
||||
if (
|
||||
|
||||
@ -21,6 +21,7 @@ import {
|
||||
LoadingState,
|
||||
} from 'Models';
|
||||
import React, { useCallback, useEffect, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useHistory, useParams } from 'react-router-dom';
|
||||
import {
|
||||
deleteGlossary,
|
||||
@ -62,6 +63,7 @@ export type ModifiedGlossaryData = Glossary & {
|
||||
|
||||
const GlossaryPageV1 = () => {
|
||||
const { glossaryName } = useParams<Record<string, string>>();
|
||||
const { t } = useTranslation();
|
||||
|
||||
const history = useHistory();
|
||||
const [isLoading, setIsLoading] = useState<boolean>(true);
|
||||
@ -482,6 +484,28 @@ const GlossaryPageV1 = () => {
|
||||
return patchGlossaries(selectedData?.id as string, jsonPatch);
|
||||
};
|
||||
|
||||
/**
|
||||
* Handle the redirection to glossary page via FQN.
|
||||
* @param fqn for redirecting to glossary page
|
||||
*/
|
||||
const handleRedirection = (fqn?: string) => {
|
||||
// If no FQN provided it will redirect to previous parent of selected glossaryTerm.
|
||||
// mainly use for after delete effect
|
||||
const redirectFqn = fqn
|
||||
? fqn
|
||||
: selectedKey.split('.').slice(0, -1).join('.');
|
||||
|
||||
if (isEmpty(redirectFqn)) {
|
||||
setGlossariesList([]);
|
||||
setIsLoading(true);
|
||||
history.push(getGlossaryPath());
|
||||
fetchGlossaryList();
|
||||
} else {
|
||||
history.push(getGlossaryPath(redirectFqn));
|
||||
fetchGlossaryList(redirectFqn);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* To update glossary
|
||||
* @param updatedData glossary with new values
|
||||
@ -514,8 +538,13 @@ const GlossaryPageV1 = () => {
|
||||
}
|
||||
});
|
||||
});
|
||||
if (selectedData?.name !== updatedData.name) {
|
||||
handleRedirection(response.fullyQualifiedName);
|
||||
}
|
||||
} else {
|
||||
throw jsonData['api-error-messages']['update-description-error'];
|
||||
throw t('server.entity-updating-error', {
|
||||
entity: updateGlossary.name,
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
showErrorToast(error as AxiosError);
|
||||
@ -544,6 +573,9 @@ const GlossaryPageV1 = () => {
|
||||
const response = await saveUpdatedGlossaryTermData(updatedData);
|
||||
if (response) {
|
||||
setSelectedData(response);
|
||||
if (selectedData?.name !== updatedData.name) {
|
||||
handleRedirection(response.fullyQualifiedName);
|
||||
}
|
||||
} else {
|
||||
throw jsonData['api-error-messages']['update-glossary-term-error'];
|
||||
}
|
||||
@ -552,20 +584,6 @@ const GlossaryPageV1 = () => {
|
||||
}
|
||||
};
|
||||
|
||||
const afterDeleteAction = () => {
|
||||
const redirectFqn = selectedKey.split('.').slice(0, -1).join('.');
|
||||
|
||||
if (isEmpty(redirectFqn)) {
|
||||
setGlossariesList([]);
|
||||
setIsLoading(true);
|
||||
history.push(getGlossaryPath());
|
||||
fetchGlossaryList();
|
||||
} else {
|
||||
history.push(getGlossaryPath(redirectFqn));
|
||||
fetchGlossaryList(redirectFqn);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* To delete glossary by id
|
||||
* @param id glossary id
|
||||
@ -578,7 +596,7 @@ const GlossaryPageV1 = () => {
|
||||
showSuccessToast(
|
||||
jsonData['api-success-messages']['delete-glossary-success']
|
||||
);
|
||||
afterDeleteAction();
|
||||
handleRedirection();
|
||||
})
|
||||
.catch((err: AxiosError) => {
|
||||
showErrorToast(
|
||||
@ -601,7 +619,7 @@ const GlossaryPageV1 = () => {
|
||||
showSuccessToast(
|
||||
jsonData['api-success-messages']['delete-glossary-term-success']
|
||||
);
|
||||
afterDeleteAction();
|
||||
handleRedirection();
|
||||
})
|
||||
.catch((err: AxiosError) => {
|
||||
showErrorToast(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user