@@ -12,6 +12,7 @@ interface FeaturesGatingConfig {
1212 features : string [ ] ,
1313}
1414
15+ // features to be gated to specific operator versions
1516export const MACH_REG_CONFIG_DEFAULTS :string = 'machine-reg-config-defaults' ;
1617export const BUILD_MEDIA_RAW_SUPPORT :string = 'build-media-raw-support' ;
1718
@@ -38,8 +39,7 @@ const FEATURES_GATING:FeaturesGatingConfig[] = [
3839
3940/**
4041 * Get the current elemental-operator version
41- * @param any store
42- * @param any alreadyInstalledApps
42+ * @param any Vue store
4343 * @returns Promise<string | void>
4444 */
4545export async function getOperatorVersion ( store : any ) : Promise < string | void > {
@@ -54,26 +54,23 @@ export async function getOperatorVersion(store: any): Promise<string | void> {
5454}
5555
5656/**
57- * Get the gated feature based on resource + mode + string
58- * @param string
59- * @param string
60- * @param string
61- * @returns FeaturesGatingConfig | {} | void
57+ * Check the gated feature compatibility with the current Elemental Operator version installed
58+ * @param string resource type (ex: Deployment)
59+ * @param string UI mode (ex: edit, create, view)
60+ * @param string Elemental feature (ex: Build media, cloud config)
61+ * @param string Elemental Operator version
62+ * @returns Boolean
6263 */
63- export function getGatedFeature ( resource : string , mode : string , feature : string ) : FeaturesGatingConfig | { } | void {
64- if ( resource && mode ) {
65- return FEATURES_GATING . find ( feat => feat . area === resource && feat . mode . includes ( mode ) && feat . features . includes ( feature ) ) ;
66- }
64+ export function checkGatedFeatureCompatibility ( resource : string , mode : string , feature : string , operatorVersion : string ) : Boolean {
65+ if ( resource && mode && feature ) {
66+ const gatedFeature = FEATURES_GATING . find ( feat => feat . area === resource && feat . mode . includes ( mode ) && feat . features . includes ( feature ) ) ;
6767
68- return { } ;
69- }
68+ if ( ! gatedFeature ?. minOperatorVersion || ! operatorVersion ) {
69+ return false ;
70+ }
7071
71- /**
72- * Determines if a given feature is enabled by doing a semver version comparison
73- * @param string
74- * @param string
75- * @returns Boolean | void
76- */
77- export function semverVersionCheck ( operatorVersion : string , operatorMinVersion : string ) : Boolean | void {
78- return semver . gte ( operatorVersion , operatorMinVersion ) ;
72+ return semver . gte ( operatorVersion , gatedFeature ?. minOperatorVersion ) ;
73+ }
74+
75+ return false ;
7976}
0 commit comments