@@ -12,6 +12,7 @@ interface FeaturesGatingConfig {
12
12
features : string [ ] ,
13
13
}
14
14
15
+ // features to be gated to specific operator versions
15
16
export const MACH_REG_CONFIG_DEFAULTS :string = 'machine-reg-config-defaults' ;
16
17
export const BUILD_MEDIA_RAW_SUPPORT :string = 'build-media-raw-support' ;
17
18
@@ -38,8 +39,7 @@ const FEATURES_GATING:FeaturesGatingConfig[] = [
38
39
39
40
/**
40
41
* Get the current elemental-operator version
41
- * @param any store
42
- * @param any alreadyInstalledApps
42
+ * @param any Vue store
43
43
* @returns Promise<string | void>
44
44
*/
45
45
export async function getOperatorVersion ( store : any ) : Promise < string | void > {
@@ -54,26 +54,23 @@ export async function getOperatorVersion(store: any): Promise<string | void> {
54
54
}
55
55
56
56
/**
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
62
63
*/
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 ) ) ;
67
67
68
- return { } ;
69
- }
68
+ if ( ! gatedFeature ?. minOperatorVersion || ! operatorVersion ) {
69
+ return false ;
70
+ }
70
71
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 ;
79
76
}
0 commit comments