mirror of https://github.com/apache/cloudstack.git
ui: simplify code using optional chaining in the zone view (#5626)
This commit is contained in:
parent
d8d5665903
commit
7791b3c10c
|
|
@ -130,10 +130,10 @@ export default {
|
|||
},
|
||||
computed: {
|
||||
zoneType () {
|
||||
return this.prefillContent.zoneType ? this.prefillContent.zoneType.value : null
|
||||
return this.prefillContent.zoneType?.value || null
|
||||
},
|
||||
hypervisor () {
|
||||
return this.prefillContent.hypervisor ? this.prefillContent.hypervisor.value : null
|
||||
return this.prefillContent.hypervisor?.value || null
|
||||
},
|
||||
localstorageenabled () {
|
||||
return this.prefillContent?.localstorageenabled?.value || false
|
||||
|
|
@ -143,7 +143,7 @@ export default {
|
|||
},
|
||||
steps () {
|
||||
const steps = []
|
||||
const hypervisor = this.prefillContent.hypervisor ? this.prefillContent.hypervisor.value : null
|
||||
const hypervisor = this.prefillContent.hypervisor?.value || null
|
||||
steps.push({
|
||||
title: 'label.cluster',
|
||||
fromKey: 'clusterResource',
|
||||
|
|
@ -713,7 +713,7 @@ export default {
|
|||
}
|
||||
},
|
||||
created () {
|
||||
this.currentStep = this.prefillContent.resourceStep ? this.prefillContent.resourceStep : 0
|
||||
this.currentStep = this.prefillContent.resourceStep?.resourceStep || 0
|
||||
if (this.stepChild && this.stepChild !== '') {
|
||||
this.currentStep = this.steps.findIndex(item => item.fromKey === this.stepChild)
|
||||
}
|
||||
|
|
@ -791,7 +791,7 @@ export default {
|
|||
}
|
||||
},
|
||||
fetchScope () {
|
||||
const hypervisor = this.prefillContent.hypervisor ? this.prefillContent.hypervisor.value : null
|
||||
const hypervisor = this.prefillContent.hypervisor?.value || null
|
||||
const scope = []
|
||||
if (['KVM', 'VMware', 'Hyperv'].includes(hypervisor)) {
|
||||
scope.push({
|
||||
|
|
@ -812,7 +812,7 @@ export default {
|
|||
this.$forceUpdate()
|
||||
},
|
||||
fetchProtocol () {
|
||||
const hypervisor = this.prefillContent.hypervisor ? this.prefillContent.hypervisor.value : null
|
||||
const hypervisor = this.prefillContent.hypervisor?.value || null
|
||||
const protocols = []
|
||||
if (hypervisor === 'KVM') {
|
||||
protocols.push({
|
||||
|
|
@ -903,7 +903,7 @@ export default {
|
|||
this.$forceUpdate()
|
||||
},
|
||||
async fetchConfigurationSwitch () {
|
||||
const hypervisor = this.prefillContent.hypervisor ? this.prefillContent.hypervisor.value : null
|
||||
const hypervisor = this.prefillContent.hypervisor?.value || null
|
||||
this.$emit('fieldsChanged', { dvSwitchEnabled: { value: false } })
|
||||
this.$emit('fieldsChanged', { vSwitchEnabled: { value: false } })
|
||||
if (hypervisor && hypervisor === 'VMware') {
|
||||
|
|
|
|||
|
|
@ -148,13 +148,13 @@ export default {
|
|||
},
|
||||
computed: {
|
||||
zoneType () {
|
||||
return this.prefillContent.zoneType ? this.prefillContent.zoneType.value : null
|
||||
return this.prefillContent.zoneType?.value || null
|
||||
},
|
||||
sgEnabled () {
|
||||
return this.prefillContent.securityGroupsEnabled ? this.prefillContent.securityGroupsEnabled.value : false
|
||||
return this.prefillContent.securityGroupsEnabled?.value || false
|
||||
},
|
||||
havingNetscaler () {
|
||||
return this.prefillContent.networkOfferingSelected ? this.prefillContent.networkOfferingSelected.havingNetscaler : false
|
||||
return this.prefillContent.networkOfferingSelected?.havingNetscaler || false
|
||||
},
|
||||
guestTrafficRangeMode () {
|
||||
return this.zoneType === 'Basic' ||
|
||||
|
|
@ -372,7 +372,7 @@ export default {
|
|||
created () {
|
||||
this.physicalNetworks = this.prefillContent.physicalNetworks
|
||||
this.steps = this.filteredSteps()
|
||||
this.currentStep = this.prefillContent.networkStep ? this.prefillContent.networkStep : 0
|
||||
this.currentStep = this.prefillContent?.networkStep || 0
|
||||
if (this.stepChild && this.stepChild !== '') {
|
||||
this.currentStep = this.steps.findIndex(item => item.formKey === this.stepChild)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -287,10 +287,10 @@ export default {
|
|||
return this.zoneType === 'Advanced'
|
||||
},
|
||||
zoneType () {
|
||||
return this.prefillContent.zoneType ? this.prefillContent.zoneType.value : null
|
||||
return this.prefillContent.zoneType?.value || null
|
||||
},
|
||||
securityGroupsEnabled () {
|
||||
return this.isAdvancedZone && (this.prefillContent.securityGroupsEnabled ? this.prefillContent.securityGroupsEnabled.value : false)
|
||||
return this.isAdvancedZone && (this.prefillContent.securityGroupsEnabled?.value || false)
|
||||
},
|
||||
networkOfferingSelected () {
|
||||
return this.prefillContent.networkOfferingSelected
|
||||
|
|
|
|||
|
|
@ -382,8 +382,8 @@ export default {
|
|||
ipV6Regex: /^((([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(([0-9A-Fa-f]{1,4}:){0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))$/i
|
||||
}),
|
||||
created () {
|
||||
this.hypervisors = this.prefillContent.hypervisors ? this.prefillContent.hypervisors : null
|
||||
this.networkOfferings = this.prefillContent.networkOfferings ? this.prefillContent.networkOfferings : null
|
||||
this.hypervisors = this.prefillContent.hypervisors?.hypervisors || null
|
||||
this.networkOfferings = this.prefillContent?.networkOfferings || null
|
||||
this.form = this.$form.createForm(this, {
|
||||
onFieldsChange: (_, changedFields) => {
|
||||
if (changedFields.networkOfferingId && this.prefillContent.networkOfferingSelected) {
|
||||
|
|
@ -433,37 +433,37 @@ export default {
|
|||
return this.zoneType === 'Advanced'
|
||||
},
|
||||
zoneType () {
|
||||
return this.prefillContent.zoneType ? this.prefillContent.zoneType.value : null
|
||||
return this.prefillContent.zoneType?.value || null
|
||||
},
|
||||
securityGroupsEnabled () {
|
||||
return this.isAdvancedZone && (this.prefillContent.securityGroupsEnabled ? this.prefillContent.securityGroupsEnabled.value : false)
|
||||
return this.isAdvancedZone && (this.prefillContent.securityGroupsEnabled?.value || false)
|
||||
},
|
||||
name () {
|
||||
return this.prefillContent.name ? this.prefillContent.name.value : null
|
||||
return this.prefillContent.name?.value || null
|
||||
},
|
||||
ipv4Dns1 () {
|
||||
return this.prefillContent.ipv4Dns1 ? this.prefillContent.ipv4Dns1.value : null
|
||||
return this.prefillContent.ipv4Dns1?.value || null
|
||||
},
|
||||
ipv4Dns2 () {
|
||||
return this.prefillContent.ipv4Dns2 ? this.prefillContent.ipv4Dns2.value : null
|
||||
return this.prefillContent.ipv4Dns2?.value || null
|
||||
},
|
||||
ipv6Dns1 () {
|
||||
return this.prefillContent.ipv6Dns1 ? this.prefillContent.ipv6Dns1.value : null
|
||||
return this.prefillContent.ipv6Dns1?.value || null
|
||||
},
|
||||
ipv6Dns2 () {
|
||||
return this.prefillContent.ipv6Dns2 ? this.prefillContent.ipv6Dns2.value : null
|
||||
return this.prefillContent.ipv6Dns2?.value || null
|
||||
},
|
||||
internalDns1 () {
|
||||
return this.prefillContent.internalDns1 ? this.prefillContent.internalDns1.value : null
|
||||
return this.prefillContent.internalDns1?.value || null
|
||||
},
|
||||
internalDns2 () {
|
||||
return this.prefillContent.internalDns2 ? this.prefillContent.internalDns2.value : null
|
||||
return this.prefillContent.internalDns2?.value || null
|
||||
},
|
||||
ipv6Cidr () {
|
||||
return this.prefillContent.ipv6Cidr ? this.prefillContent.ipv6Cidr.value : null
|
||||
return this.prefillContent.ipv6Cidr?.value || null
|
||||
},
|
||||
ip6gateway () {
|
||||
return this.prefillContent.ip6gateway ? this.prefillContent.ip6gateway.value : null
|
||||
return this.prefillContent.ip6gateway?.value || null
|
||||
},
|
||||
currentHypervisor () {
|
||||
if (this.prefillContent.hypervisor) {
|
||||
|
|
@ -474,7 +474,7 @@ export default {
|
|||
return null
|
||||
},
|
||||
currentNetworkOfferingId () {
|
||||
const lastNetworkOfferingId = this.prefillContent.networkOfferingSelected ? this.prefillContent.networkOfferingSelected.id : null
|
||||
const lastNetworkOfferingId = this.prefillContent.networkOfferingSelected?.id || null
|
||||
if (this.networkOfferings) {
|
||||
if (lastNetworkOfferingId !== null && this.networkOfferings[lastNetworkOfferingId]) {
|
||||
return lastNetworkOfferingId
|
||||
|
|
@ -484,29 +484,29 @@ export default {
|
|||
return null
|
||||
},
|
||||
networkDomain () {
|
||||
return this.prefillContent.networkDomain ? this.prefillContent.networkDomain.value : null
|
||||
return this.prefillContent.networkDomain?.value || null
|
||||
},
|
||||
guestcidraddress () {
|
||||
return this.prefillContent.guestcidraddress ? this.prefillContent.guestcidraddress.value : '10.1.1.0/24'
|
||||
return this.prefillContent.guestcidraddress?.value || '10.1.1.0/24'
|
||||
},
|
||||
isDedicated () {
|
||||
return this.prefillContent.isDedicated ? this.prefillContent.isDedicated.value : false
|
||||
return this.prefillContent.isDedicated?.value || false
|
||||
},
|
||||
domain () {
|
||||
const lastDomainId = this.prefillContent.domainId ? this.prefillContent.domainId.value : null
|
||||
const lastDomainId = this.prefillContent.domainId?.value || null
|
||||
if (this.domains !== null && lastDomainId !== null && this.domains[lastDomainId]) {
|
||||
return lastDomainId
|
||||
}
|
||||
return null
|
||||
},
|
||||
account () {
|
||||
return this.prefillContent.account ? this.prefillContent.account.value : null
|
||||
return this.prefillContent.account?.value || null
|
||||
},
|
||||
localstorageenabled () {
|
||||
return this.prefillContent.localstorageenabled ? this.prefillContent.localstorageenabled.value : false
|
||||
return this.prefillContent.localstorageenabled?.value || false
|
||||
},
|
||||
localstorageenabledforsystemvm () {
|
||||
return this.prefillContent.localstorageenabledforsystemvm ? this.prefillContent.localstorageenabledforsystemvm.value : false
|
||||
return this.prefillContent.localstorageenabledforsystemvm?.value || false
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
|
|
|||
Loading…
Reference in New Issue