Skip to content

Commit

Permalink
refactor(ui/glossary): Clean up term deletion (datahub-project#10589)
Browse files Browse the repository at this point in the history
  • Loading branch information
asikowitz committed Jun 3, 2024
1 parent 9c166f0 commit 67c610d
Showing 1 changed file with 5 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,10 @@ function useDeleteEntity(
const { isInGlossaryContext, urnsToUpdate, setUrnsToUpdate } = useGlossaryEntityData();
const { handleDeleteDomain } = useHandleDeleteDomain({ entityData, urn });

const maybeDeleteEntity = getDeleteEntityMutation(type)();
const deleteEntity = (maybeDeleteEntity && maybeDeleteEntity[0]) || undefined;
const client = maybeDeleteEntity?.[1].client;
const [deleteEntity, { client }] = getDeleteEntityMutation(type)() ?? [undefined, { client: undefined }];

function handleDeleteEntity() {
deleteEntity?.({
variables: {
urn,
},
})
deleteEntity?.({ variables: { urn } })
.then(() => {
analytics.event({
type: EventType.DeleteEntityEvent,
Expand All @@ -56,17 +50,16 @@ function useDeleteEntity(
handleDeleteDomain();
}

if (client && entityData.type === EntityType.GlossaryTerm && entityData?.parentNodes?.nodes) {
removeTermFromGlossaryNode(client, entityData.parentNodes.nodes[0].urn, urn);
}

setTimeout(
() => {
setHasBeenDeleted(true);
onDelete?.();
if (isInGlossaryContext) {
const parentNodeToUpdate = getParentNodeToUpdate(entityData, type);
updateGlossarySidebar([parentNodeToUpdate], urnsToUpdate, setUrnsToUpdate);
if (client) {
removeTermFromGlossaryNode(client, parentNodeToUpdate, urn);
}
}
if (!hideMessage) {
message.success({
Expand Down

0 comments on commit 67c610d

Please sign in to comment.