Skip to content

Commit c165806

Browse files
erikbocksGaOrtiga
andauthored
Fix VPC network offerings listing in isolated network creation form (#12645)
* Fix VPC network offerings listing in isolated network creation form * Apply suggestions from code review Co-authored-by: GaOrtiga <49285692+GaOrtiga@users.noreply.github.com> * Address Bernardo's review --------- Co-authored-by: GaOrtiga <49285692+GaOrtiga@users.noreply.github.com>
1 parent a7c2a05 commit c165806

3 files changed

Lines changed: 21 additions & 9 deletions

File tree

ui/public/locales/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3731,6 +3731,7 @@
37313731
"message.warn.filetype": "jpg, jpeg, png, bmp and svg are the only supported image formats.",
37323732
"message.warn.importing.instance.without.nic": "WARNING: This Instance is being imported without NICs and many Network resources will not be available. Consider creating a NIC via vCenter before importing or as soon as the Instance is imported.",
37333733
"message.warn.zone.mtu.update": "Please note that this limit won't affect pre-existing Network's MTU settings",
3734+
"message.warn.vpc.offerings": "VPC offerings will only be shown if the selected account has at least one VPC.",
37343735
"message.webhook.deliveries.time.filter": "Webhook deliveries list can be filtered based on date-time. Select 'Custom' for specifying start and end date range.",
37353736
"message.zone.creation.complete": "Zone creation complete.",
37363737
"message.zone.detail.description": "Populate Zone details.",

ui/public/locales/pt_BR.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2510,6 +2510,7 @@
25102510
"message.vr.alert.upon.network.offering.creation.others": "Como nenhum dos servi\u00e7os obrigat\u00f3rios para cria\u00e7\u00e3o do VR (VPN, DHCP, DNS, Firewall, LB, UserData, SourceNat, StaticNat, PortForwarding) foram habilitados, o VR n\u00e3o ser\u00e1 criado e a oferta de computa\u00e7\u00e3o n\u00e3o ser\u00e1 usada.",
25112511
"message.warn.filetype": "jpg, jpeg, png, bmp e svg s\u00e3o os \u00fanicos formatos de imagem suportados",
25122512
"message.warn.importing.instance.without.nic": "AVISO: essa inst\u00e2ncia est\u00e1 sendo importada sem NICs e muitos recursos de rede n\u00e3o estar\u00e3o dispon\u00edveis. Considere criar uma NIC antes de importar via VCenter ou assim que a inst\u00e2ncia for importada.",
2513+
"message.warn.vpc.offerings": "Ofertas de VPC somente ser\u00c3o exibidas caso a conta selecionada possua ao menos uma VPC.",
25132514
"message.zone.creation.complete": "Cria\u00e7\u00e3o de zona completa",
25142515
"message.zone.detail.description": "Preencha os detalhes da zona",
25152516
"message.zone.detail.hint": "Uma zona \u00e9 a maior unidade organizacional no CloudStack, e normalmente corresponde a um \u00fanico datacenter. As zonas proporcionam isolamento f\u00edsico e redund\u00e2ncia. Uma zona consiste em um ou mais pods (cada um contendo hosts e servidores de armazenamento prim\u00e1rio) e um servidor de armazenamento secund\u00e1rio que \u00e9 compartilhado por todos os pods da zona.",

ui/src/views/network/CreateIsolatedNetworkForm.vue

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,11 @@
9696
{{ opt.displaytext || opt.name || opt.description }}
9797
</a-select-option>
9898
</a-select>
99+
<a-alert type="warning" v-if="!this.hasVPC">
100+
<template #message>
101+
<span v-html="$t('message.warn.vpc.offerings')"/>
102+
</template>
103+
</a-alert>
99104
</a-form-item>
100105
<a-form-item ref="asnumber" name="asnumber" v-if="isASNumberRequired()">
101106
<template #label>
@@ -369,7 +374,8 @@ export default {
369374
setMTU: false,
370375
asNumberLoading: false,
371376
selectedAsNumber: 0,
372-
asNumbersZone: []
377+
asNumbersZone: [],
378+
hasVPC: true
373379
}
374380
},
375381
watch: {
@@ -515,13 +521,17 @@ export default {
515521
if (this.vpc !== null) { // from VPC section
516522
this.fetchNetworkOfferingData(true)
517523
} else { // from guest network section
518-
var params = {}
524+
const params = {
525+
account: this.owner.account,
526+
projectid: this.owner.projectid,
527+
domainid: this.owner.domainid
528+
}
519529
this.networkOfferingLoading = true
520530
if ('listVPCs' in this.$store.getters.apis) {
521531
api('listVPCs', params).then(json => {
522532
const listVPCs = json.listvpcsresponse.vpc
523-
var vpcAvailable = this.arrayHasItems(listVPCs)
524-
if (vpcAvailable === false) {
533+
this.hasVPC = this.arrayHasItems(listVPCs)
534+
if (!this.hasVPC) {
525535
this.fetchNetworkOfferingData(false)
526536
} else {
527537
this.fetchNetworkOfferingData()
@@ -534,7 +544,7 @@ export default {
534544
},
535545
fetchNetworkOfferingData (forVpc) {
536546
this.networkOfferingLoading = true
537-
var params = {
547+
const params = {
538548
zoneid: this.selectedZone.id,
539549
guestiptype: 'Isolated',
540550
state: 'Enabled'
@@ -577,7 +587,7 @@ export default {
577587
},
578588
fetchVpcData () {
579589
this.vpcLoading = true
580-
var params = {
590+
const params = {
581591
listAll: true,
582592
details: 'min'
583593
}
@@ -600,14 +610,14 @@ export default {
600610
const formRaw = toRaw(this.form)
601611
const values = this.handleRemoveFields(formRaw)
602612
this.actionLoading = true
603-
var params = {
613+
const params = {
604614
zoneId: this.selectedZone.id,
605615
name: values.name,
606616
displayText: values.displaytext,
607617
networkOfferingId: this.selectedNetworkOffering.id
608618
}
609-
var usefulFields = ['gateway', 'netmask', 'cidrsize', 'startip', 'startipv4', 'endip', 'endipv4', 'dns1', 'dns2', 'ip6dns1', 'ip6dns2', 'sourcenatipaddress', 'externalid', 'vpcid', 'vlan', 'networkdomain']
610-
for (var field of usefulFields) {
619+
const usefulFields = ['gateway', 'netmask', 'cidrsize', 'startip', 'startipv4', 'endip', 'endipv4', 'dns1', 'dns2', 'ip6dns1', 'ip6dns2', 'sourcenatipaddress', 'externalid', 'vpcid', 'vlan', 'networkdomain']
620+
for (const field of usefulFields) {
611621
if (this.isValidTextValueForKey(values, field)) {
612622
params[field] = values[field]
613623
}

0 commit comments

Comments
 (0)