@@ -4,6 +4,7 @@ import { Banner } from '@components/Banner';
44import AsyncButton from ' @shell/components/AsyncButton' ;
55import { randomStr , CHARSET } from ' @shell/utils/string' ;
66import { ELEMENTAL_SCHEMA_IDS } from ' ../config/elemental-types' ;
7+ import { getOperatorVersion , checkGatedFeatureCompatibility , BUILD_MEDIA_RAW_SUPPORT } from ' ../utils/feature-versioning' ;
78
89const MEDIA_TYPES = {
910 RAW : {
@@ -38,17 +39,28 @@ export default {
3839 registrationEndpoint: {
3940 type: String ,
4041 default: ' '
42+ },
43+ resource: {
44+ type: String ,
45+ default: ' '
46+ },
47+ mode: {
48+ type: String ,
49+ default: ' '
4150 }
4251 },
4352 async fetch () {
4453 this .seedImagesList = await this .$store .dispatch (' management/findAll' , { type: ELEMENTAL_SCHEMA_IDS .SEED_IMAGE });
4554 this .managedOsVersions = await this .$store .dispatch (' management/findAll' , { type: ELEMENTAL_SCHEMA_IDS .MANAGED_OS_VERSIONS });
55+
56+ this .operatorVersion = await getOperatorVersion (this .$store );
4657 },
4758 data () {
4859 return {
4960 seedImagesList: [],
5061 managedOsVersions: [],
5162 filteredManagedOsVersions: [],
63+ operatorVersion: ' ' ,
5264 buildMediaOsVersions: [],
5365 buildMediaTypes: [
5466 { label: MEDIA_TYPES .ISO .label , value: MEDIA_TYPES .ISO .type },
@@ -79,6 +91,15 @@ export default {
7991 }
8092 },
8193 computed: {
94+ isRawDiskImageBuildSupported() {
95+ const check = checkGatedFeatureCompatibility(this.resource, this.mode, BUILD_MEDIA_RAW_SUPPORT, this.operatorVersion);
96+
97+ if (!check) {
98+ this.buildMediaTypeSelected = MEDIA_TYPES.ISO.type; // eslint-disable-line vue/no-side-effects-in-computed-properties
99+ }
100+
101+ return check;
102+ },
82103 registrationEndpointsOptions() {
83104 const activeRegEndpoints = this.registrationEndpointList.filter(item => item.state === 'active');
84105
@@ -91,10 +112,10 @@ export default {
91112 },
92113 isBuildMediaBtnEnabled() {
93114 if (this.displayRegEndpoints) {
94- return this.registrationEndpointSelected && this.buildMediaOsVersionSelected && this.buildMediaTypeSelected;
115+ return this.isRawDiskImageBuildSupported ? this. registrationEndpointSelected && this.buildMediaOsVersionSelected && this.buildMediaTypeSelected : this.registrationEndpointSelected && this.buildMediaOsVersionSelected ;
95116 }
96117
97- return this.buildMediaOsVersionSelected && this.buildMediaTypeSelected;
118+ return this.isRawDiskImageBuildSupported ? this. buildMediaOsVersionSelected && this.buildMediaTypeSelected : this.buildMediaOsVersionSelected ;
98119 },
99120 seedImageFound() {
100121 if (this.seedImage) {
@@ -146,21 +167,26 @@ export default {
146167 const machineRegName = this.displayRegEndpoints ? this.registrationEndpointSelected.split('/')[1] : this.registrationEndpoint.split('/')[1];
147168 const machineRegNamespace = this.displayRegEndpoints ? this.registrationEndpointSelected.split('/')[0] : this.registrationEndpoint.split('/')[0];
148169
149- const seedImageModel = await this.$store.dispatch('management/create', {
170+ const seedImageObject = {
150171 metadata: {
151172 name: ` media- image- reg- ${ machineRegName }- ${ randomStr (8 , CHARSET .ALPHA_LOWER ) }` ,
152173 namespace: 'fleet-default'
153174 },
154175 spec: {
155- type: this.buildMediaTypeSelected,
156176 baseImage: this.buildMediaOsVersionSelected,
157177 registrationRef: {
158178 name: machineRegName,
159179 namespace: machineRegNamespace
160180 }
161181 },
162182 type: ELEMENTAL_SCHEMA_IDS.SEED_IMAGE,
163- });
183+ };
184+
185+ if (this.isRawDiskImageBuildSupported) {
186+ seedImageObject.spec.type = this.buildMediaTypeSelected;
187+ }
188+
189+ const seedImageModel = await this.$store.dispatch('management/create', seedImageObject);
164190
165191 try {
166192 this.seedImage = await seedImageModel.save({ url: ` / v1/ ${ ELEMENTAL_SCHEMA_IDS .SEED_IMAGE }` , method: 'POST' });
@@ -207,7 +233,10 @@ export default {
207233 :options="registrationEndpointsOptions"
208234 />
209235 </div>
210- <div class="col span-2">
236+ <div
237+ v-if="isRawDiskImageBuildSupported"
238+ class="col span-2"
239+ >
211240 <LabeledSelect
212241 v-model="buildMediaTypeSelected"
213242 class="mr-20"
0 commit comments