diff --git a/src/views/checkups/storage/components/hooks/useCheckupsStoragePermissions.ts b/src/views/checkups/storage/components/hooks/useCheckupsStoragePermissions.ts index 021e6b7bc..7fd66861f 100644 --- a/src/views/checkups/storage/components/hooks/useCheckupsStoragePermissions.ts +++ b/src/views/checkups/storage/components/hooks/useCheckupsStoragePermissions.ts @@ -14,6 +14,7 @@ import { IoK8sApiRbacV1ClusterRoleBinding, } from '@kubevirt-ui/kubevirt-api/kubernetes'; import { ALL_NAMESPACES_SESSION_KEY } from '@kubevirt-utils/hooks/constants'; +import { isEmpty } from '@kubevirt-utils/utils/utils'; import { useActiveNamespace, useK8sWatchResource } from '@openshift-console/dynamic-plugin-sdk'; import { @@ -44,7 +45,9 @@ export const useCheckupsStoragePermissions = () => { }, ); - const [clusterRoleBinding] = useK8sWatchResource( + const [clusterRoleBinding, loadedClusterRoleBinding] = useK8sWatchResource< + IoK8sApiRbacV1ClusterRoleBinding[] + >( !isAllNamespace && { groupVersionKind: modelToGroupVersionKind(ClusterRoleBindingModel), isList: true, @@ -81,7 +84,11 @@ export const useCheckupsStoragePermissions = () => { return { clusterRoleBinding: isClusterRoleBinding, - isPermitted: Boolean(isServiceAccount && isConfigMapRole && isConfigMapRoleBinding), - loading: !loadingServiceAccounts && !loadingRoles && !loadingRolesBinding, + isPermitted: Boolean( + isServiceAccount && isConfigMapRole && isConfigMapRoleBinding && isClusterRoleBinding, + ), + isPermittedToInstall: !isEmpty(clusterRoleBinding), + loading: + !loadingServiceAccounts && !loadingRoles && !loadingRolesBinding && !loadedClusterRoleBinding, }; }; diff --git a/src/views/checkups/storage/list/CheckupsStorageList.tsx b/src/views/checkups/storage/list/CheckupsStorageList.tsx index fd1b4968c..2e0c15b79 100644 --- a/src/views/checkups/storage/list/CheckupsStorageList.tsx +++ b/src/views/checkups/storage/list/CheckupsStorageList.tsx @@ -25,6 +25,7 @@ const CheckupsStorageList = () => { const { clusterRoleBinding, isPermitted, + isPermittedToInstall, loading: loadingPermissions, } = useCheckupsStoragePermissions(); const { configMaps, error, jobs, loading } = useCheckupsStorageData(); @@ -38,6 +39,7 @@ const CheckupsStorageList = () => { ); diff --git a/src/views/checkups/storage/list/CheckupsStorageListEmptyState.tsx b/src/views/checkups/storage/list/CheckupsStorageListEmptyState.tsx index c902555c9..5591b889f 100644 --- a/src/views/checkups/storage/list/CheckupsStorageListEmptyState.tsx +++ b/src/views/checkups/storage/list/CheckupsStorageListEmptyState.tsx @@ -27,12 +27,14 @@ import './CheckupsStorageListEmptyState.scss'; type CheckupsStorageListEmptyStateProps = { clusterRoleBinding: IoK8sApiRbacV1ClusterRoleBinding; isPermitted: boolean; + isPermittedToInstall: boolean; loadingPermissions: boolean; }; const CheckupsStorageListEmptyState: FC = ({ clusterRoleBinding, isPermitted, + isPermittedToInstall, loadingPermissions, }) => { const { t } = useKubevirtTranslation(); @@ -64,6 +66,12 @@ const CheckupsStorageListEmptyState: FC = ({ - +