Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ui) - Add a custom error message for bulk edit to add clarity #6775

Merged
merged 6 commits into from
Dec 28, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,18 @@ export const UpdateDeprecationModal = ({ urns, onClose, refetch }: Props) => {
} catch (e: unknown) {
message.destroy();
if (e instanceof Error) {
message.error({ content: `Failed to update Deprecation: \n ${e.message || ''}`, duration: 2 });
if (
urns.length > 1 &&
e.message === 'Unauthorized to perform this action. Please contact your DataHub administrator.'
) {
message.error({
content:
'Your bulk edit selection included datasets that you do not own. The bulk edit being performed will not be saved.',
duration: 3,
});
} else {
message.error({ content: `Failed to update Deprecation: \n ${e.message || ''}`, duration: 2 });
}
}
}
refetch?.();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,18 @@ export default function DeleteDropdown({ urns, disabled = false, refetch }: Prop
})
.catch((e) => {
message.destroy();
message.error({ content: `Failed to delete assets: \n ${e.message || ''}`, duration: 3 });
if (
urns.length > 1 &&
e.message === 'Unauthorized to perform this action. Please contact your DataHub administrator.'
) {
message.error({
content:
'Your bulk edit selection included datasets that you do not own. The bulk edit being performed will not be saved.',
duration: 3,
});
} else {
message.error({ content: `Failed to delete assets: \n ${e.message || ''}`, duration: 3 });
}
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,21 @@ export default function DeprecationDropdown({ urns, disabled = false, refetch }:
})
.catch((e) => {
message.destroy();
message.error({
content: `Failed to mark assets as un-deprecated: \n ${e.message || ''}`,
duration: 3,
});
if (
urns.length > 1 &&
e.message === 'Unauthorized to perform this action. Please contact your DataHub administrator.'
) {
message.error({
content:
'Your bulk edit selection included datasets that you do not own. The bulk edit being performed will not be saved.',
duration: 3,
});
} else {
message.error({
content: `Failed to mark assets as un-deprecated: \n ${e.message || ''}`,
duration: 3,
});
}
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,21 @@ export default function DomainsDropdown({ urns, disabled = false, refetch }: Pro
})
.catch((e) => {
message.destroy();
message.error({ content: `Failed to remove assets from Domain: \n ${e.message || ''}`, duration: 3 });
if (
urns.length > 1 &&
e.message === 'Unauthorized to perform this action. Please contact your DataHub administrator.'
) {
message.error({
content:
'Your bulk edit selection included entities that you do not own. The bulk edit being performed will not be saved.',
duration: 3,
});
} else {
message.error({
content: `Failed to remove assets from Domain: \n ${e.message || ''}`,
duration: 3,
});
}
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,18 @@ export const SetDomainModal = ({ urns, onCloseModal, refetch, defaultValue, onOk
})
.catch((e) => {
message.destroy();
message.error({ content: `Failed to add assets to Domain: \n ${e.message || ''}`, duration: 3 });
if (
urns.length > 1 &&
e.message === 'Unauthorized to perform this action. Please contact your DataHub administrator.'
) {
message.error({
content:
'Your bulk edit selection included datasets that you do not own. The bulk edit being performed will not be saved.',
duration: 3,
});
} else {
message.error({ content: `Failed to add assets to Domain: \n ${e.message || ''}`, duration: 3 });
}
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,18 @@ export const EditOwnersModal = ({
} catch (e: unknown) {
message.destroy();
if (e instanceof Error) {
message.error({ content: `Failed to add owners: \n ${e.message || ''}`, duration: 3 });
if (
urns.length > 1 &&
e.message === 'Unauthorized to perform this action. Please contact your DataHub administrator.'
) {
message.error({
content:
'Your bulk edit selection included datasets that you do not own. The bulk edit being performed will not be saved.',
duration: 3,
});
} else {
message.error({ content: `Failed to add owners: \n ${e.message || ''}`, duration: 3 });
}
}
} finally {
refetch?.();
Expand All @@ -267,7 +278,18 @@ export const EditOwnersModal = ({
} catch (e: unknown) {
message.destroy();
if (e instanceof Error) {
message.error({ content: `Failed to remove owners: \n ${e.message || ''}`, duration: 3 });
if (
urns.length > 1 &&
e.message === 'Unauthorized to perform this action. Please contact your DataHub administrator.'
) {
message.error({
content:
'Your bulk edit selection included datasets that you do not own. The bulk edit being performed will not be saved.',
duration: 3,
});
} else {
message.error({ content: `Failed to remove owners: \n ${e.message || ''}`, duration: 3 });
}
}
} finally {
refetch?.();
Expand Down
26 changes: 24 additions & 2 deletions datahub-web-react/src/app/entity/shared/entity/EntityActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,18 @@ function EntityActions(props: Props) {
})
.catch((e) => {
message.destroy();
message.error({ content: `Failed to add glossary term: \n ${e.message || ''}`, duration: 3 });
if (
entityUrns.length > 0 &&
e.message === 'Unauthorized to perform this action. Please contact your DataHub administrator.'
) {
message.error({
content:
'Your bulk edit selection included datasets that you do not own. The bulk edit being performed will not be saved.',
duration: 3,
});
} else {
message.error({ content: `Failed to add glossary term: \n ${e.message || ''}`, duration: 3 });
}
});
};

Expand Down Expand Up @@ -90,7 +101,18 @@ function EntityActions(props: Props) {
})
.catch((e) => {
message.destroy();
message.error({ content: `Failed to add assets to Domain: \n ${e.message || ''}`, duration: 3 });
if (
entityUrns.length > 0 &&
e.message === 'Unauthorized to perform this action. Please contact your DataHub administrator.'
) {
message.error({
content:
'Your bulk edit selection included datasets that you do not own. The bulk edit being performed will not be saved.',
duration: 3,
});
} else {
message.error({ content: `Failed to add assets to Domain: \n ${e.message || ''}`, duration: 3 });
}
});
};

Expand Down
52 changes: 48 additions & 4 deletions datahub-web-react/src/app/shared/tags/AddTagsTermsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,18 @@ export default function EditTagTermsModal({
})
.catch((e) => {
message.destroy();
message.error({ content: `Failed to add: \n ${e.message || ''}`, duration: 3 });
if (
resources.length > 1 &&
e.message === 'Unauthorized to perform this action. Please contact your DataHub administrator.'
) {
message.error({
content:
'Your bulk edit selection included datasets that you do not own. The bulk edit being performed will not be saved.',
duration: 3,
});
} else {
message.error({ content: `Failed to add: \n ${e.message || ''}`, duration: 3 });
}
})
.finally(() => {
setDisableAction(false);
Expand Down Expand Up @@ -295,7 +306,18 @@ export default function EditTagTermsModal({
})
.catch((e) => {
message.destroy();
message.error({ content: `Failed to add: \n ${e.message || ''}`, duration: 3 });
if (
resources.length > 1 &&
e.message === 'Unauthorized to perform this action. Please contact your DataHub administrator.'
) {
message.error({
content:
'Your bulk edit selection included datasets that you do not own. The bulk edit being performed will not be saved.',
duration: 3,
});
} else {
message.error({ content: `Failed to add: \n ${e.message || ''}`, duration: 3 });
}
})
.finally(() => {
setDisableAction(false);
Expand Down Expand Up @@ -323,7 +345,18 @@ export default function EditTagTermsModal({
})
.catch((e) => {
message.destroy();
message.error({ content: `Failed to remove: \n ${e.message || ''}`, duration: 3 });
if (
resources.length > 1 &&
e.message === 'Unauthorized to perform this action. Please contact your DataHub administrator.'
) {
message.error({
content:
'Your bulk edit selection included datasets that you do not own. The bulk edit being performed will not be saved.',
duration: 3,
});
} else {
message.error({ content: `Failed to remove: \n ${e.message || ''}`, duration: 3 });
}
})
.finally(() => {
setDisableAction(false);
Expand Down Expand Up @@ -351,7 +384,18 @@ export default function EditTagTermsModal({
})
.catch((e) => {
message.destroy();
message.error({ content: `Failed to remove: \n ${e.message || ''}`, duration: 3 });
if (
resources.length > 1 &&
e.message === 'Unauthorized to perform this action. Please contact your DataHub administrator.'
mkamalas marked this conversation as resolved.
Show resolved Hide resolved
) {
message.error({
content:
'Your bulk edit selection included datasets that you do not own. The bulk edit being performed will not be saved.',
duration: 3,
});
} else {
message.error({ content: `Failed to remove: \n ${e.message || ''}`, duration: 3 });
}
})
.finally(() => {
setDisableAction(false);
Expand Down
14 changes: 13 additions & 1 deletion datahub-web-react/src/app/shared/tags/CreateTagModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,19 @@ export default function CreateTagModal({ onClose, onBack, visible, tagName, reso
})
.catch((e) => {
message.destroy();
message.error({ content: `Failed to add tag: \n ${e.message || ''}`, duration: 3 });
if (
resources.length > 1 &&
e.message ===
'Unauthorized to perform this action. Please contact your DataHub administrator.'
) {
message.error({
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can be more than just datasets - I don't think this specific of an error message will do in this place

content:
'Your bulk edit selection included datasets that you do not own. The bulk edit being performed will not be saved.',
duration: 3,
});
} else {
message.error({ content: `Failed to add tag: \n ${e.message || ''}`, duration: 3 });
}
onClose();
})
.finally(() => {
Expand Down