From e230341a05a1fd27cb222f006f77620e92c0520e Mon Sep 17 00:00:00 2001 From: Brian Federle Date: Wed, 14 Dec 2011 11:31:36 -0800 Subject: [PATCH] bug 12542 Add action pre-filter to add network action -- if guest network is present and zone is basic, pop up a notice message and prevent dialog from appearing status 12542: resolved fixed --- ui/scripts/system.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/ui/scripts/system.js b/ui/scripts/system.js index d04f61f8cc5..16cc810527b 100644 --- a/ui/scripts/system.js +++ b/ui/scripts/system.js @@ -853,6 +853,37 @@ }); }, + preAction: function(args) { + var zone = $('.detail-view:last').data('view-args').context.zones[0]; + var networksPresent = false; + + // Only 1 guest network is allowed per basic zone, + // so don't show the dialog in this case + $.ajax({ + url: createURL('listNetworks'), + data: { + trafficType: 'guest', + zoneId: zone.id + }, + async: false, + success: function(json) { + if (json.listnetworksresponse.network) { + networksPresent = true; + } + } + }); + + if (zone.networktype == 'Basic' && networksPresent) { + cloudStack.dialog.notice({ + message: 'Sorry, you can only have one guest network for a basic zone.' + }); + + return false; + } + + return true; + }, + notification: { poll: function(args) { args.complete();