diff --git a/src/utils/flags/useEnableKubevirtMenuFlags.ts b/src/utils/flags/useEnableKubevirtMenuFlags.ts index 035ea7f9c..2c0f34170 100644 --- a/src/utils/flags/useEnableKubevirtMenuFlags.ts +++ b/src/utils/flags/useEnableKubevirtMenuFlags.ts @@ -1,3 +1,5 @@ +import VirtualMachineClusterInstancetypeModel from '@kubevirt-ui/kubevirt-api/console/models/VirtualMachineClusterInstancetypeModel'; +import VirtualMachineClusterPreferenceModel from '@kubevirt-ui/kubevirt-api/console/models/VirtualMachineClusterPreferenceModel'; import VirtualMachineInstancetypeModel from '@kubevirt-ui/kubevirt-api/console/models/VirtualMachineInstancetypeModel'; import VirtualMachinePreferenceModel from '@kubevirt-ui/kubevirt-api/console/models/VirtualMachinePreferenceModel'; import { @@ -11,12 +13,25 @@ import { FLAG_KUBEVIRT_INSTANCETYPES, FLAG_KUBEVIRT_PREFERENCES } from './consts const useEnableKubevirtMenuFlags = (setFeatureFlag: SetFeatureFlag) => { const [namespace] = useActiveNamespace(); + + const [canShowClusterInstancetypes] = useAccessReview({ + group: VirtualMachineClusterInstancetypeModel.apiGroup, + resource: VirtualMachineClusterInstancetypeModel.plural, + verb: 'list' as K8sVerb, + }); + const [canShowInstancetypes] = useAccessReview({ group: VirtualMachineInstancetypeModel.apiGroup, namespace, resource: VirtualMachineInstancetypeModel.plural, verb: 'list' as K8sVerb, }); + const [canShowClusterPreferences] = useAccessReview({ + group: VirtualMachineClusterPreferenceModel.apiGroup, + namespace, + resource: VirtualMachineClusterPreferenceModel.plural, + verb: 'list' as K8sVerb, + }); const [canShowPreferences] = useAccessReview({ group: VirtualMachinePreferenceModel.apiGroup, @@ -25,8 +40,8 @@ const useEnableKubevirtMenuFlags = (setFeatureFlag: SetFeatureFlag) => { verb: 'list' as K8sVerb, }); - setFeatureFlag(FLAG_KUBEVIRT_PREFERENCES, canShowPreferences); - setFeatureFlag(FLAG_KUBEVIRT_INSTANCETYPES, canShowInstancetypes); + setFeatureFlag(FLAG_KUBEVIRT_PREFERENCES, canShowPreferences || canShowClusterPreferences); + setFeatureFlag(FLAG_KUBEVIRT_INSTANCETYPES, canShowInstancetypes || canShowClusterInstancetypes); }; export default useEnableKubevirtMenuFlags;