Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 35 additions & 2 deletions ui/src/views/network/CreateVpc.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
</a-select-option>
</a-select>
</a-form-item>
<ownership-selection v-if="isAdminOrDomainAdmin()" @fetch-owner="fetchOwnerOptions"/>
<a-form-item name="cidr" ref="cidr" v-if="selectedVpcOffering && (selectedVpcOffering.networkmode !== 'ROUTED' || isAdmin())">
<template #label>
<tooltip-label :title="$t('label.cidr')" :tooltip="apiParams.cidr.description"/>
Expand Down Expand Up @@ -210,13 +211,15 @@
<script>
import { ref, reactive, toRaw } from 'vue'
import { api } from '@/api'
import { isAdmin } from '@/role'
import { isAdmin, isAdminOrDomainAdmin } from '@/role'
import ResourceIcon from '@/components/view/ResourceIcon'
import TooltipLabel from '@/components/widgets/TooltipLabel'
import OwnershipSelection from '@/views/compute/wizard/OwnershipSelection.vue'

export default {
name: 'CreateVpc',
components: {
OwnershipSelection,
ResourceIcon,
TooltipLabel
},
Expand Down Expand Up @@ -267,6 +270,7 @@ export default {
}
},
methods: {
isAdminOrDomainAdmin,
initForm () {
this.formRef = ref()
this.form = reactive({
Expand Down Expand Up @@ -359,6 +363,28 @@ export default {
}
})
},
fetchOwnerOptions (OwnerOptions) {
this.owner = {
projectid: null,
domainid: this.$store.getters.userInfo.domainid,
account: this.$store.getters.userInfo.account
}
if (OwnerOptions.selectedAccountType === 'Account') {
if (!OwnerOptions.selectedAccount) {
return
}
this.owner.account = OwnerOptions.selectedAccount
this.owner.domainid = OwnerOptions.selectedDomain
this.owner.projectid = null
} else if (OwnerOptions.selectedAccountType === 'Project') {
if (!OwnerOptions.selectedProject) {
return
}
this.owner.account = null
this.owner.domainid = null
this.owner.projectid = OwnerOptions.selectedProject
}
},
handleVpcOfferingChange (value) {
this.selectedVpcOffering = {}
if (!value) {
Expand Down Expand Up @@ -398,7 +424,14 @@ export default {
if (this.loading) return
this.formRef.value.validate().then(() => {
const values = toRaw(this.form)
const params = {}
var params = {}
if (this.owner?.account) {
params.account = this.owner.account
params.domainid = this.owner.domainid
} else if (this.owner?.projectid) {
params.domainid = this.owner.domainid
params.projectid = this.owner.projectid
}
for (const key in values) {
const input = values[key]
if (input === '' || input === null || input === undefined) {
Expand Down