From 6b14d2f7daa8caaa82d32cae570216cf501dd72b Mon Sep 17 00:00:00 2001 From: Ugo Palatucci Date: Wed, 25 Feb 2026 10:45:44 +0100 Subject: [PATCH] CNV-59877: Hide NAD create button for users without create permission 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 --- .../list/NetworkAttachmentDefinitionList.tsx | 3 ++- .../components/NADListEmpty/NADListEmpty.tsx | 23 +++++++++++-------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/views/nads/list/NetworkAttachmentDefinitionList.tsx b/src/views/nads/list/NetworkAttachmentDefinitionList.tsx index 4b9334c5..75075c56 100644 --- a/src/views/nads/list/NetworkAttachmentDefinitionList.tsx +++ b/src/views/nads/list/NetworkAttachmentDefinitionList.tsx @@ -49,6 +49,7 @@ const NetworkAttachmentDefinitionList: FC const [canCreateNAD] = useAccessReview({ group: NetworkAttachmentDefinitionModel.apiGroup, + namespace, resource: NetworkAttachmentDefinitionModel.plural, verb: 'create' as K8sVerb, }); @@ -91,7 +92,7 @@ const NetworkAttachmentDefinitionList: FC columns={columns} data={filteredData} - EmptyMsg={() => } + EmptyMsg={() => } loaded={loaded} loadError={loadError} Row={NADsRow} diff --git a/src/views/nads/list/components/NADListEmpty/NADListEmpty.tsx b/src/views/nads/list/components/NADListEmpty/NADListEmpty.tsx index afc6ff3a..b48b663e 100644 --- a/src/views/nads/list/components/NADListEmpty/NADListEmpty.tsx +++ b/src/views/nads/list/components/NADListEmpty/NADListEmpty.tsx @@ -20,10 +20,11 @@ import { QuickStartModel } from '@utils/models'; import { resourcePathFromModel } from '@utils/resources/shared'; type NADListEmptyProps = { + canCreateNAD?: boolean; namespace: string; }; -const NADListEmpty: FC = ({ namespace }) => { +const NADListEmpty: FC = ({ canCreateNAD = true, namespace }) => { const navigate = useNavigate(); const { t } = useNetworkingTranslation(); @@ -43,15 +44,17 @@ const NADListEmpty: FC = ({ namespace }) => { return ( - + {canCreateNAD && ( + + )} {hasQuickStarts && (