Repository: ambari Updated Branches: refs/heads/branch-1.7.0 d589cce6e -> 7c5dc8cea
AMBARI-8114. Unknown component state shown and empty during save configs. (onechiporenko) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/7c5dc8ce Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/7c5dc8ce Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/7c5dc8ce Branch: refs/heads/branch-1.7.0 Commit: 7c5dc8cea8b73759106f24f8addd580ac8535d1b Parents: d589cce Author: Oleg Nechiporenko <onechipore...@apache.org> Authored: Mon Nov 3 13:05:03 2014 +0200 Committer: Oleg Nechiporenko <onechipore...@apache.org> Committed: Mon Nov 3 13:05:03 2014 +0200 ---------------------------------------------------------------------- .../controllers/main/service/info/configs.js | 24 +++++++-- .../main/service/info/config_test.js | 51 +++++++++++++++++++- 2 files changed, 70 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/7c5dc8ce/ambari-web/app/controllers/main/service/info/configs.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/service/info/configs.js b/ambari-web/app/controllers/main/service/info/configs.js index 2b194ae..11002c1 100644 --- a/ambari-web/app/controllers/main/service/info/configs.js +++ b/ambari-web/app/controllers/main/service/info/configs.js @@ -1442,6 +1442,8 @@ App.MainServiceInfoConfigsController = Em.Controller.extend(App.ServerValidatorM /** * Show save configs popup + * @method showSaveConfigsPopup + * @return {App.ModalPopup} */ showSaveConfigsPopup: function (header, flag, message, messageClass, value, status, urlParams) { var self = this; @@ -1449,7 +1451,7 @@ App.MainServiceInfoConfigsController = Em.Controller.extend(App.ServerValidatorM this.set('forceTransition', flag); self.loadStep(); } - App.ModalPopup.show({ + return App.ModalPopup.show({ header: header, primary: Em.I18n.t('ok'), secondary: null, @@ -1494,17 +1496,31 @@ App.MainServiceInfoConfigsController = Em.Controller.extend(App.ServerValidatorM context: view }); }, + /** + * Map components for their hosts + * Return format: + * <code> + * { + * host1: [component1, component2, ...], + * host2: [component3, component4, ...] + * } + * </code> + * @return {object} + */ setComponents = function (item, components) { item.host_components.forEach(function (c) { var name = c.HostRoles.host_name; if (!components[name]) { components[name] = []; - } else { - components[name].push(App.format.role(item.ServiceComponentInfo.component_name)); } + components[name].push(App.format.role(item.ServiceComponentInfo.component_name)); }); return components; }, + /** + * Map result of <code>setComponents</code> to array + * @return {{name: string, components: string}[]} + */ setHosts = function (components) { var hosts = []; Em.keys(components).forEach(function (key) { @@ -1549,7 +1565,7 @@ App.MainServiceInfoConfigsController = Em.Controller.extend(App.ServerValidatorM this.set('isLoaded', true); }, didInsertElement: function () { - App.ajax.send({ + return App.ajax.send({ name: 'components.filter_by_status', sender: this, data: { http://git-wip-us.apache.org/repos/asf/ambari/blob/7c5dc8ce/ambari-web/test/controllers/main/service/info/config_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/service/info/config_test.js b/ambari-web/test/controllers/main/service/info/config_test.js index 56e0195..86692e7 100644 --- a/ambari-web/test/controllers/main/service/info/config_test.js +++ b/ambari-web/test/controllers/main/service/info/config_test.js @@ -262,7 +262,7 @@ describe("App.MainServiceInfoConfigsController", function () { }); }); - describe("rollingRestartStaleConfigSlaveComponents", function () { + describe("#rollingRestartStaleConfigSlaveComponents", function () { var tests = [ { componentName: { @@ -1218,3 +1218,52 @@ describe("App.MainServiceInfoConfigsController", function () { }); }); }); + +describe("#setCompareDefaultGroupConfig", function() { + + describe('#showSaveConfigsPopup', function () { + + var bodyView; + + describe('#bodyClass', function () { + beforeEach(function() { + sinon.stub(App.ajax, 'send', Em.K); + // default implementation + bodyView = mainServiceInfoConfigsController.showSaveConfigsPopup().get('bodyClass').create({ + parentView: Em.View.create() + }); + }); + + afterEach(function() { + App.ajax.send.restore(); + }); + + describe('#componentsFilterSuccessCallback', function () { + it('check components with unknown state', function () { + bodyView = mainServiceInfoConfigsController.showSaveConfigsPopup('', true, '', {}, '', 'unknown', '').get('bodyClass').create({ + parentView: Em.View.create() + }); + bodyView.componentsFilterSuccessCallback({ + items: [ + { + ServiceComponentInfo: { + total_count: 4, + started_count: 2, + installed_count: 1, + component_name: 'c1' + }, + host_components: [ + {HostRoles: {host_name: 'h1'}} + ] + } + ] + }); + var unknownHosts = bodyView.get('unknownHosts'); + expect(unknownHosts.length).to.equal(1); + expect(unknownHosts[0]).to.eql({name: 'h1', components: 'C1'}); + }); + }); + }); + }); + +}); \ No newline at end of file