[WEB-2682] fix: delete project mutation and workspace draft header validation#5843
[WEB-2682] fix: delete project mutation and workspace draft header validation#5843SatishGandham merged 2 commits intopreviewfrom
Conversation
WalkthroughThe changes involve modifications to the Changes
Possibly related PRs
Suggested labels
Suggested reviewers
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
🧹 Outside diff range and nitpick comments (3)
web/app/[workspaceSlug]/(projects)/drafts/header.tsx (3)
18-18: LGTM: Component declaration simplified and new hook utilizedThe removal of the
FCtype annotation simplifies the component declaration, which is a good practice in modern React development. The addition ofjoinedProjectIdsfrom theuseProjecthook enhances the component's awareness of the user's project context.Consider adding a comment explaining the purpose of
joinedProjectIdsfor 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" buttonThe 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 functionalityThe modifications to the
WorkspaceDraftHeadercomponent successfully address the PR objective of improving the Workspace draft header validation. The changes include:
- Adding the
useProjecthook to access joined project IDs.- Implementing conditional rendering for the "Draft an issue" button based on the user's joined projects.
- Simplifying the component declaration by removing the unnecessary
FCtype 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
📒 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 correctlyThe addition of the
useProjecthook 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 structureThe change to the
deleteProjectmethod enhances its functionality without affecting other parts of theProjectStoreclass. This localized improvement maintains the overall structure and integrity of the class while addressing the specific issue of project permission cleanup.
Changes:
This PR addresses the following changes:
Reference:
[WEB-2682]
Summary by CodeRabbit
New Features
WorkspaceDraftHeadercomponent to conditionally display the button based on project IDs.Bug Fixes
WorkspaceDraftHeadercomponent.Refactor