Skip to content

Conversation

@anmolsinghbhatia
Copy link
Collaborator

@anmolsinghbhatia anmolsinghbhatia commented Feb 17, 2025

Description

This PR includes following changes:

  • Fixed the Cmd-K work item action issue and updated permission validation for work item header actions. Previously, the project ID was retrieved from the router, causing issues after the new URL implementation.

Type of Change

  • Bug fix
  • Code refactoring

References

[WEB-3410]

Summary by CodeRabbit

  • Refactor
    • Improved fetching logic for issue details, moving to a hook-based implementation.
    • Streamlined parameter handling for actions like updating assignee, priority, and state, enhancing clarity.
    • Enhanced permission checks by incorporating workspace and project context for edit and restore capabilities.
    • Simplified label color retrieval by directly accessing label data through identifiers.
  • Style
    • Applied minor formatting updates for increased code clarity and consistency.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 17, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This pull request refactors issue handling across several components. The changes replace service-based fetching with a hook-based approach in the issue-level component, update parameter extraction logic (switching from issueId to workItem), and introduce new variables to parse identifiers. Other components now derive projectId and related variables from the issue object instead of URL parameters. Minor formatting changes and updates to permission checks have also been made.

Changes

File(s) Change Summary
web/ce/components/command-palette/modals/issue-level.tsx Updated import statements to include useIssueDetail; removed ISSUE_DETAILS constant and issueService; changed parameter extraction from issueId to workItem with derivation of projectIdentifier and sequence_id; updated fetching logic to use fetchIssueWithIdentifier.
web/core/components/command-palette/actions/issue-actions/actions-list.tsx Modified parameter handling to derive projectId and issueId from issueDetails instead of URL parameters.
web/core/components/command-palette/actions/issue-actions/change-assignee.tsx Removed destructuring of projectId from useParams; now derives projectId from the issue object; updated to use getProjectMemberIds(projectId) instead of direct destructuring for member IDs.
web/core/components/command-palette/actions/issue-actions/change-priority.tsx Eliminated extraction of projectId from router parameters; now sourcing projectId from the issue prop for conditional checks in the update function.
web/core/components/command-palette/actions/issue-actions/change-state.tsx Updated extraction logic to derive projectId from the issue object; replaced direct access to projectStates with getProjectStates(projectId) via the hook.
web/core/components/issues/delete-issue-modal.tsx Minor formatting change in the import statement (removed extra space after commas).
web/core/components/issues/issue-detail/issue-detail-quick-actions.tsx Enhanced permission checks by adding workspaceSlug and projectId as parameters to the allowPermissions function for isEditable and canRestoreIssue.
web/core/components/command-palette/command-palette.tsx Updated parameter extraction from useParams to replace issueId with workItem; modified dependency array in copyIssueUrlToClipboard function.
web/core/components/issues/issue-detail/issue-activity/activity/actions/label.tsx Updated label color retrieval to use getLabelById instead of searching through projectLabels, simplifying the logic.

Possibly related PRs

Suggested labels

🐛bug, 🌐frontend, 🧹chore

Suggested reviewers

  • rahulramesha

Poem

I'm a nimble rabbit in the code forest green,
Hopping through refactors where new hooks are seen.
I leave behind old services for a cleaner way,
Parsing work items with a joyful sway.
Here's to changes that make our code gleam—hip, hip, hooray!
🐇🌟


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 126c0b6 and fa17429.

📒 Files selected for processing (1)
  • web/core/components/issues/issue-detail/issue-activity/activity/actions/label.tsx (2 hunks)

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: 2

🔭 Outside diff range comments (1)
web/core/components/issues/issue-detail/issue-detail-quick-actions.tsx (1)

117-118: ⚠️ Potential issue

Fix translation key typo.

The translation key "toast.error " contains an extra space which could cause issues with translation lookups.

Apply this fix:

-        title: t("toast.error "),
+        title: t("toast.error"),
🧹 Nitpick comments (3)
web/ce/components/command-palette/modals/issue-level.tsx (2)

16-16: Consider fallback handling for split logic.
You introduced workItem for retrieving identifiers. If workItem is missing or doesn't follow the <projectIdentifier>-<sequence_id> pattern, the subsequent lines may break. Consider adding a fallback or validation for safety.


39-41: Validate SWR key uniqueness and handle missing values.
Using "ISSUE_DETAIL_${workspaceSlug}_${projectIdentifier}_${sequence_id}" as the key is fine, but handle cases where projectIdentifier or sequence_id might be empty. This prevents potential collisions or null fetches.

