CNV-59877: Fix permissions request for NADs#352
CNV-59877: Fix permissions request for NADs#352openshift-merge-bot[bot] merged 1 commit intoopenshift:mainfrom
Conversation
Add namespace to the useAccessReview hook so it checks namespace-scoped RBAC instead of cluster-level access. Pass the permission result to NADListEmpty so the create button is hidden when the user lacks permission to create NetworkAttachmentDefinitions. Co-authored-by: Cursor <cursoragent@cursor.com>
|
@upalatucci: This pull request references CNV-59877 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the bug to target the "4.22.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
WalkthroughUpdated NetworkAttachmentDefinition list component to support namespace-aware permission checking. The parent component now passes a canCreateNAD prop to NADListEmpty, which conditionally renders the Create button based on this permission flag instead of always displaying it. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@upalatucci: This pull request references CNV-59877 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the bug to target the "4.22.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/views/nads/list/components/NADListEmpty/NADListEmpty.tsx (1)
23-27: Consider makingcanCreateNADrequired instead of defaulting totrue.Using a permissive default can silently reintroduce the button if a future call site forgets to pass permission state. Requiring the prop makes this safer at compile time.
Suggested tightening of prop contract
type NADListEmptyProps = { - canCreateNAD?: boolean; + canCreateNAD: boolean; namespace: string; }; -const NADListEmpty: FC<NADListEmptyProps> = ({ canCreateNAD = true, namespace }) => { +const NADListEmpty: FC<NADListEmptyProps> = ({ canCreateNAD, namespace }) => {🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/views/nads/list/components/NADListEmpty/NADListEmpty.tsx` around lines 23 - 27, The prop canCreateNAD on NADListEmpty (declared in NADListEmptyProps and used in the NADListEmpty functional component) should be made required instead of optional with a default true: remove the "?" from canCreateNAD in the NADListEmptyProps type and remove the default assignment ({ canCreateNAD = true, namespace }) in the NADListEmpty component signature; update any call sites that render NADListEmpty to explicitly pass a boolean for canCreateNAD so the compiler enforces permission handling.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/views/nads/list/components/NADListEmpty/NADListEmpty.tsx`:
- Around line 23-27: The prop canCreateNAD on NADListEmpty (declared in
NADListEmptyProps and used in the NADListEmpty functional component) should be
made required instead of optional with a default true: remove the "?" from
canCreateNAD in the NADListEmptyProps type and remove the default assignment ({
canCreateNAD = true, namespace }) in the NADListEmpty component signature;
update any call sites that render NADListEmpty to explicitly pass a boolean for
canCreateNAD so the compiler enforces permission handling.
ℹ️ Review info
Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge base: Disabled due to data retention organization setting
📒 Files selected for processing (2)
src/views/nads/list/NetworkAttachmentDefinitionList.tsxsrc/views/nads/list/components/NADListEmpty/NADListEmpty.tsx
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: adamviktora, upalatucci The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/retest |
|
@upalatucci: all tests passed! Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
|
/cherry-pick release-4.21 |
|
@upalatucci: new pull request created: #353 DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Summary
namespaceto theuseAccessReviewhook inNetworkAttachmentDefinitionListso it checks namespace-scoped RBAC permissions instead of cluster-level accessNADListEmptycomponent so the "Create NetworkAttachmentDefinition" button is hidden when the user lackscreatepermission for NADs in the current namespaceFixes: https://issues.redhat.com/browse/CNV-59877
Test plan
Made with Cursor
Summary by CodeRabbit