|
376 | 376 | sectionSelect: { |
377 | 377 | preFilter: function(args) { |
378 | 378 | var sectionsToShow = ['networks']; |
| 379 | + var securityGroupsEnabledFound = false; //Until we found a zone where securitygroupsenabled is true. |
379 | 380 |
|
| 381 | + //This call to show VPC and VPN Customer Gateway sections, if zone is advanced. |
380 | 382 | $.ajax({ |
381 | 383 | url: createURL('listZones'), |
382 | 384 | data: { |
383 | 385 | networktype: 'Advanced' |
384 | 386 | }, |
385 | 387 | async: false, |
386 | 388 | success: function(json) { |
387 | | - advZoneObjs = json.listzonesresponse.zone; |
| 389 | + advZoneObjs = json.listzonesresponse ? json.listzonesresponse.zone : null; |
388 | 390 | if (advZoneObjs != null && advZoneObjs.length > 0) { |
389 | 391 | sectionsToShow.push('vpc'); |
390 | 392 | sectionsToShow.push('vpnCustomerGateway'); |
| 393 | + |
| 394 | + //At the same time check if any advanced zone has securitygroupsenabled is true. |
| 395 | + //If so, show Security Group section. |
| 396 | + for (var i = 0; (i < advZoneObjs.length) && !securityGroupsEnabledFound; i++) { |
| 397 | + if (advZoneObjs[i].securitygroupsenabled) { |
| 398 | + securityGroupsEnabledFound = true; |
| 399 | + sectionsToShow.push('securityGroups'); |
| 400 | + } |
| 401 | + } |
391 | 402 | } |
392 | 403 | } |
393 | 404 | }); |
394 | 405 |
|
395 | | - $.ajax({ |
396 | | - url: createURL('listNetworks', { |
397 | | - ignoreProject: true |
398 | | - }), |
399 | | - data: { |
400 | | - supportedServices: 'SecurityGroup', |
401 | | - listAll: true |
402 | | - }, |
403 | | - async: false, |
404 | | - success: function(json) { |
405 | | - if (json.listnetworksresponse.network != null && json.listnetworksresponse.network.length > 0) { |
406 | | - sectionsToShow.push('securityGroups'); |
| 406 | + //If we didn't find any advanced zone whose securitygroupsenabled is true. |
| 407 | + //Search in all Basic zones. |
| 408 | + if (!securityGroupsEnabledFound) { |
| 409 | + $.ajax({ |
| 410 | + url: createURL('listZones'), |
| 411 | + data: { |
| 412 | + networktype: 'Basic' |
| 413 | + }, |
| 414 | + async: false, |
| 415 | + success: function(json) { |
| 416 | + var basicZoneObjs = json.listzonesresponse ? json.listzonesresponse.zone : null; |
| 417 | + if (basicZoneObjs != null && basicZoneObjs.length > 0) { |
| 418 | + sectionsToShow.push('securityGroups'); |
| 419 | + } |
407 | 420 | } |
408 | | - } |
409 | | - }); |
| 421 | + }); |
| 422 | + } |
410 | 423 |
|
411 | 424 | return sectionsToShow; |
412 | 425 | }, |
|
0 commit comments