[WEB-3415] chore: work item url redirection improvement#6627
[WEB-3415] chore: work item url redirection improvement#6627sriramveeraghanta merged 1 commit intopreviewfrom
Conversation
WalkthroughThe changes update the Changes
Sequence Diagram(s)sequenceDiagram
participant Page as IssueDetailsPage
participant SWR as useSWR Hook
participant Redirect as redirect Function
participant UI as User Interface (Spinner/EmptyState)
Page->>SWR: Initiate issue metadata fetch
alt Data is loading
SWR->>Page: Return loading state
Page->>UI: Display loading spinner
else Data fetched successfully
SWR->>Page: Return fetched data
Page->>Redirect: Trigger redirection
else Error occurs
SWR->>Page: Return error state
Page->>UI: Display EmptyState component
end
Possibly related PRs
Suggested labels
Suggested reviewers
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 using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/issues/(detail)/[issueId]/page.tsx (2)
27-32: Consider optimizing the SWR implementation.While the implementation is functional, consider these improvements:
- Use array notation for the SWR key to improve maintainability
- Add TypeScript types for the response data
- const { data, isLoading, error } = useSWR( - workspaceSlug && projectId && issueId ? `ISSUE_DETAIL_META_${workspaceSlug}_${projectId}_${issueId}` : null, - workspaceSlug && projectId && issueId - ? () => issueService.getIssueMetaFromURL(workspaceSlug.toString(), projectId.toString(), issueId.toString()) - : null - ); + const { data, isLoading, error } = useSWR<{ project_identifier: string; sequence_id: number }>( + workspaceSlug && projectId && issueId ? ['ISSUE_DETAIL_META', workspaceSlug, projectId, issueId] : null, + ([, ws, pid, iid]) => issueService.getIssueMetaFromURL(ws.toString(), pid.toString(), iid.toString()) + );
42-58: Consider enhancing error state information.While the error handling is comprehensive, consider providing more specific error information to help users understand and resolve issues.
{error ? ( <EmptyState image={resolvedTheme === "dark" ? emptyIssueDark : emptyIssueLight} - title={t("issue.empty_state.issue_detail.title")} - description={t("issue.empty_state.issue_detail.description")} + title={t("issue.empty_state.issue_detail.title")} + description={ + error.status === 404 + ? t("issue.empty_state.issue_detail.not_found") + : t("issue.empty_state.issue_detail.description") + } primaryButton={{ text: t("issue.empty_state.issue_detail.primary_button.text"), onClick: () => router.push(`/${workspaceSlug}/workspace-views/all-issues/`), }} + secondaryButton={error.status !== 404 ? { + text: t("common.try_again"), + onClick: () => window.location.reload(), + } : undefined} />
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/issues/(detail)/[issueId]/page.tsx(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Analyze (javascript)
- GitHub Check: Analyze (python)
🔇 Additional comments (3)
web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/issues/(detail)/[issueId]/page.tsx (3)
5-15: LGTM! Well-organized imports.The new imports are logically grouped and align with the PR objectives for improving URL redirection and error handling.
23-25: LGTM! Proper hook initialization.The hooks are correctly initialized and follow React's rules of hooks. The internationalization and theme hooks enhance the component's functionality.
34-38: LGTM! Clean redirection implementation.The redirection logic is simple, effective, and properly handles the data dependency.
Description
This PR improves work item URL redirection and includes error state.
Type of Change
References
[WEB-3415]
Summary by CodeRabbit