Skip to content

Commit eec0c8d

Browse files
committed
show backup step only when zone has offering
1 parent f850567 commit eec0c8d

File tree

2 files changed

+35
-7
lines changed

2 files changed

+35
-7
lines changed

ui/public/locales/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3069,6 +3069,7 @@
30693069
"message.backup.offering.remove": "Are you sure you want to remove Instance from backup offering and delete the backup chain?",
30703070
"message.backup.provision.instance": "Select a backup offering to assign to the Instance. You can also add one or more backup schedules for different interval types to automate backups for this Instance. Assigning a backup offering and schedules helps protect your data by enabling automated and scheduled backups.",
30713071
"message.backup.restore": "Please confirm that you want to restore the Instance backup?",
3072+
"message.backup.update.existing.schedule": "Updating existing backup schedule for the same interval type",
30723073
"message.cancel.shutdown": "Please confirm that you would like to cancel the shutdown on this Management Server. It will resume accepting any new Async Jobs.",
30733074
"message.cancel.maintenance": "Please confirm that you would like to cancel the maintenance on this Management Server. It will resume accepting any new Async Jobs.",
30743075
"message.certificate.upload.processing": "Certificate upload in progress",

ui/src/views/compute/DeployVM.vue

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@
541541
</template>
542542
</a-step>
543543
<a-step
544-
v-if="isUserAllowedBackupOperations"
544+
v-if="zoneAllowsBackupOperations"
545545
:title="$t('label.backup')"
546546
:status="zoneSelected ? 'process' : 'wait'">
547547
<template #description>
@@ -1157,6 +1157,7 @@ export default {
11571157
},
11581158
externalDetailsEnabled: false,
11591159
selectedExtensionId: null,
1160+
zoneAllowsBackupOperations: false,
11601161
selectedBackupOffering: null,
11611162
backupSchedules: []
11621163
}
@@ -1538,10 +1539,6 @@ export default {
15381539
},
15391540
isTemplateHypervisorExternal () {
15401541
return !!this.template && this.template.hypervisor === 'External'
1541-
},
1542-
isUserAllowedBackupOperations () {
1543-
return Boolean('listBackupOfferings' in this.$store.getters.apis) &&
1544-
Boolean('assignVirtualMachineToBackupOffering' in this.$store.getters.apis)
15451542
}
15461543
},
15471544
watch: {
@@ -3014,6 +3011,31 @@ export default {
30143011
this.updateTemplateKey()
30153012
this.formModel = toRaw(this.form)
30163013
},
3014+
async updateZoneAllowsBackupOperations () {
3015+
this.zoneAllowsBackupOperations = false
3016+
if (!this.zoneId) {
3017+
return
3018+
}
3019+
if (!('listBackupOfferings' in this.$store.getters.apis) ||
3020+
!('assignVirtualMachineToBackupOffering' in this.$store.getters.apis)) {
3021+
return
3022+
}
3023+
const params = {
3024+
zoneid: this.zoneId,
3025+
issystem: false,
3026+
listall: true,
3027+
page: 1,
3028+
pageSize: 1
3029+
}
3030+
try {
3031+
const response = await getAPI('listBackupOfferings', params)
3032+
const backupOfferings = response.listbackupofferingsresponse.backupoffering || []
3033+
this.zoneAllowsBackupOperations = backupOfferings.length > 0
3034+
} catch (error) {
3035+
console.error('Error fetching backup offerings:', error)
3036+
this.zoneAllowsBackupOperations = false
3037+
}
3038+
},
30173039
onSelectZoneId (value) {
30183040
if (this.dataPreFill.zoneid !== value) {
30193041
this.dataPreFill = {}
@@ -3040,7 +3062,9 @@ export default {
30403062
this.resetIsosList()
30413063
this.imageType = this.queryIsoId ? 'isoid' : 'templateid'
30423064
this.form.backupofferingid = undefined
3065+
this.selectedBackupOffering = null
30433066
this.fetchZoneOptions()
3067+
this.updateZoneAllowsBackupOperations()
30443068
},
30453069
onSelectPodId (value) {
30463070
this.podId = value
@@ -3450,14 +3474,17 @@ export default {
34503474
// This is in accordance with the API behavior that only one schedule per intervaltype is allowed
34513475
const existingIndex = this.backupSchedules.findIndex(item => item.intervaltype === schedule.intervaltype)
34523476
if (existingIndex !== -1) {
3453-
message.warning({ content: this.$t('Updating existing backup schedule for the same interval type') + ' ' + schedule.intervaltype, duration: 3 })
3477+
message.warning({
3478+
content: this.$t('message.backup.update.existing.schedule') + ' ' + schedule.intervaltype,
3479+
duration: 2
3480+
})
34543481
this.backupSchedules.splice(existingIndex, 1, schedule)
34553482
return
34563483
}
34573484
this.backupSchedules.push(schedule)
34583485
},
34593486
async performPostDeployBackupActions (vm) {
3460-
if (!this.isUserAllowedBackupOperations) {
3487+
if (!this.zoneAllowsBackupOperations) {
34613488
return
34623489
}
34633490
const assigned = await this.assignVirtualMachineToBackupOfferingIfNeeded(vm)

0 commit comments

Comments
 (0)