Repository: ambari Updated Branches: refs/heads/trunk 6727c1dc8 -> 6cfff2107
AMBARI-10838. Ranger Admin HA Wizard: different order after page refresh on step2. (akovalenko) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/6cfff210 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/6cfff210 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/6cfff210 Branch: refs/heads/trunk Commit: 6cfff2107852df046627ffbb33a7d40702c26295 Parents: 6727c1d Author: Aleksandr Kovalenko <akovale...@hortonworks.com> Authored: Wed Apr 29 19:15:19 2015 +0300 Committer: Aleksandr Kovalenko <akovale...@hortonworks.com> Committed: Wed Apr 29 19:39:47 2015 +0300 ---------------------------------------------------------------------- ambari-web/app/assets/test/tests.js | 1 + .../nameNode/step2_controller.js | 4 +- .../rangerAdmin/step2_controller.js | 4 +- .../resourceManager/step2_controller.js | 4 +- .../mixins/wizard/assign_master_components.js | 30 ++++++++-- .../nameNode/step2_controller_test.js | 63 ++++++++++++++++++++ 6 files changed, 98 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/6cfff210/ambari-web/app/assets/test/tests.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/assets/test/tests.js b/ambari-web/app/assets/test/tests.js index d1d454d..9abb648 100644 --- a/ambari-web/app/assets/test/tests.js +++ b/ambari-web/app/assets/test/tests.js @@ -59,6 +59,7 @@ var files = ['test/init_model_test', 'test/controllers/main/admin/highAvailability_controller_test', 'test/controllers/main/admin/highAvailability/progress_controller_test', 'test/controllers/main/admin/highAvailability/progress_popup_controller_test', + 'test/controllers/main/admin/highAvailability/nameNode/step2_controller_test', 'test/controllers/main/admin/highAvailability/nameNode/step3_controller_test', 'test/controllers/main/admin/highAvailability/nameNode/step4_controller_test', 'test/controllers/main/admin/highAvailability/resourceManager/step3_controller_test', http://git-wip-us.apache.org/repos/asf/ambari/blob/6cfff210/ambari-web/app/controllers/main/admin/highAvailability/nameNode/step2_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/admin/highAvailability/nameNode/step2_controller.js b/ambari-web/app/controllers/main/admin/highAvailability/nameNode/step2_controller.js index ea604dc..b8d7978 100644 --- a/ambari-web/app/controllers/main/admin/highAvailability/nameNode/step2_controller.js +++ b/ambari-web/app/controllers/main/admin/highAvailability/nameNode/step2_controller.js @@ -32,7 +32,9 @@ App.HighAvailabilityWizardStep2Controller = Em.Controller.extend(App.BlueprintMi showCurrentPrefix: ['NAMENODE'], - showAdditionalPrefix: ['NAMENODE'] + showAdditionalPrefix: ['NAMENODE'], + + showInstalledMastersFirst: true }); http://git-wip-us.apache.org/repos/asf/ambari/blob/6cfff210/ambari-web/app/controllers/main/admin/highAvailability/rangerAdmin/step2_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/admin/highAvailability/rangerAdmin/step2_controller.js b/ambari-web/app/controllers/main/admin/highAvailability/rangerAdmin/step2_controller.js index 6911853..1922a98 100644 --- a/ambari-web/app/controllers/main/admin/highAvailability/rangerAdmin/step2_controller.js +++ b/ambari-web/app/controllers/main/admin/highAvailability/rangerAdmin/step2_controller.js @@ -31,7 +31,9 @@ App.RAHighAvailabilityWizardStep2Controller = Em.Controller.extend(App.Blueprint showAdditionalPrefix: ['RANGER_ADMIN'], - mastersAddableInHA: ['RANGER_ADMIN'] + mastersAddableInHA: ['RANGER_ADMIN'], + + showInstalledMastersFirst: true }); http://git-wip-us.apache.org/repos/asf/ambari/blob/6cfff210/ambari-web/app/controllers/main/admin/highAvailability/resourceManager/step2_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/admin/highAvailability/resourceManager/step2_controller.js b/ambari-web/app/controllers/main/admin/highAvailability/resourceManager/step2_controller.js index 551742c..8ad2a51 100644 --- a/ambari-web/app/controllers/main/admin/highAvailability/resourceManager/step2_controller.js +++ b/ambari-web/app/controllers/main/admin/highAvailability/resourceManager/step2_controller.js @@ -30,6 +30,8 @@ App.RMHighAvailabilityWizardStep2Controller = Em.Controller.extend(App.Blueprint showCurrentPrefix: ['RESOURCEMANAGER'], - showAdditionalPrefix: ['RESOURCEMANAGER'] + showAdditionalPrefix: ['RESOURCEMANAGER'], + + showInstalledMastersFirst: true }); http://git-wip-us.apache.org/repos/asf/ambari/blob/6cfff210/ambari-web/app/mixins/wizard/assign_master_components.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/mixins/wizard/assign_master_components.js b/ambari-web/app/mixins/wizard/assign_master_components.js index 796e3b1..69a21d5 100644 --- a/ambari-web/app/mixins/wizard/assign_master_components.js +++ b/ambari-web/app/mixins/wizard/assign_master_components.js @@ -89,6 +89,12 @@ App.AssignMasterComponents = Em.Mixin.create({ additionalHostsList: [], /** + * Define whether show already installed masters first + * @type {Boolean} + */ + showInstalledMastersFirst: false, + + /** * Array of <code>servicesMasters</code> objects, that will be shown on the page * Are filtered using <code>mastersToShow</code> * @type {Array} @@ -96,16 +102,30 @@ App.AssignMasterComponents = Em.Mixin.create({ servicesMastersToShow: function () { var mastersToShow = this.get('mastersToShow'); var servicesMasters = this.get('servicesMasters'); + var result = []; if (!mastersToShow.length) { - return servicesMasters; + result = servicesMasters; } else { - var result = []; - mastersToShow.forEach(function(master){ + mastersToShow.forEach(function (master) { result = result.concat(servicesMasters.filterProperty('component_name', master)); }); - return result; } - }.property('servicesMasters.length', 'mastersToShow.length'), + + if (this.get('showInstalledMastersFirst')) { + result = this.sortMasterComponents(result); + } + + return result; + }.property('servicesMasters.length', 'mastersToShow.length', 'showInstalledMastersFirst'), + + /** + * Sort masters, installed masters will be first. + * @param masters + * @returns {Array} + */ + sortMasterComponents: function (masters) { + return [].concat(masters.filterProperty('isInstalled'), masters.filterProperty('isInstalled', false)); + }, /** * Check if <code>installerWizard</code> used http://git-wip-us.apache.org/repos/asf/ambari/blob/6cfff210/ambari-web/test/controllers/main/admin/highAvailability/nameNode/step2_controller_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/admin/highAvailability/nameNode/step2_controller_test.js b/ambari-web/test/controllers/main/admin/highAvailability/nameNode/step2_controller_test.js new file mode 100644 index 0000000..731094f --- /dev/null +++ b/ambari-web/test/controllers/main/admin/highAvailability/nameNode/step2_controller_test.js @@ -0,0 +1,63 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var App = require('app'); + +describe('App.HighAvailabilityWizardStep2Controller', function () { + var controller = App.HighAvailabilityWizardStep2Controller.create(); + + describe('#sortMasterComponents', function () { + + it('should sort installed masters first', function() { + expect(controller.sortMasterComponents([ + Em.Object.create({ + isInstalled: true + }), + Em.Object.create({ + isInstalled: false + }), + Em.Object.create({ + isInstalled: true + }), + Em.Object.create({ + isInstalled: false + }), + Em.Object.create({ + isInstalled: true + }) + ])).to.eql([ + Em.Object.create({ + isInstalled: true + }), + Em.Object.create({ + isInstalled: true + }), + Em.Object.create({ + isInstalled: true + }), + Em.Object.create({ + isInstalled: false + }), + Em.Object.create({ + isInstalled: false + }) + ]); + }); + }); + +}); \ No newline at end of file