@@ -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