-
Notifications
You must be signed in to change notification settings - Fork 3.2k
[WEB-3287]fix: label creation in global views #6541
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughThis pull request updates the event handling logic related to label creation in two React components. Both components now enforce permission checks before adding a label. In the Changes
Sequence Diagram(s)sequenceDiagram
participant U as User
participant C as Label Component
participant PC as Permission Checker
U->>C: Press "Enter" key in search input
C->>PC: Verify canCreateLabel (and workspace context if applicable)
alt Permission Granted
PC-->>C: Permission valid
C->>C: Execute label addition logic
else Permission Denied
PC-->>C: Permission invalid
C->>U: Ignore action or show error
end
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Tip 🌐 Web search-backed reviews and chat
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.
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/issues/issue-detail/label/select/label-select.tsx (1)
99-104: LGTM! Permission check added for label creation.The addition of the
canCreateLabelcheck in the Enter key handler aligns with the PR objective of restricting label creation. This ensures that only users with appropriate permissions can create labels.Consider adding a user feedback message when label creation is attempted without permission:
if (query !== "" && e.key === "Enter" && canCreateLabel) { e.stopPropagation(); e.preventDefault(); await handleAddLabel(query); +} else if (query !== "" && e.key === "Enter") { + e.stopPropagation(); + e.preventDefault(); + // Show feedback that user doesn't have permission to create labels }web/core/components/issues/issue-layouts/properties/label-dropdown.tsx (1)
160-163: LGTM! Consistent permission check implementation.The permission check in the Enter key handler matches the implementation in the label-select component, ensuring consistent behavior across components.
Consider adding the same user feedback message suggested for the label-select component:
if (query !== "" && e.key === "Enter" && canCreateLabel) { e.preventDefault(); await handleAddLabel(query); +} else if (query !== "" && e.key === "Enter") { + e.preventDefault(); + // Show feedback that user doesn't have permission to create labels }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
web/core/components/issues/issue-detail/label/select/label-select.tsx(1 hunks)web/core/components/issues/issue-layouts/properties/label-dropdown.tsx(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Analyze (javascript)
- GitHub Check: Analyze (python)
🔇 Additional comments (1)
web/core/components/issues/issue-layouts/properties/label-dropdown.tsx (1)
84-84: LGTM! Workspace-aware permission check added.The
canCreateLabelpermission check now includes theworkspaceSlugparameter, making it properly workspace-aware. This aligns with the PR objective of restricting label creation in global views.
There was a problem hiding this 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 (1)
web/core/components/issues/issue-layouts/properties/label-dropdown.tsx (1)
279-298: Consider adding user feedback for permission denied cases.When a user without permissions attempts to create a label (by pressing Enter or clicking), they currently see "No matching results." Consider showing a more informative message like "You don't have permission to create labels."
) : submitting ? ( <Loader className="spin h-3.5 w-3.5" /> ) : canCreateLabel ? ( <p onClick={() => { if (!query.length) return; handleAddLabel(query); }} className={`text-left text-custom-text-200 ${query.length ? "cursor-pointer" : "cursor-default"}`} > {query.length ? ( <> + Add <span className="text-custom-text-100">"{query}"</span> to labels </> ) : ( "Type to add a new label" )} </p> ) : ( - <p className="text-left text-custom-text-200 ">No matching results.</p> + <p className="text-left text-custom-text-200"> + {query.length ? "You don't have permission to create labels" : "No matching results"} + </p> )}
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
web/core/components/issues/issue-detail/label/select/label-select.tsx(2 hunks)web/core/components/issues/issue-layouts/properties/label-dropdown.tsx(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- web/core/components/issues/issue-detail/label/select/label-select.tsx
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Analyze (javascript)
- GitHub Check: Analyze (python)
🔇 Additional comments (2)
web/core/components/issues/issue-layouts/properties/label-dropdown.tsx (2)
84-85: LGTM! Permission check enhancement properly scopes label creation.The permission check now correctly includes both workspace and project context, which aligns with the PR objective to restrict label creation.
161-164: LGTM! Label creation is properly gated by permissions.The Enter key handler now correctly enforces the permission check before allowing label creation.
* fix: label creation on enter * fix: update label creation permissions --------- Co-authored-by: sriram veeraghanta <[email protected]>
Description
This update fixes labels creation at views.
Type of Change
Screenshots and Media (if applicable)
Test Scenarios
References
WEB-3287
WEB-3289
Summary by CodeRabbit