From 310b24b285c53b4f58cc47981cce2693b48cbe9f Mon Sep 17 00:00:00 2001 From: Brian Federle Date: Tue, 7 Aug 2012 15:43:02 -0700 Subject: [PATCH] List view: support external link actions Support actions which point to an external link, primary to support launching the console proxy. Example: listView: { actions: { viewConsole: { label: 'label.view.console', action: { externalLink: { url: function(args) { return clientConsoleUrl + '?cmd=access&vm=' + args.context.vpcTierInstances[0].id; }, title: function(args) { return args.context.vpcTierInstances[0].id.substr(0,8); }, width: 820, height: 640 } } } } } --- ui/scripts/ui/widgets/listView.js | 45 ++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/ui/scripts/ui/widgets/listView.js b/ui/scripts/ui/widgets/listView.js index 0a1d093743f..b9382542424 100644 --- a/ui/scripts/ui/widgets/listView.js +++ b/ui/scripts/ui/widgets/listView.js @@ -66,7 +66,26 @@ listViewArgs.activeSection ] = [$instanceRow.data('jsonObj')]; - if (action.custom && !action.noAdd) { + var externalLinkAction = action.externalLink; + if (externalLinkAction) { + // Show popup immediately, do not proceed through normal action process + window.open( + // URL + externalLinkAction.url({ + context: context + }), + + // Title + externalLinkAction.title({ + context: context + }), + + // Window options + 'menubar=0,resizable=0,' + + 'width=' + externalLinkAction.width + ',' + + 'height=' + externalLinkAction.height + ); + } else if (action.custom && !action.noAdd) { action.custom({ data: data, ref: options.ref, @@ -254,7 +273,8 @@ listViewArgs.activeSection ] = [$instanceRow.data('jsonObj')]; - if (!args.action.createForm && + if (!args.action.action.externalLink && + !args.action.createForm && args.action.addRow != 'true' && !action.custom && !action.uiCustom) cloudStack.dialog.confirm({ @@ -274,7 +294,26 @@ var isHeader = args.action.isHeader; var createFormContext = $.extend({}, context); - if (args.action.createForm) { + var externalLinkAction = action.externalLink; + if (externalLinkAction) { + // Show popup immediately, do not proceed through normal action process + window.open( + // URL + externalLinkAction.url({ + context: context + }), + + // Title + externalLinkAction.title({ + context: context + }), + + // Window options + 'menubar=0,resizable=0,' + + 'width=' + externalLinkAction.width + ',' + + 'height=' + externalLinkAction.height + ); + } else if (args.action.createForm) { cloudStack.dialog.createForm({ form: args.action.createForm, after: function(args) {