web/core/components/command-palette/actions/issue-actions/change-priority.tsx (1)

27-27: Validate issue object presence.
Deriving projectId from issue?.project_id can fail if the issue is undefined or if project_id is missing. Safeguard this logic or provide an appropriate fallback.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 075eefe and bb39859.

📒 Files selected for processing (7)
  • web/ce/components/command-palette/modals/issue-level.tsx (2 hunks)
  • web/core/components/command-palette/actions/issue-actions/actions-list.tsx (1 hunks)
  • web/core/components/command-palette/actions/issue-actions/change-assignee.tsx (1 hunks)
  • web/core/components/command-palette/actions/issue-actions/change-priority.tsx (1 hunks)
  • web/core/components/command-palette/actions/issue-actions/change-state.tsx (1 hunks)
  • web/core/components/issues/delete-issue-modal.tsx (1 hunks)
  • web/core/components/issues/issue-detail/issue-detail-quick-actions.tsx (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • web/core/components/issues/delete-issue-modal.tsx
🔇 Additional comments (9)
web/ce/components/command-palette/modals/issue-level.tsx (3)

9-9: Use of new store hook is consistent.
Great job switching to useIssueDetail for fetching issue details. This aligns with the broader hook-based approach.


23-23: Confirm removal of issueService references.
This change replaces the service-based approach with the fetchIssueWithIdentifier hook. Make sure all references to the obsolete issueService are removed to avoid inconsistencies.


45-46: Ensure consistent fallback for projectId.
Defaulting to paramsProjectId first is good. Confirm that issueDetails?.project_id is never needed if paramsProjectId is set, or consider which value to prioritize in edge cases.

web/core/components/command-palette/actions/issue-actions/change-priority.tsx (1)

23-23: Confirm minimal router usage.
Using only workspaceSlug from the router is a cleaner approach. Ensure that other components dependent on projectId from the URL are updated to rely on the issue object if that is now the single source of truth.

web/core/components/command-palette/actions/issue-actions/change-state.tsx (2)

20-20: Minimal parameter extraction looks good.
Relying on workspaceSlug alone keeps the router usage streamlined and less error-prone. Confirm that any previous usage of projectId from the router is fully deprecated to prevent confusion.


23-23: Check for parallel usage of getProjectStates.
You replaced projectStates with getProjectStates(...). Ensure that no stale references exist to the old store variable or that references to it are removed to avoid confusion.

web/core/components/command-palette/actions/issue-actions/change-assignee.tsx (1)

21-22: LGTM! Improved parameter handling.

The changes simplify parameter extraction and make projectId derivation more reliable by sourcing it directly from the issue object.

Also applies to: 28-29

web/core/components/command-palette/actions/issue-actions/actions-list.tsx (1)

27-34: LGTM! Enhanced parameter handling with explicit derivation.

The changes improve code reliability by deriving issueId and projectId directly from issueDetails, making the source of truth more explicit and consistent.

web/core/components/issues/issue-detail/issue-detail-quick-actions.tsx (1)

173-184: LGTM! Enhanced permission validation.

The changes improve security by adding granular permission checks at both workspace and project levels.

Comment on lines +35 to +36
const projectIdentifier = workItem?.toString().split("-")[0];
const sequence_id = workItem?.toString().split("-")[1];
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Validate workItem split for robust error handling.
Splitting workItem?.toString() by - may cause runtime errors if workItem is undefined or if the string doesn't contain a dash. Add suitable checks or default values.

Comment on lines +25 to +26
const projectId = issue?.project_id;
const projectStates = getProjectStates(projectId);
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Handle null projectId scenario.
Using issue?.project_id is more reliable, but if issue is undefined, getProjectStates(projectId) might return undefined or throw an error. Consider gracefully falling back or showing a more meaningful warning.

@sriramveeraghanta sriramveeraghanta merged commit a9aeeb6 into preview Feb 17, 2025
3 of 5 checks passed
@sriramveeraghanta sriramveeraghanta deleted the fix-work-item-permission-and-validation branch February 17, 2025 12:39
@coderabbitai coderabbitai bot mentioned this pull request Mar 24, 2025
6 tasks
lifeiscontent pushed a commit that referenced this pull request Aug 18, 2025
* fix: work item permission and validation

* fix: command palette

* chore: code refactor
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.

4 participants