[WEB-3414] fix: cmd-k project level action in work item detail page#6637
Conversation
WalkthroughThis change refactors the way issue details are handled in the Command Palette and Issue Level Modals. In the modal component, a new Changes
Sequence Diagram(s)sequenceDiagram
participant CP as CommandPalette
participant RP as useParams
participant API as Data Fetcher (useSWR)
participant IL as IssueLevelModals
participant IH as useIssueDetail (getIssueById)
participant DM as DeleteIssueModal
CP->>RP: Extract workspaceSlug, cycleId, moduleId, paramsProjectId
CP->>API: Fetch issue details using workspace slug & workItem
API-->>CP: Return issue details
CP->>IL: Render IssueLevelModals with projectId & issueId
IL->>IH: getIssueById(issueId)
IH-->>IL: Return issueDetails
IL->>DM: Render DeleteIssueModal if projectId, issueId, and issueDetails are defined
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/core/components/command-palette/command-palette.tsx (2)
51-64: Consider adding error handling for the SWR data fetching.While the implementation is robust, it would be beneficial to handle potential errors from the SWR hook.
const { data: issueDetails } = useSWR( workspaceSlug && workItem ? `ISSUE_DETAIL_${workspaceSlug}_${projectIdentifier}_${sequence_id}` : null, workspaceSlug && workItem ? () => fetchIssueWithIdentifier(workspaceSlug.toString(), projectIdentifier, sequence_id) : null + { + onError: (error) => { + setToast({ + type: TOAST_TYPE.ERROR, + title: "Failed to fetch issue details", + message: error.message + }); + } + } );
268-268: Consider adding runtime type checking for projectId and issueId.While TypeScript handles compile-time type checking, adding runtime checks could prevent potential issues.
-<IssueLevelModals projectId={projectId} issueId={issueId} /> +<IssueLevelModals + projectId={typeof projectId === 'string' ? projectId : undefined} + issueId={typeof issueId === 'string' ? issueId : undefined} +/>
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
web/ce/components/command-palette/modals/issue-level.tsx(3 hunks)web/core/components/command-palette/command-palette.tsx(5 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Analyze (javascript)
- GitHub Check: Analyze (python)
🔇 Additional comments (7)
web/ce/components/command-palette/modals/issue-level.tsx (4)
13-16: LGTM! Well-defined Props type.The Props type definition is clear and follows TypeScript best practices with optional parameters.
18-28: LGTM! Improved type safety and data fetching.The changes enhance type safety with FC and simplify data fetching using the useIssueDetail hook.
41-41: LGTM! Simplified issue details fetching.The new approach using getIssueById is more direct and efficient.
52-62: LGTM! Comprehensive rendering conditions.The conditions for rendering DeleteIssueModal are thorough and prevent potential runtime errors by checking all required props.
web/core/components/command-palette/command-palette.tsx (3)
6-6: LGTM! Enhanced imports and parameter clarity.The addition of useSWR and useIssueDetail hooks, along with the clear parameter naming (paramsProjectId), improves code clarity.
Also applies to: 15-22, 41-41
69-80: LGTM! Comprehensive permission checks.The permission checks now properly include workspace and project context, which aligns with the PR objective of fixing project-level actions.
175-178: LGTM! Proper Command-K shortcut handling.The implementation correctly handles the Command-K shortcut and modal state, fixing the reported issue.
|
|
||
| // derived values | ||
| const projectIdentifier = workItem?.toString().split("-")[0]; | ||
| const sequence_id = workItem?.toString().split("-")[1]; |
There was a problem hiding this comment.
Can we create a helper function for this?
Description
This PR resolves a bug where users were unable to perform project-level actions from Command-K on the work item detail page.
Type of Change
References
[WEB-3414]
Summary by CodeRabbit