Skip to content

[WEB-3414] fix: cmd-k project level action in work item detail page#6637

Merged
sriramveeraghanta merged 1 commit intopreviewfrom
fix-cmd-k-project-level-action-in-work-item-detail-page
Feb 18, 2025
Merged

[WEB-3414] fix: cmd-k project level action in work item detail page#6637
sriramveeraghanta merged 1 commit intopreviewfrom
fix-cmd-k-project-level-action-in-work-item-detail-page

Conversation

@anmolsinghbhatia
Copy link
Collaborator

@anmolsinghbhatia anmolsinghbhatia commented Feb 18, 2025

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

  • Bug fix
  • Code refactoring

References

[WEB-3414]

Summary by CodeRabbit

  • Refactor
    • Updated issue modals to simplify how issue details are retrieved and displayed, ensuring a more consistent user experience.
    • Refined command interface logic with improved identifier handling and enhanced permission checks based on the current workspace and project context.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 18, 2025

Walkthrough

This change refactors the way issue details are handled in the Command Palette and Issue Level Modals. In the modal component, a new Props type is introduced with optional projectId and issueId, and the data fetching is updated to use getIssueById from the useIssueDetail hook. In the Command Palette component, parameter extraction is adjusted (renaming projectId to paramsProjectId), and both useSWR and useIssueDetail hooks are integrated to fetch issue details. Permission checks are updated and the rendering of modals now depends on the proper passing of these new props.

Changes

File(s) Change Summary
web/ce/.../modals/issue-level.tsx Added a new Props type (with optional projectId and issueId), refactored the component to destructure props, replaced useSWR with getIssueById from useIssueDetail, and updated modal rendering conditions to require all identifiers.
web/core/.../command-palette.tsx Modified parameter extraction by renaming projectId to paramsProjectId, integrated useSWR and useIssueDetail for fetching issue details, updated permission check functions to include workspace details, and passed projectId & issueId to modals.

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
Loading

Possibly related PRs

Suggested labels

🐛bug, 🌐frontend, 🌟improvement

Suggested reviewers

  • sriramveeraghanta
  • prateekshourya29

Poem

Hey, I'm a rabbit with code so neat,
Hopping through changes with a rhythmic beat.
New props and hooks lead the way,
In IssueLevelModals they now hold sway.
With every line, bugs bid adieu,
Happy hops and clean code—woohoo!
🐰💻


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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 64752de and 0ef74fd.

📒 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];
Copy link
Member

Choose a reason for hiding this comment

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

Can we create a helper function for this?

@sriramveeraghanta sriramveeraghanta merged commit 51c2ea6 into preview Feb 18, 2025
5 of 6 checks passed
@sriramveeraghanta sriramveeraghanta deleted the fix-cmd-k-project-level-action-in-work-item-detail-page branch February 18, 2025 21:30
@coderabbitai coderabbitai bot mentioned this pull request Mar 5, 2025
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants