|
62 | 62 | </a-select-option> |
63 | 63 | </a-select> |
64 | 64 | </a-form-item> |
| 65 | + <ownership-selection v-if="isAdminOrDomainAdmin()" @fetch-owner="fetchOwnerOptions"/> |
65 | 66 | <a-form-item name="cidr" ref="cidr" v-if="selectedVpcOffering && (selectedVpcOffering.networkmode !== 'ROUTED' || isAdmin())"> |
66 | 67 | <template #label> |
67 | 68 | <tooltip-label :title="$t('label.cidr')" :tooltip="apiParams.cidr.description"/> |
|
210 | 211 | <script> |
211 | 212 | import { ref, reactive, toRaw } from 'vue' |
212 | 213 | import { api } from '@/api' |
213 | | -import { isAdmin } from '@/role' |
| 214 | +import { isAdmin, isAdminOrDomainAdmin } from '@/role' |
214 | 215 | import ResourceIcon from '@/components/view/ResourceIcon' |
215 | 216 | import TooltipLabel from '@/components/widgets/TooltipLabel' |
| 217 | +import OwnershipSelection from '@/views/compute/wizard/OwnershipSelection.vue' |
216 | 218 |
|
217 | 219 | export default { |
218 | 220 | name: 'CreateVpc', |
219 | 221 | components: { |
| 222 | + OwnershipSelection, |
220 | 223 | ResourceIcon, |
221 | 224 | TooltipLabel |
222 | 225 | }, |
@@ -267,6 +270,7 @@ export default { |
267 | 270 | } |
268 | 271 | }, |
269 | 272 | methods: { |
| 273 | + isAdminOrDomainAdmin, |
270 | 274 | initForm () { |
271 | 275 | this.formRef = ref() |
272 | 276 | this.form = reactive({ |
@@ -359,6 +363,28 @@ export default { |
359 | 363 | } |
360 | 364 | }) |
361 | 365 | }, |
| 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 | + }, |
362 | 388 | handleVpcOfferingChange (value) { |
363 | 389 | this.selectedVpcOffering = {} |
364 | 390 | if (!value) { |
@@ -398,7 +424,14 @@ export default { |
398 | 424 | if (this.loading) return |
399 | 425 | this.formRef.value.validate().then(() => { |
400 | 426 | 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 | + } |
402 | 435 | for (const key in values) { |
403 | 436 | const input = values[key] |
404 | 437 | if (input === '' || input === null || input === undefined) { |
|
0 commit comments