145145 centered
146146 width =" 450px" >
147147 <a-spin :spinning =" acquireLoading" v-ctrl-enter =" acquireIpAddress" >
148- <a-alert :message =" $t('message.action.acquire.ip')" type =" warning" />
148+ <div v-if =" $route.path.startsWith('/vpc') && !isNormalUserOrProject()" >
149+ <ownership-selection :override =" possibleOwnership" @fetch-owner =" fetchOwnerOptions" />
150+ </div >
149151 <a-form layout =" vertical" style =" margin-top : 10px " >
150152 <a-form-item :label =" $t('label.ipaddress')" >
151153 <infinite-scroll-select
160162 :autoSelectFirstOption =" true"
161163 @change-option-value =" (ip) => acquireIp = ip" />
162164 </a-form-item >
165+ <a-alert :message =" $t('message.action.acquire.ip')" type =" warning" />
163166 <div :span =" 24" class =" action-button" >
164167 <a-button @click =" onCloseModal" >{{ $t('label.cancel') }}</a-button >
165168 <a-button ref =" submit" type =" primary" @click =" acquireIpAddress" >{{ $t('label.ok') }}</a-button >
@@ -210,14 +213,16 @@ import TooltipButton from '@/components/widgets/TooltipButton'
210213import BulkActionView from ' @/components/view/BulkActionView'
211214import eventBus from ' @/config/eventBus'
212215import InfiniteScrollSelect from ' @/components/widgets/InfiniteScrollSelect'
216+ import OwnershipSelection from ' @/views/compute/wizard/OwnershipSelection.vue'
213217
214218export default {
215219 name: ' IpAddressesTab' ,
216220 components: {
217221 Status,
218222 TooltipButton,
219223 BulkActionView,
220- InfiniteScrollSelect
224+ InfiniteScrollSelect,
225+ OwnershipSelection
221226 },
222227 props: {
223228 resource: {
@@ -281,7 +286,12 @@ export default {
281286 acquireLoading: false ,
282287 acquireIp: null ,
283288 changeSourceNat: false ,
284- zoneExtNetProvider: ' '
289+ zoneExtNetProvider: ' ' ,
290+ possibleOwnership: {
291+ domains: null ,
292+ projects: null ,
293+ accounts: null
294+ }
285295 }
286296 },
287297 async created () {
@@ -321,6 +331,9 @@ export default {
321331 }
322332 },
323333 methods: {
334+ isNormalUserOrProject () {
335+ return [' User' ].includes (this .$store .getters .userInfo .roletype ) || this .$store .getters .project ? .id
336+ },
324337 fetchData () {
325338 const params = {
326339 listall: true ,
@@ -334,6 +347,7 @@ export default {
334347 if (this .vpcTier ) {
335348 params .associatednetworkid = this .vpcTier
336349 }
350+ this .getAvailableOwnersForIP ()
337351 } else if (this .resource .type === ' Shared' ) {
338352 params .networkid = this .resource .id
339353 params .allocatedonly = false
@@ -362,13 +376,20 @@ export default {
362376 }).catch (reject)
363377 })
364378 },
365- fetchListPublicIpAddress (state ) {
366- return new Promise ((resolve , reject ) => {
367- getAPI (' listPublicIpAddresses' , this .listApiParams ).then (json => {
368- const listPublicIps = json .listpublicipaddressesresponse .publicipaddress || []
369- resolve (listPublicIps)
370- }).catch (reject)
371- })
379+ fetchOwnerOptions (OwnerOptions ) {
380+ this .owner = {}
381+ if (OwnerOptions .selectedAccountType === this .$t (' label.account' )) {
382+ if (! OwnerOptions .selectedAccount ) {
383+ return
384+ }
385+ this .owner .account = OwnerOptions .selectedAccount
386+ this .owner .domainid = OwnerOptions .selectedDomain
387+ } else if (OwnerOptions .selectedAccountType === this .$t (' label.project' )) {
388+ if (! OwnerOptions .selectedProject ) {
389+ return
390+ }
391+ this .owner .projectid = OwnerOptions .selectedProject
392+ }
372393 },
373394 handleTierSelect (tier ) {
374395 this .vpcTier = tier
@@ -453,6 +474,11 @@ export default {
453474 const params = {}
454475 if (this .$route .path .startsWith (' /vpc' )) {
455476 params .vpcid = this .resource .id
477+ if (this .owner ) {
478+ params .domainid = this .owner .domainid
479+ params .account = this .owner .projectid ? null : this .owner .account
480+ params .projectid = this .owner .projectid ? this .owner .projectid : null
481+ }
456482 if (this .vpcTier ) {
457483 params .networkid = this .vpcTier
458484 }
@@ -560,6 +586,20 @@ export default {
560586 default : return ' /vm/'
561587 }
562588 },
589+ getAvailableOwnersForIP () {
590+ this .possibleOwnership .domains = new Set ([this .resource .domainid ])
591+ this .possibleOwnership .projects = this .resource .projectid ? new Set ([this .resource .projectid ]) : new Set ([])
592+ this .possibleOwnership .accounts = this .resource .projectid ? new Set ([]) : new Set ([this .resource .account ])
593+
594+ this .resource .network .forEach (network => {
595+ this .possibleOwnership .domains .add (network .domainid )
596+ if (network .projectid ) {
597+ this .possibleOwnership .projects .add (network .projectid )
598+ } else {
599+ this .possibleOwnership .accounts .add (network .account )
600+ }
601+ })
602+ },
563603 async onShowAcquireIp () {
564604 this .showAcquireIp = true
565605 },
0 commit comments