[WEB-2320] fix: Redirect to issues page post issue deletion deletion#5437
[WEB-2320] fix: Redirect to issues page post issue deletion deletion#5437SatishGandham merged 1 commit intopreviewfrom
Conversation
WalkthroughThe changes to the Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 1
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- web/core/components/issues/issue-detail/issue-detail-quick-actions.tsx (1 hunks)
Additional comments not posted (2)
web/core/components/issues/issue-detail/issue-detail-quick-actions.tsx (2)
81-81: Refactor: Consolidate deletion logicThe use of the
deleteIssuevariable to conditionally assign eitherremoveArchivedIssueorremoveIssuebased on whether the issue is archived is a good refactor. It reduces code duplication and improves readability.The code changes are approved.
82-84: Refactor: Simplify redirection logicThe use of the
redirectionPathvariable to determine the redirection path after deletion is a good refactor. It simplifies the routing logic and makes the code more maintainable.The code changes are approved.
| return deleteIssue(workspaceSlug, projectId, issueId).then(() => { | ||
| router.push(redirectionPath); | ||
| captureIssueEvent({ | ||
| eventName: ISSUE_DELETED, | ||
| payload: { id: issueId, state: "SUCCESS", element: "Issue detail page" }, | ||
| path: pathname, | ||
| }); | ||
| } else { | ||
| return removeIssue(workspaceSlug, projectId, issueId); | ||
| } | ||
| }); |
There was a problem hiding this comment.
Ensure proper error handling
The refactored code correctly handles errors by displaying a toast message and capturing the issue event. However, consider logging the error for debugging purposes.
try {
const deleteIssue = issue?.archived_at ? removeArchivedIssue : removeIssue;
const redirectionPath = issue?.archived_at
? `/${workspaceSlug}/projects/${projectId}/archives/issues`
: `/${workspaceSlug}/projects/${projectId}/issues`;
return deleteIssue(workspaceSlug, projectId, issueId).then(() => {
router.push(redirectionPath);
captureIssueEvent({
eventName: ISSUE_DELETED,
payload: { id: issueId, state: "SUCCESS", element: "Issue detail page" },
path: pathname,
});
});
} catch (error) {
+ console.error("Error deleting issue:", error);
setToast({
title: "Error!",
type: TOAST_TYPE.ERROR,
message: "Issue delete failed",
});
captureIssueEvent({
eventName: ISSUE_DELETED,
payload: { id: issueId, state: "FAILED", element: "Issue detail page" },
path: pathname,
});
}Consider logging the error for debugging purposes.
Committable suggestion was skipped due to low confidence.
This PR adds a redirection from issue detail page post issue deletion.
Screen.Recording.2024-08-27.at.4.24.25.PM.mov
Summary by CodeRabbit