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

[WEB-658] fix: multiple toast alerts on adding existing issues #3889

Merged
merged 6 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 0 additions & 6 deletions web/components/core/modals/existing-issues-list-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,6 @@ export const ExistingIssuesListModal: React.FC<Props> = (props) => {
await handleOnSubmit(selectedIssues).finally(() => setIsSubmitting(false));

handleClose();

setToast({
type: TOAST_TYPE.SUCCESS,
title: "Success",
message: `Issue${selectedIssues.length > 1 ? "s" : ""} added successfully`,
});
};

useEffect(() => {
Expand Down
23 changes: 16 additions & 7 deletions web/components/issues/issue-layouts/empty-states/cycle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,22 @@ export const CycleEmptyState: React.FC<Props> = observer((props) => {

const issueIds = data.map((i) => i.id);

await issues.addIssueToCycle(workspaceSlug.toString(), projectId, cycleId.toString(), issueIds).catch(() => {
setToast({
type: TOAST_TYPE.ERROR,
title: "Error!",
message: "Selected issues could not be added to the cycle. Please try again.",
});
});
await issues
.addIssueToCycle(workspaceSlug.toString(), projectId, cycleId.toString(), issueIds)
.then(() =>
setToast({
type: TOAST_TYPE.SUCCESS,
title: "Success!",
message: "Issues added to the cycle successfully.",
})
)
.catch(() =>
setToast({
type: TOAST_TYPE.ERROR,
title: "Error!",
message: "Selected issues could not be added to the cycle. Please try again.",
})
);
};

const emptyStateDetail = CYCLE_EMPTY_STATE_DETAILS["no-issues"];
Expand Down
7 changes: 7 additions & 0 deletions web/components/issues/issue-layouts/empty-states/module.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ export const ModuleEmptyState: React.FC<Props> = observer((props) => {
const issueIds = data.map((i) => i.id);
await issues
.addIssuesToModule(workspaceSlug.toString(), projectId?.toString(), moduleId.toString(), issueIds)
.then(() =>
setToast({
type: TOAST_TYPE.SUCCESS,
title: "Success!",
message: "Issues added to the module successfully.",
})
)
.catch(() =>
setToast({
type: TOAST_TYPE.ERROR,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,13 @@ export const HeaderGroupByCard: FC<IHeaderGroupByCard> = observer((props) => {
const issues = data.map((i) => i.id);

try {
addIssuesToView && addIssuesToView(issues);
await addIssuesToView?.(issues);

setToast({
type: TOAST_TYPE.SUCCESS,
title: "Success!",
message: "Issues added to the cycle successfully.",
});
} catch (error) {
setToast({
type: TOAST_TYPE.ERROR,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,13 @@ export const HeaderGroupByCard = observer(
const issues = data.map((i) => i.id);

try {
addIssuesToView && addIssuesToView(issues);
await addIssuesToView?.(issues);

setToast({
type: TOAST_TYPE.SUCCESS,
title: "Success!",
message: "Issues added to the cycle successfully.",
});
} catch (error) {
setToast({
type: TOAST_TYPE.ERROR,
Expand Down