Skip to content

Comments

[WEB-2682] fix: delete project mutation and workspace draft header validation#5843

Merged
SatishGandham merged 2 commits intopreviewfrom
fix-draft-issue-project-id
Oct 16, 2024
Merged

[WEB-2682] fix: delete project mutation and workspace draft header validation#5843
SatishGandham merged 2 commits intopreviewfrom
fix-draft-issue-project-id

Conversation

@anmolsinghbhatia
Copy link
Collaborator

@anmolsinghbhatia anmolsinghbhatia commented Oct 16, 2024

Changes:

This PR addresses the following changes:

  • Resolved the issue with the delete project mutation in the permission store.
  • Added validation for the Workspace draft header action button.

Reference:

[WEB-2682]

Summary by CodeRabbit

  • New Features

    • Enhanced WorkspaceDraftHeader component to conditionally display the button based on project IDs.
    • Improved project deletion process by automatically removing associated permissions.
  • Bug Fixes

    • Streamlined export declaration for the WorkspaceDraftHeader component.
  • Refactor

    • Updated method signatures for better clarity and functionality.

@anmolsinghbhatia anmolsinghbhatia added this to the v0.24.0 milestone Oct 16, 2024
@anmolsinghbhatia anmolsinghbhatia self-assigned this Oct 16, 2024
@anmolsinghbhatia anmolsinghbhatia changed the title [WEB] fix: delete project mutation and workspace draft header validation [WEB-2682] fix: delete project mutation and workspace draft header validation Oct 16, 2024
@anmolsinghbhatia anmolsinghbhatia marked this pull request as ready for review October 16, 2024 09:29
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 16, 2024

Walkthrough

The changes involve modifications to the WorkspaceDraftHeader component in header.tsx, simplifying its export statement and enhancing its functionality by adding a new variable derived from the useProject hook. Additionally, the deleteProject method in project.store.ts has been updated to ensure that project permissions are removed when a project is deleted, improving the cleanup process.

Changes

File Path Change Summary
web/app/[workspaceSlug]/(projects)/drafts/header.tsx - Simplified export statement for WorkspaceDraftHeader.
- Added joinedProjectIds from useProject.
- Updated button rendering logic based on joinedProjectIds.
web/core/store/project/project.store.ts - Updated deleteProject method to remove project permissions upon project deletion.

Possibly related PRs

Suggested labels

🐛bug

Suggested reviewers

  • sriramveeraghanta
  • SatishGandham

🐰 In the meadow, changes bloom,
The header shines, dispelling gloom.
With projects joined, the button's bright,
Permissions cleared, all feels right!
A hop, a skip, let’s celebrate,
In code we trust, it’s truly great! 🌼


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

🧹 Outside diff range and nitpick comments (3)
web/app/[workspaceSlug]/(projects)/drafts/header.tsx (3)

18-18: LGTM: Component declaration simplified and new hook utilized

The removal of the FC type annotation simplifies the component declaration, which is a good practice in modern React development. The addition of joinedProjectIds from the useProject hook enhances the component's awareness of the user's project context.

Consider adding a comment explaining the purpose of joinedProjectIds for better code readability:

// Extract joined project IDs to determine if the user is part of any projects
const { joinedProjectIds } = useProject();

Also applies to: 24-24


57-67: LGTM: Improved conditional rendering for the "Draft an issue" button

The new conditional rendering for the "Draft an issue" button enhances the user experience by only displaying the button when the user has joined projects. This change aligns well with the PR objective of improving the Workspace draft header validation.

For improved readability and to make the condition's purpose more explicit, consider extracting the condition into a named constant:

const hasJoinedProjects = joinedProjectIds && joinedProjectIds.length > 0;

// Then in the JSX:
{hasJoinedProjects && (
  <Button
    // ... (rest of the button properties)
  >
    Draft<span className="hidden sm:inline-block"> an issue</span>
  </Button>
)}

This change would make the code's intent clearer and easier to understand at a glance.


Line range hint 1-72: Summary: Changes align with PR objectives and improve component functionality

The modifications to the WorkspaceDraftHeader component successfully address the PR objective of improving the Workspace draft header validation. The changes include:

  1. Adding the useProject hook to access joined project IDs.
  2. Implementing conditional rendering for the "Draft an issue" button based on the user's joined projects.
  3. Simplifying the component declaration by removing the unnecessary FC type annotation.

These changes enhance the user experience by ensuring the draft issue button is only displayed when relevant. The code is well-structured and follows React best practices.

Consider adding unit tests for this component to ensure the new conditional rendering behaves correctly under various scenarios (e.g., with and without joined projects, with different user permissions).

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 9b85306 and bc11563.

📒 Files selected for processing (2)
  • web/app/[workspaceSlug]/(projects)/drafts/header.tsx (3 hunks)
  • web/core/store/project/project.store.ts (1 hunks)
🧰 Additional context used
🔇 Additional comments (3)
web/app/[workspaceSlug]/(projects)/drafts/header.tsx (1)

3-3: LGTM: Import statements updated correctly

The addition of the useProject hook to the import statement is consistent with its usage in the component. This change improves the component's functionality by allowing access to project-related data.

Also applies to: 14-14

web/core/store/project/project.store.ts (2)

407-407: Excellent addition for comprehensive project cleanup!

This new line ensures that project permissions are properly removed from the user's permissions store when a project is deleted. This enhancement aligns well with the PR objective of fixing the delete project mutation and contributes to maintaining data consistency across the application.


Line range hint 1-456: LGTM: Localized improvement with no negative impact on the class structure

The change to the deleteProject method enhances its functionality without affecting other parts of the ProjectStore class. This localized improvement maintains the overall structure and integrity of the class while addressing the specific issue of project permission cleanup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug]: Creating a draft issue with no project is allowed but doesn't actually save

2 participants