Repository: ambari Updated Branches: refs/heads/branch-2.5 17ef55594 -> fcad14b39
AMBARI-20287 - Filter in Customize Services Page doesn't bring up all properties that matches (rzang) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/fcad14b3 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/fcad14b3 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/fcad14b3 Branch: refs/heads/branch-2.5 Commit: fcad14b39e55137912fee51a946b2b85f5140d0e Parents: 17ef555 Author: Richard Zang <rz...@apache.org> Authored: Thu Mar 9 11:51:45 2017 -0800 Committer: Richard Zang <rz...@apache.org> Committed: Thu Mar 9 11:57:15 2017 -0800 ---------------------------------------------------------------------- .../app/models/configs/theme/sub_section.js | 2 +- .../app/models/configs/theme/sub_section_tab.js | 9 +- .../configs/service_config_layout_tab_view.js | 4 +- .../configs/theme/sub_section_tab_test.js | 198 +++++++++++++++++++ 4 files changed, 209 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/fcad14b3/ambari-web/app/models/configs/theme/sub_section.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/models/configs/theme/sub_section.js b/ambari-web/app/models/configs/theme/sub_section.js index 7274569..591a3e9 100644 --- a/ambari-web/app/models/configs/theme/sub_section.js +++ b/ambari-web/app/models/configs/theme/sub_section.js @@ -181,7 +181,7 @@ App.SubSection = DS.Model.extend({ var configs = this.get('configs').filter(function(c) { return !c.get('hiddenBySection') && c.get('isVisible'); }); - return configs.length ? configs.everyProperty('isHiddenByFilter', true) : false; + return configs.length ? configs.everyProperty('isHiddenByFilter', true) && !this.get('someSubSectionTabIsVisible'): false; }.property('configs.@each.isHiddenByFilter'), /** http://git-wip-us.apache.org/repos/asf/ambari/blob/fcad14b3/ambari-web/app/models/configs/theme/sub_section_tab.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/models/configs/theme/sub_section_tab.js b/ambari-web/app/models/configs/theme/sub_section_tab.js index 2262882..9062457 100644 --- a/ambari-web/app/models/configs/theme/sub_section_tab.js +++ b/ambari-web/app/models/configs/theme/sub_section_tab.js @@ -81,7 +81,10 @@ App.SubSectionTab = DS.Model.extend({ * If there is no configs, subsection can't be hidden * @type {boolean} */ - isHiddenByFilter: Em.computed.everyBy('visibleProperties', 'isHiddenByFilter', true), + isHiddenByFilter: function () { + var configs = this.get('visibleProperties'); + return configs.length ? configs.everyProperty('isHiddenByFilter', true) : false; + }.property('configs.@each.isHiddenByFilter').volatile(), /** * @type {boolean} @@ -92,7 +95,9 @@ App.SubSectionTab = DS.Model.extend({ * Determines if subsection is visible * @type {boolean} */ - isVisible: Em.computed.and('!isHiddenByFilter', '!isHiddenByConfig', 'someConfigIsVisible') + isVisible: function() { + return !this.get('isHiddenByFilter') && !this.get('isHiddenByConfig') && this.get('someConfigIsVisible'); + }.property('isHiddenByFilter', 'isHiddenByConfig', 'someConfigIsVisible').volatile() }); http://git-wip-us.apache.org/repos/asf/ambari/blob/fcad14b3/ambari-web/app/views/common/configs/service_config_layout_tab_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/common/configs/service_config_layout_tab_view.js b/ambari-web/app/views/common/configs/service_config_layout_tab_view.js index 466a88d..ccbb148 100644 --- a/ambari-web/app/views/common/configs/service_config_layout_tab_view.js +++ b/ambari-web/app/views/common/configs/service_config_layout_tab_view.js @@ -182,7 +182,9 @@ App.ServiceConfigLayoutTabView = Em.View.extend(App.ConfigOverridable, { * @param event */ setActiveSubTab: function(event) { - if (!event.context) return; + if (!event.context || !event.context.get('isVisible')) { + return false; + } try { event.context.get('subSection.subSectionTabs').setEach('isActive', false); event.context.set('isActive', true); http://git-wip-us.apache.org/repos/asf/ambari/blob/fcad14b3/ambari-web/test/models/configs/theme/sub_section_tab_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/models/configs/theme/sub_section_tab_test.js b/ambari-web/test/models/configs/theme/sub_section_tab_test.js new file mode 100644 index 0000000..d65cd76 --- /dev/null +++ b/ambari-web/test/models/configs/theme/sub_section_tab_test.js @@ -0,0 +1,198 @@ +/** + * 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'); +require('models/configs/theme/sub_section_tab'); + +describe('App.SubSectionTab', function () { + + var subSectionTab, + getModel = function () { + return App.SubSectionTab.createRecord(); + }; + + beforeEach(function () { + subSectionTab = getModel(); + }); + + describe('#visibleProperties', function () { + + var configs = [ + Em.Object.create({ + id: 0, + isVisible: false, + hiddenBySection: false + }), + Em.Object.create({ + id: 1, + isVisible: false, + hiddenBySection: true + }), + Em.Object.create({ + id: 2, + isVisible: true, + hiddenBySection: false + }), + Em.Object.create({ + id: 3, + isVisible: true, + hiddenBySection: true + }), + Em.Object.create({ + id: 4, + isVisible: false + }), + Em.Object.create({ + id: 5, + isVisible: true + }) + ]; + + it('should include visible properties from visible sections only', function () { + subSectionTab.set('configs', configs); + expect(subSectionTab.get('visibleProperties').mapProperty('id')).to.eql([2, 5]); + }); + + }); + + describe('#errorsCount', function () { + + var configs = [ + Em.Object.create({ + isVisible: true, + isValid: true, + isValidOverride: true + }), + Em.Object.create({ + isVisible: false, + isValid: true, + isValidOverride: true + }), + Em.Object.create({ + isVisible: true, + isValid: true, + isValidOverride: false + }), + Em.Object.create({ + isVisible: false, + isValid: true, + isValidOverride: false + }), + Em.Object.create({ + isVisible: true, + isValid: false, + isValidOverride: true + }), + Em.Object.create({ + isVisible: false, + isValid: false, + isValidOverride: true + }), + Em.Object.create({ + isVisible: true, + isValid: false, + isValidOverride: false + }), + Em.Object.create({ + isVisible: false, + isValid: false, + isValidOverride: false + }), + Em.Object.create({ + isVisible: true, + isValid: true + }), + Em.Object.create({ + isVisible: false, + isValid: true + }), + Em.Object.create({ + isVisible: true, + isValid: false + }), + Em.Object.create({ + isVisible: false, + isValid: false + }), + Em.Object.create({ + isVisible: true, + isValidOverride: true + }), + Em.Object.create({ + isVisible: false, + isValidOverride: true + }), + Em.Object.create({ + isVisible: true, + isValidOverride: false + }), + Em.Object.create({ + isVisible: false, + isValidOverride: false + }), + Em.Object.create({ + isVisible: true + }), + Em.Object.create({ + isVisible: false + }) + ]; + + it('should include visible properties with errors', function () { + subSectionTab.set('configs', configs); + expect(subSectionTab.get('errorsCount')).to.be.equal(8); + }); + + }); + + describe('#isHiddenByFilter', function () { + + Em.A([ + { + configs: [], + e: false, + m: 'Can\'t be hidden if there is no configs' + }, + { + configs: [Em.Object.create({isHiddenByFilter: true, isVisible: true}), Em.Object.create({isHiddenByFilter: true, isVisible: true})], + e: true, + m: 'All configs are hidden' + }, + { + configs: [Em.Object.create({isHiddenByFilter: false, isVisible: true}), Em.Object.create({isHiddenByFilter: true, isVisible: true})], + e: false, + m: 'Some configs are hidden' + }, + { + configs: [Em.Object.create({isHiddenByFilter: false, isVisible: true}), Em.Object.create({isHiddenByFilter: true, isVisible: true})], + e: false, + m: 'Some configs are hidden' + }, + { + configs: [Em.Object.create({isHiddenByFilter: false, isVisible: true}), Em.Object.create({isHiddenByFilter: false, isVisible: true})], + e: false, + m: 'No configs are hidden' + } + ]).forEach(function (test) { + it(test.m, function () { + subSectionTab.set('configs', test.configs); + expect(subSectionTab.get('isHiddenByFilter')).to.equal(test.e); + }) + }); + + });}); \ No newline at end of file