Skip to content

Commit 0b2952c

Browse files
committed
Merge release branch 4.20 to main
* 4.20: Add ownership selection to VPC form (#10124)
2 parents ee893d1 + cbac6cc commit 0b2952c

File tree

1 file changed

+35
-2
lines changed

1 file changed

+35
-2
lines changed

ui/src/views/network/CreateVpc.vue

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
</a-select-option>
6363
</a-select>
6464
</a-form-item>
65+
<ownership-selection v-if="isAdminOrDomainAdmin()" @fetch-owner="fetchOwnerOptions"/>
6566
<a-form-item name="cidr" ref="cidr" v-if="selectedVpcOffering && (selectedVpcOffering.networkmode !== 'ROUTED' || isAdmin())">
6667
<template #label>
6768
<tooltip-label :title="$t('label.cidr')" :tooltip="apiParams.cidr.description"/>
@@ -210,13 +211,15 @@
210211
<script>
211212
import { ref, reactive, toRaw } from 'vue'
212213
import { api } from '@/api'
213-
import { isAdmin } from '@/role'
214+
import { isAdmin, isAdminOrDomainAdmin } from '@/role'
214215
import ResourceIcon from '@/components/view/ResourceIcon'
215216
import TooltipLabel from '@/components/widgets/TooltipLabel'
217+
import OwnershipSelection from '@/views/compute/wizard/OwnershipSelection.vue'
216218
217219
export default {
218220
name: 'CreateVpc',
219221
components: {
222+
OwnershipSelection,
220223
ResourceIcon,
221224
TooltipLabel
222225
},
@@ -267,6 +270,7 @@ export default {
267270
}
268271
},
269272
methods: {
273+
isAdminOrDomainAdmin,
270274
initForm () {
271275
this.formRef = ref()
272276
this.form = reactive({
@@ -359,6 +363,28 @@ export default {
359363
}
360364
})
361365
},
366+
fetchOwnerOptions (OwnerOptions) {
367+
this.owner = {
368+
projectid: null,
369+
domainid: this.$store.getters.userInfo.domainid,
370+
account: this.$store.getters.userInfo.account
371+
}
372+
if (OwnerOptions.selectedAccountType === 'Account') {
373+
if (!OwnerOptions.selectedAccount) {
374+
return
375+
}
376+
this.owner.account = OwnerOptions.selectedAccount
377+
this.owner.domainid = OwnerOptions.selectedDomain
378+
this.owner.projectid = null
379+
} else if (OwnerOptions.selectedAccountType === 'Project') {
380+
if (!OwnerOptions.selectedProject) {
381+
return
382+
}
383+
this.owner.account = null
384+
this.owner.domainid = null
385+
this.owner.projectid = OwnerOptions.selectedProject
386+
}
387+
},
362388
handleVpcOfferingChange (value) {
363389
this.selectedVpcOffering = {}
364390
if (!value) {
@@ -398,7 +424,14 @@ export default {
398424
if (this.loading) return
399425
this.formRef.value.validate().then(() => {
400426
const values = toRaw(this.form)
401-
const params = {}
427+
var params = {}
428+
if (this.owner?.account) {
429+
params.account = this.owner.account
430+
params.domainid = this.owner.domainid
431+
} else if (this.owner?.projectid) {
432+
params.domainid = this.owner.domainid
433+
params.projectid = this.owner.projectid
434+
}
402435
for (const key in values) {
403436
const input = values[key]
404437
if (input === '' || input === null || input === undefined) {

0 commit comments

Comments
 (0)