Skip to content
This repository was archived by the owner on Jan 20, 2021. It is now read-only.

Commit b40cd8b

Browse files
committed
Fixing ip tabs
1 parent c14e4cf commit b40cd8b

2 files changed

Lines changed: 57 additions & 43 deletions

File tree

src/components/view/ResourceView.vue

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -113,27 +113,8 @@ export default {
113113
this.activeTab = key
114114
},
115115
showTab (tab) {
116-
if ('networkServiceFilter' in tab) {
117-
if (this.resource && this.resource.virtualmachineid && !this.resource.vpcid && tab.name !== 'firewall') {
118-
return false
119-
}
120-
if (this.resource && this.resource.virtualmachineid && this.resource.vpcid) {
121-
return false
122-
}
123-
// dont display any option for source NAT IP of VPC
124-
if (this.resource && this.resource.vpcid && !this.resource.issourcenat && tab.name !== 'firewall') {
125-
return true
126-
}
127-
// display LB and PF options for isolated networks if static nat is disabled
128-
if (this.resource && !this.resource.vpcid) {
129-
if (!this.resource.isstaticnat) {
130-
return true
131-
} else if (tab.name === 'firewall') {
132-
return true
133-
}
134-
}
135-
return this.networkService && this.networkService.service &&
136-
tab.networkServiceFilter(this.networkService.service)
116+
if (this.networkService && this.networkService.service && tab.networkServiceFilter) {
117+
return tab.networkServiceFilter(this.networkService.service)
137118
} else if ('show' in tab) {
138119
return tab.show(this.resource, this.$route, this.$store.getters.userInfo)
139120
} else {

src/views/network/PublicIpResource.vue

Lines changed: 55 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ export default {
6363
tabs: [{
6464
name: 'details',
6565
component: () => import('@/components/view/DetailsTab.vue')
66+
}],
67+
defaultTabs: [{
68+
name: 'details',
69+
component: () => import('@/components/view/DetailsTab.vue')
6670
}]
6771
}
6872
},
@@ -97,39 +101,68 @@ export default {
97101
}
98102
99103
this.loading = true
100-
this.portFWRuleCount = await this.fetchPortFWRule()
104+
await this.filterTabs()
105+
await this.fetchAction()
106+
this.loading = false
107+
},
108+
async filterTabs () {
109+
// VPC IPs with source nat have only VPN
110+
if (this.resource && this.resource.vpcid && this.resource.issourcenat) {
111+
this.tabs = this.defaultTabs.concat(this.$route.meta.tabs.filter(tab => tab.name === 'vpn'))
112+
return
113+
}
114+
115+
// VPC IPs with vpnenabled have only VPN
116+
if (this.resource && this.resource.vpcid && this.resource.vpnenabled) {
117+
this.tabs = this.defaultTabs.concat(this.$route.meta.tabs.filter(tab => tab.name === 'vpn'))
118+
return
119+
}
120+
121+
// VPC IPs with static nat have nothing
122+
if (this.resource && this.resource.vpcid && this.resource.isstaticnat) {
123+
return
124+
}
125+
126+
if (this.resource && this.resource.vpcid) {
127+
// VPC IPs don't have firewall
128+
let tabs = this.$route.meta.tabs.filter(tab => tab.name !== 'firewall')
101129
102-
// disable load balancing rules only if port forwarding is enabled and
103-
// network belongs to VPC
104-
if (this.portFWRuleCount > 0 && this.resource.vpcid) {
105-
this.tabs = this.$route.meta.tabs.filter(tab => tab.name !== 'loadbalancing')
106-
} else {
130+
this.portFWRuleCount = await this.fetchPortFWRule()
107131
this.loadBalancerRuleCount = await this.fetchLoadBalancerRule()
108132
109-
// for isolated networks, display both LB and PF
110-
// for VPC they are mutually exclusive
133+
// VPC IPs with PF only have PF
134+
if (this.portFWRuleCount > 0) {
135+
tabs = this.defaultTabs.concat(this.$route.meta.tabs.filter(tab => tab.name === 'portforwarding'))
136+
}
137+
138+
// VPC IPs with LB rules only have LB
111139
if (this.loadBalancerRuleCount > 0) {
112-
this.tabs =
113-
this.resource.vpcid ? this.$route.meta.tabs.filter(tab => tab.name !== 'portforwarding') : this.$route.meta.tabs
114-
this.loading = false
115-
} else {
116-
this.tabs = this.$route.meta.tabs
140+
tabs = this.defaultTabs.concat(this.$route.meta.tabs.filter(tab => tab.name === 'loadbalancing'))
117141
}
142+
this.tabs = tabs
143+
return
118144
}
119145
120-
await this.fetchAction()
121-
this.loading = false
122-
},
123-
fetchAction () {
124-
this.actions = []
125-
if (this.$route.meta.actions) {
126-
this.actions = this.$route.meta.actions
146+
// Regular guest networks with Source Nat have everything
147+
if (this.resource && !this.resource.vpcid && this.resource.issourcenat) {
148+
this.tabs = this.$route.meta.tabs
149+
return
150+
}
151+
152+
// Regular guest networks with Static Nat only have Firewall
153+
if (this.resource && !this.resource.vpcid && this.resource.isstaticnat) {
154+
this.tabs = this.defaultTabs.concat(this.$route.meta.tabs.filter(tab => tab.name === 'firewall'))
155+
return
127156
}
128157
129-
if (this.portFWRuleCount > 0 || this.loadBalancerRuleCount > 0) {
130-
this.actions = this.actions.filter(action => action.api !== 'enableStaticNat')
158+
// Regular guest networks have all tabs
159+
if (this.resource && !this.resource.vpcid) {
160+
this.tabs = this.$route.meta.tabs
131161
}
132162
},
163+
fetchAction () {
164+
this.actions = this.$route.meta.actions || []
165+
},
133166
fetchPortFWRule () {
134167
return new Promise((resolve, reject) => {
135168
api('listPortForwardingRules', {

0 commit comments

Comments
 (0)