mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-10-28 09:13:58 +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 = {
|
updatedDetails = {
|
||||||
...selectedData,
|
...selectedData,
|
||||||
displayName: displayName?.trim(),
|
displayName: displayName?.trim(),
|
||||||
|
name: displayName?.trim() || selectedData.name,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
|||||||
@ -21,6 +21,7 @@ import {
|
|||||||
LoadingState,
|
LoadingState,
|
||||||
} from 'Models';
|
} from 'Models';
|
||||||
import React, { useCallback, useEffect, useState } from 'react';
|
import React, { useCallback, useEffect, useState } from 'react';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
import { useHistory, useParams } from 'react-router-dom';
|
import { useHistory, useParams } from 'react-router-dom';
|
||||||
import {
|
import {
|
||||||
deleteGlossary,
|
deleteGlossary,
|
||||||
@ -62,6 +63,7 @@ export type ModifiedGlossaryData = Glossary & {
|
|||||||
|
|
||||||
const GlossaryPageV1 = () => {
|
const GlossaryPageV1 = () => {
|
||||||
const { glossaryName } = useParams<Record<string, string>>();
|
const { glossaryName } = useParams<Record<string, string>>();
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
const [isLoading, setIsLoading] = useState<boolean>(true);
|
const [isLoading, setIsLoading] = useState<boolean>(true);
|
||||||
@ -482,6 +484,28 @@ const GlossaryPageV1 = () => {
|
|||||||
return patchGlossaries(selectedData?.id as string, jsonPatch);
|
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
|
* To update glossary
|
||||||
* @param updatedData glossary with new values
|
* @param updatedData glossary with new values
|
||||||
@ -514,8 +538,13 @@ const GlossaryPageV1 = () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
if (selectedData?.name !== updatedData.name) {
|
||||||
|
handleRedirection(response.fullyQualifiedName);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
throw jsonData['api-error-messages']['update-description-error'];
|
throw t('server.entity-updating-error', {
|
||||||
|
entity: updateGlossary.name,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showErrorToast(error as AxiosError);
|
showErrorToast(error as AxiosError);
|
||||||
@ -544,6 +573,9 @@ const GlossaryPageV1 = () => {
|
|||||||
const response = await saveUpdatedGlossaryTermData(updatedData);
|
const response = await saveUpdatedGlossaryTermData(updatedData);
|
||||||
if (response) {
|
if (response) {
|
||||||
setSelectedData(response);
|
setSelectedData(response);
|
||||||
|
if (selectedData?.name !== updatedData.name) {
|
||||||
|
handleRedirection(response.fullyQualifiedName);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
throw jsonData['api-error-messages']['update-glossary-term-error'];
|
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
|
* To delete glossary by id
|
||||||
* @param id glossary id
|
* @param id glossary id
|
||||||
@ -578,7 +596,7 @@ const GlossaryPageV1 = () => {
|
|||||||
showSuccessToast(
|
showSuccessToast(
|
||||||
jsonData['api-success-messages']['delete-glossary-success']
|
jsonData['api-success-messages']['delete-glossary-success']
|
||||||
);
|
);
|
||||||
afterDeleteAction();
|
handleRedirection();
|
||||||
})
|
})
|
||||||
.catch((err: AxiosError) => {
|
.catch((err: AxiosError) => {
|
||||||
showErrorToast(
|
showErrorToast(
|
||||||
@ -601,7 +619,7 @@ const GlossaryPageV1 = () => {
|
|||||||
showSuccessToast(
|
showSuccessToast(
|
||||||
jsonData['api-success-messages']['delete-glossary-term-success']
|
jsonData['api-success-messages']['delete-glossary-term-success']
|
||||||
);
|
);
|
||||||
afterDeleteAction();
|
handleRedirection();
|
||||||
})
|
})
|
||||||
.catch((err: AxiosError) => {
|
.catch((err: AxiosError) => {
|
||||||
showErrorToast(
|
showErrorToast(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user