Skip to content

Commit

Permalink
Merge pull request #2348 from upalatucci/preference-instancetype-navb…
Browse files Browse the repository at this point in the history
…ar-disappear

CNV-52452: Preference instancetype navbar disappear
  • Loading branch information
openshift-merge-bot[bot] authored Jan 9, 2025
2 parents 48bd707 + 62465cb commit 68dfefc
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/utils/flags/useEnableKubevirtMenuFlags.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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,
Expand All @@ -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;

0 comments on commit 68dfefc

Please sign in to comment.