From b332b5a4cbe39525cedb07a2b93ec29f5db89e81 Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Wed, 10 Feb 2016 12:56:20 +0100 Subject: [PATCH] Feature #4217: Add Image export action --- src/sunstone/etc/sunstone-views/admin.yaml | 1 + src/sunstone/etc/sunstone-views/user.yaml | 1 + .../public/app/tabs/images-tab/actions.js | 20 +++++++++++++++++++ .../public/app/tabs/images-tab/buttons.js | 4 ++++ .../marketplaceapps-tab/form-panels/create.js | 9 +++++++++ 5 files changed, 35 insertions(+) diff --git a/src/sunstone/etc/sunstone-views/admin.yaml b/src/sunstone/etc/sunstone-views/admin.yaml index 84b076149f..59b029490d 100644 --- a/src/sunstone/etc/sunstone-views/admin.yaml +++ b/src/sunstone/etc/sunstone-views/admin.yaml @@ -265,6 +265,7 @@ tabs: actions: Image.refresh: true Image.create_dialog: true + Image.export_dialog: true Image.rename: true Image.chown: true Image.chgrp: true diff --git a/src/sunstone/etc/sunstone-views/user.yaml b/src/sunstone/etc/sunstone-views/user.yaml index 581e0afdab..976095db2b 100644 --- a/src/sunstone/etc/sunstone-views/user.yaml +++ b/src/sunstone/etc/sunstone-views/user.yaml @@ -265,6 +265,7 @@ tabs: actions: Image.refresh: true Image.create_dialog: true + Image.export_dialog: true Image.rename: true Image.chown: false Image.chgrp: false diff --git a/src/sunstone/public/app/tabs/images-tab/actions.js b/src/sunstone/public/app/tabs/images-tab/actions.js index bc7fe8f977..17cc61abe5 100644 --- a/src/sunstone/public/app/tabs/images-tab/actions.js +++ b/src/sunstone/public/app/tabs/images-tab/actions.js @@ -24,8 +24,11 @@ define(function(require) { var RESOURCE = "Image"; var XML_ROOT = "IMAGE"; var TAB_ID = require('./tabId'); + var MARKETPLACEAPPS_TAB_ID = require('tabs/marketplaceapps-tab/tabId'); var CREATE_DIALOG_ID = require('./form-panels/create/formPanelId'); var CLONE_DIALOG_ID = require('./dialogs/clone/dialogId'); + var CREATE_APP_DIALOG_ID = require('tabs/marketplaceapps-tab/form-panels/create/formPanelId'); + var _commonActions = new CommonActions(OpenNebulaResource, RESOURCE, TAB_ID, XML_ROOT); @@ -50,6 +53,23 @@ define(function(require) { "Image.snapshot_flatten": _commonActions.singleAction("snapshot_flatten"), "Image.snapshot_revert": _commonActions.singleAction("snapshot_revert"), "Image.snapshot_delete": _commonActions.singleAction("snapshot_delete"), + "Image.export_dialog" : { + type: "custom", + call: function() { + Sunstone.showTab(MARKETPLACEAPPS_TAB_ID); + Sunstone.showFormPanel(MARKETPLACEAPPS_TAB_ID, CREATE_APP_DIALOG_ID, "create", + function(formPanelInstance, context) { + var selectedNodes = Sunstone.getDataTable(TAB_ID).elements(); + if (selectedNodes.length !== 1) { + Notifier.notifyMessage('Please select one (and just one) Image to export.'); + return false; + } + + var resourceId = '' + selectedNodes[0]; + formPanelInstance.setImageId(resourceId); + }); + } + }, "Image.clone_dialog" : { type: "custom", diff --git a/src/sunstone/public/app/tabs/images-tab/buttons.js b/src/sunstone/public/app/tabs/images-tab/buttons.js index 97b4cca001..68e02808c9 100644 --- a/src/sunstone/public/app/tabs/images-tab/buttons.js +++ b/src/sunstone/public/app/tabs/images-tab/buttons.js @@ -27,6 +27,10 @@ define(function(require) { type: "create_dialog", layout: "create" }, + "Image.export_dialog" : { + type: "action", + text: '' + }, "Image.chown" : { type: "confirm_with_select", text: Locale.tr("Change owner"), diff --git a/src/sunstone/public/app/tabs/marketplaceapps-tab/form-panels/create.js b/src/sunstone/public/app/tabs/marketplaceapps-tab/form-panels/create.js index 4528ebab9c..9893b1a5f9 100644 --- a/src/sunstone/public/app/tabs/marketplaceapps-tab/form-panels/create.js +++ b/src/sunstone/public/app/tabs/marketplaceapps-tab/form-panels/create.js @@ -80,6 +80,7 @@ define(function(require) { FormPanel.prototype.htmlAdvanced = _htmlAdvanced; FormPanel.prototype.submitWizard = _submitWizard; FormPanel.prototype.submitAdvanced = _submitAdvanced; + FormPanel.prototype.setImageId = _setImageId; FormPanel.prototype.onShow = _onShow; FormPanel.prototype.setup = _setup; @@ -114,6 +115,14 @@ define(function(require) { return false; } + function _setImageId(imageId) { + var selectedResources = { + ids : imageId + } + + this.imagesTable.selectResourceTableSelect(selectedResources); + } + // Set up the create datastore context function _setup(context) { Tips.setup(context);