From d33ab311e793300c35f464cfc4fb9f0d9576bae1 Mon Sep 17 00:00:00 2001 From: Olga Dimova <38855943+olgadimova@users.noreply.github.com> Date: Wed, 29 Nov 2023 16:24:39 +0300 Subject: [PATCH] fix(ui): refactor add and remove Related Terms tab message to showcase actual request result --- .../profile/AddRelatedTermsModal.tsx | 15 ++++++++------- .../profile/useRemoveRelatedTerms.tsx | 18 +++++++++--------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/datahub-web-react/src/app/entity/glossaryTerm/profile/AddRelatedTermsModal.tsx b/datahub-web-react/src/app/entity/glossaryTerm/profile/AddRelatedTermsModal.tsx index 5b303f75e2985..9c8e7624d1c74 100644 --- a/datahub-web-react/src/app/entity/glossaryTerm/profile/AddRelatedTermsModal.tsx +++ b/datahub-web-react/src/app/entity/glossaryTerm/profile/AddRelatedTermsModal.tsx @@ -34,6 +34,7 @@ function AddRelatedTermsModal(props: Props) { const [AddRelatedTerms] = useAddRelatedTermsMutation(); function addTerms() { + message.loading({ content: 'Adding...' }); AddRelatedTerms({ variables: { input: { @@ -43,19 +44,19 @@ function AddRelatedTermsModal(props: Props) { }, }, }) - .catch((e) => { - message.destroy(); - message.error({ content: `Failed to move: \n ${e.message || ''}`, duration: 3 }); - }) - .finally(() => { - message.loading({ content: 'Adding...', duration: 2 }); + .then(() => { setTimeout(() => { + refetch(); + message.destroy(); message.success({ content: 'Added Related Terms!', duration: 2, }); - refetch(); }, 2000); + }) + .catch((e) => { + message.destroy(); + message.error({ content: `Failed to move: \n ${e.message || ''}`, duration: 3 }); }); onClose(); } diff --git a/datahub-web-react/src/app/entity/glossaryTerm/profile/useRemoveRelatedTerms.tsx b/datahub-web-react/src/app/entity/glossaryTerm/profile/useRemoveRelatedTerms.tsx index 0eb46924243cd..aff9fa8dd79ec 100644 --- a/datahub-web-react/src/app/entity/glossaryTerm/profile/useRemoveRelatedTerms.tsx +++ b/datahub-web-react/src/app/entity/glossaryTerm/profile/useRemoveRelatedTerms.tsx @@ -12,6 +12,9 @@ function useRemoveRelatedTerms(termUrn: string, relationshipType: TermRelationsh const [removeRelatedTerms] = useRemoveRelatedTermsMutation(); function handleRemoveRelatedTerms() { + message.loading({ + content: 'Removing...', + }); removeRelatedTerms({ variables: { input: { @@ -21,22 +24,19 @@ function useRemoveRelatedTerms(termUrn: string, relationshipType: TermRelationsh }, }, }) - .catch((e) => { - message.destroy(); - message.error({ content: `Failed to remove: \n ${e.message || ''}`, duration: 3 }); - }) - .finally(() => { - message.loading({ - content: 'Removing...', - duration: 2, - }); + .then(() => { setTimeout(() => { refetch(); + message.destroy(); message.success({ content: `Removed Glossary Term!`, duration: 2, }); }, 2000); + }) + .catch((e) => { + message.destroy(); + message.error({ content: `Failed to remove: \n ${e.message || ''}`, duration: 3 }); }); }