Return-Path: X-Original-To: apmail-ambari-commits-archive@www.apache.org Delivered-To: apmail-ambari-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id BE91C18668 for ; Thu, 22 Oct 2015 02:11:22 +0000 (UTC) Received: (qmail 91460 invoked by uid 500); 22 Oct 2015 02:11:22 -0000 Delivered-To: apmail-ambari-commits-archive@ambari.apache.org Received: (qmail 91432 invoked by uid 500); 22 Oct 2015 02:11:22 -0000 Mailing-List: contact commits-help@ambari.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: ambari-dev@ambari.apache.org Delivered-To: mailing list commits@ambari.apache.org Received: (qmail 91423 invoked by uid 99); 22 Oct 2015 02:11:22 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 22 Oct 2015 02:11:22 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 7A484DFC15; Thu, 22 Oct 2015 02:11:22 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jaimin@apache.org To: commits@ambari.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: ambari git commit: AMBARI-13481. Ranger User Info tab: All subsequent subsection and their configs should be hidden if Ranger Usersync is disabled. (jaimin) Date: Thu, 22 Oct 2015 02:11:22 +0000 (UTC) Repository: ambari Updated Branches: refs/heads/trunk ac51d8b6c -> 34a03533b AMBARI-13481. Ranger User Info tab: All subsequent subsection and their configs should be hidden if Ranger Usersync is disabled. (jaimin) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/34a03533 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/34a03533 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/34a03533 Branch: refs/heads/trunk Commit: 34a03533b1bf844a9f7b3f56919de1db3d24754c Parents: ac51d8b Author: Jaimin Jetly Authored: Tue Oct 20 11:33:01 2015 -0700 Committer: Jaimin Jetly Committed: Wed Oct 21 19:10:57 2015 -0700 ---------------------------------------------------------------------- ambari-web/app/mappers/configs/themes_mapper.js | 62 +++++++++++++--- ambari-web/app/models.js | 2 +- .../app/models/configs/config_condition.js | 65 ----------------- .../app/models/configs/theme/sub_section.js | 9 ++- .../app/models/configs/theme/sub_section_tab.js | 9 ++- .../app/models/configs/theme/theme_condition.js | 76 ++++++++++++++++++++ .../configs/service_config_layout_tab_view.js | 3 +- .../configs/widgets/config_widget_view.js | 30 +++++++- 8 files changed, 172 insertions(+), 84 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/34a03533/ambari-web/app/mappers/configs/themes_mapper.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/mappers/configs/themes_mapper.js b/ambari-web/app/mappers/configs/themes_mapper.js index fff2013..0a55068 100644 --- a/ambari-web/app/mappers/configs/themes_mapper.js +++ b/ambari-web/app/mappers/configs/themes_mapper.js @@ -22,7 +22,7 @@ App.themesMapper = App.QuickDataMapper.create({ sectionModel: App.Section, subSectionModel: App.SubSection, subSectionTabModel: App.SubSectionTab, - configConditionModel: App.ConfigCondition, + themeConditionModel: App.ThemeCondition, tabConfig: { "id": "name", @@ -107,27 +107,40 @@ App.themesMapper = App.QuickDataMapper.create({ if (section.subsections) { var subSections = []; + var subSectionConditions = []; section.subsections.forEach(function(subSection) { var parsedSubSection = this.parseIt(subSection, this.get("subSectionConfig")); parsedSubSection.section_id = parsedSection.id; if (subSection['subsection-tabs']) { var subSectionTabs = []; + var subSectionTabConditions = []; subSection['subsection-tabs'].forEach(function (subSectionTab) { var parsedSubSectionTab = this.parseIt(subSectionTab, this.get("subSectionTabConfig")); parsedSubSectionTab.sub_section_id = parsedSubSection.id; - + if (parsedSubSectionTab['depends_on']) { + subSectionTabConditions.push(parsedSubSectionTab); + } subSectionTabs.push(parsedSubSectionTab); }, this); subSectionTabs[0].is_active = true; - + if (subSectionTabConditions.length) { + var type = 'subsectionTab'; + this.mapThemeConditions(subSectionTabConditions, type); + } App.store.loadMany(this.get("subSectionTabModel"), subSectionTabs); parsedSubSection.sub_section_tabs = subSectionTabs.mapProperty("id"); } - + if (parsedSubSection['depends_on']) { + subSectionConditions.push(parsedSubSection); + } subSections.push(parsedSubSection); }, this); + if (subSectionConditions.length) { + var type = 'subsection'; + this.mapThemeConditions(subSectionConditions, type); + } App.store.loadMany(this.get("subSectionModel"), subSections); parsedSection.sub_sections = subSections.mapProperty("id"); } @@ -159,15 +172,12 @@ App.themesMapper = App.QuickDataMapper.create({ var subSectionTabId = configLink["subsection-tab-name"]; if (subSectionTabId) { var subSectionTab = App.SubSectionTab.find(subSectionTabId); - var subSectionTabDependsOnConfigs = subSectionTab.get('dependsOn'); } else if (subSectionId) { var subSection = App.SubSection.find(subSectionId); - var subSectionDependsOnConfigs = subSection.get('dependsOn'); } var configProperty = App.StackConfigProperty.find(configId); - var configDependsOnOtherConfigs = configLink["depends-on"] || []; - var dependsOnConfigs = configDependsOnOtherConfigs.concat(subSectionDependsOnConfigs || []).concat(subSectionTabDependsOnConfigs || []); + var dependsOnConfigs = configLink["depends-on"] || []; if (configProperty.get('id') && subSection) { subSection.get('configProperties').pushObject(configProperty); @@ -181,7 +191,7 @@ App.themesMapper = App.QuickDataMapper.create({ if (valueAttributes) { var isUiOnlyProperty = valueAttributes["ui_only_property"]; // UI only configs are mentioned in the themes for supporting widgets that is not intended for setting a value - // And thus is affiliated witha fake config peperty termed as ui only config property + // And thus is affiliated with fake config property termed as ui only config property if (isUiOnlyProperty && subSection) { var split = configLink.config.split("/"); var fileName = split[0] + '.xml'; @@ -237,11 +247,43 @@ App.themesMapper = App.QuickDataMapper.create({ } configCondition.resource = _configCondition.resource || 'config'; + configCondition.type = _configCondition.type || 'config'; configConditionsCopy.pushObject(configCondition); }, this); - App.store.loadMany(this.get("configConditionModel"), configConditionsCopy); + App.store.loadMany(this.get("themeConditionModel"), configConditionsCopy); + App.store.commit(); + }, + + /** + * + * @param subSections: Array + * @param type: {String} possible values: `subsection` or `subsectionTab` + */ + mapThemeConditions: function(subSections, type) { + var subSectionConditionsCopy = []; + subSections.forEach(function(_subSection){ + var subSectionConditions = _subSection['depends_on']; + subSectionConditions.forEach(function(_subSectionCondition, index){ + var subSectionCondition = $.extend({},_subSectionCondition); + subSectionCondition.id = _subSection.id + '_' + index; + subSectionCondition.name = _subSection.name; + if (_subSectionCondition.configs && _subSectionCondition.configs.length) { + subSectionCondition.configs = _subSectionCondition.configs.map(function (item) { + var result = {}; + result.fileName = item.split('/')[0] + '.xml'; + result.configName = item.split('/')[1]; + return result; + }); + } + + subSectionCondition.resource = _subSectionCondition.resource || 'config'; + subSectionCondition.type = _subSectionCondition.type || type; + subSectionConditionsCopy.pushObject(subSectionCondition); + }, this); + }, this); + App.store.loadMany(this.get("themeConditionModel"), subSectionConditionsCopy); App.store.commit(); }, http://git-wip-us.apache.org/repos/asf/ambari/blob/34a03533/ambari-web/app/models.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/models.js b/ambari-web/app/models.js index 8117f62..9440dea 100644 --- a/ambari-web/app/models.js +++ b/ambari-web/app/models.js @@ -60,7 +60,7 @@ require('models/master_component'); require('models/host_stack_version'); require('models/root_service'); require('models/upgrade_entity'); -require('models/configs/config_condition'); +require('models/configs/theme/theme_condition'); require('models/configs/service_config_version'); require('models/configs/stack_config_property'); require('models/configs/config_group'); http://git-wip-us.apache.org/repos/asf/ambari/blob/34a03533/ambari-web/app/models/configs/config_condition.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/models/configs/config_condition.js b/ambari-web/app/models/configs/config_condition.js deleted file mode 100644 index f978424..0000000 --- a/ambari-web/app/models/configs/config_condition.js +++ /dev/null @@ -1,65 +0,0 @@ -/** - * 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. - */ - -/** - * THIS IS NOT USED FOR NOW - * FOR CONFIG GROUPS WE ARE USING OLD MODELS AND LOGIC - */ - -var App = require('app'); - -App.ConfigCondition = DS.Model.extend({ - /** - * unique id generated as config_namefilename - * @property {string} - */ - id: DS.attr('string'), - - /** - * Name of the config that is being affected with the condition - */ - configName: DS.attr('string'), - - /** - * File name to which the config getting affected belongs - */ - fileName: DS.attr('string'), - - /** - * List of configs whose values affect the config - * Each Object in an array consists of configName and fileName - */ - configs: DS.attr('array', {defaultValue: []}), - - /** - * resource can be `config`, `service` - */ - resource: DS.attr('string', {defaultValue: 'config'}), - - /** - * conditional String which can be evaluated to boolean result. - * If evaluated result of this staring is true then use the statement provided by `then` attribute. - * Otherwise use the attribute provided by `else` attributes - */ - if: DS.attr('string'), - then: DS.attr('object', {defaultValue: null}), - else: DS.attr('object', {defaultValue: null}) - -}); - -App.ConfigCondition.FIXTURES = []; http://git-wip-us.apache.org/repos/asf/ambari/blob/34a03533/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 261d3b8..ed3c7a2 100644 --- a/ambari-web/app/models/configs/theme/sub_section.js +++ b/ambari-web/app/models/configs/theme/sub_section.js @@ -172,6 +172,11 @@ App.SubSection = DS.Model.extend({ }.property('columnIndex', 'columnSpan', 'section.sectionColumns'), /** + * If the visibility of subsection is dependent on a value of some config + */ + isHiddenByConfig: false, + + /** * Determines if subsection is filtered by checking it own configs * If there is no configs, subsection can't be hidden * @type {boolean} @@ -186,8 +191,8 @@ App.SubSection = DS.Model.extend({ * @type {boolean} */ isSectionVisible: function () { - return !this.get('isHiddenByFilter') && this.get('configs').someProperty('isVisible', true); - }.property('isHiddenByFilter', 'configs.@each.isVisible') + return !this.get('isHiddenByFilter') && !this.get('isHiddenByConfig') && this.get('configs').someProperty('isVisible', true); + }.property('isHiddenByFilter', 'configs.@each.isVisible', 'isHiddenByConfig') }); http://git-wip-us.apache.org/repos/asf/ambari/blob/34a03533/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 bf7c015..ca42aeb 100644 --- a/ambari-web/app/models/configs/theme/sub_section_tab.js +++ b/ambari-web/app/models/configs/theme/sub_section_tab.js @@ -66,6 +66,11 @@ App.SubSectionTab = DS.Model.extend({ }.property('configs.@each.isVisible', 'configs.@each.isValid', 'configs.@each.overrideErrorTrigger'), /** + * If the visibility of subsection is dependent on a value of some config + */ + isHiddenByConfig: false, + + /** * Determines if subsection is filtered by checking it own configs * If there is no configs, subsection can't be hidden * @type {boolean} @@ -80,8 +85,8 @@ App.SubSectionTab = DS.Model.extend({ * @type {boolean} */ isVisible: function () { - return !this.get('isHiddenByFilter') && this.get('configs').someProperty('isVisible', true); - }.property('isHiddenByFilter', 'configs.@each.isVisible') + return !this.get('isHiddenByFilter') && !this.get('isHiddenByConfig') && this.get('configs').someProperty('isVisible', true); + }.property('isHiddenByFilter', 'isHiddenByConfig', 'configs.@each.isVisible') }); http://git-wip-us.apache.org/repos/asf/ambari/blob/34a03533/ambari-web/app/models/configs/theme/theme_condition.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/models/configs/theme/theme_condition.js b/ambari-web/app/models/configs/theme/theme_condition.js new file mode 100644 index 0000000..a77256a --- /dev/null +++ b/ambari-web/app/models/configs/theme/theme_condition.js @@ -0,0 +1,76 @@ +/** + * 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. + */ + +/** + * THIS IS NOT USED FOR NOW + * FOR CONFIG GROUPS WE ARE USING OLD MODELS AND LOGIC + */ + +var App = require('app'); + +App.ThemeCondition = DS.Model.extend({ + /** + * unique id generated as config_namefilename + * @property {string} + */ + id: DS.attr('string'), + + /** + * type can be `config`, `service` + */ + type: DS.attr('string'), + + /** + * This is specific to subsection and subsectionTab type + */ + + name: DS.attr('string'), + + /** + * Name of the config that is being affected with the condition + */ + configName: DS.attr('string'), + + /** + * File name to which the config getting affected belongs + */ + fileName: DS.attr('string'), + + /** + * List of configs whose values affect the config + * Each Object in an array consists of configName and fileName + */ + configs: DS.attr('array', {defaultValue: []}), + + /** + * resource can be `config`, `service` + */ + resource: DS.attr('string', {defaultValue: 'config'}), + + /** + * conditional String which can be evaluated to boolean result. + * If evaluated result of this staring is true then use the statement provided by `then` attribute. + * Otherwise use the attribute provided by `else` attributes + */ + if: DS.attr('string'), + then: DS.attr('object', {defaultValue: null}), + else: DS.attr('object', {defaultValue: null}) + +}); + +App.ThemeCondition.FIXTURES = []; http://git-wip-us.apache.org/repos/asf/ambari/blob/34a03533/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 720dd12..1aec1fa 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 @@ -119,8 +119,7 @@ App.ServiceConfigLayoutTabView = Em.View.extend(App.ConfigOverridable, { stackConfigProperty: config }; - - var configConditions = App.ConfigCondition.find().filter(function (_configCondition) { + var configConditions = App.ThemeCondition.find().filter(function (_configCondition) { // Filter config condition depending on the value of another config var conditionalConfigs = (_configCondition.get('configs')||[]).filterProperty('fileName', config.get('filename')).filterProperty('configName', config.get('name')); // Filter config condition depending on the service existence or service state http://git-wip-us.apache.org/repos/asf/ambari/blob/34a03533/ambari-web/app/views/common/configs/widgets/config_widget_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/common/configs/widgets/config_widget_view.js b/ambari-web/app/views/common/configs/widgets/config_widget_view.js index b3e806f..9e120ce 100644 --- a/ambari-web/app/views/common/configs/widgets/config_widget_view.js +++ b/ambari-web/app/views/common/configs/widgets/config_widget_view.js @@ -430,7 +430,11 @@ App.ConfigWidgetView = Em.View.extend(App.SupportsDependentConfigs, App.WidgetPo } }, this); isConditionTrue = window.eval(allConditionResult.join('')); - this.changeConfigAttribute(configCondition, isConditionTrue); + if (configCondition.get("type") === 'subsection' || configCondition.get("type") === 'subsectionTab') { + this.changeSubsectionAttribute(configCondition, isConditionTrue); + } else { + this.changeConfigAttribute(configCondition, isConditionTrue); + } } else if (configCondition.get("resource") === 'service') { var service = App.Service.find().findProperty('serviceName', ifStatement); var serviceName; @@ -449,7 +453,7 @@ App.ConfigWidgetView = Em.View.extend(App.SupportsDependentConfigs, App.WidgetPo /** * - * @param configCondition {App.ConfigCondition} + * @param configCondition {App.ThemeCondition} * @param isConditionTrue {boolean} */ changeConfigAttribute: function(configCondition, isConditionTrue) { @@ -470,6 +474,28 @@ App.ConfigWidgetView = Em.View.extend(App.SupportsDependentConfigs, App.WidgetPo } }, + /** + * + * @param subsectionCondition {App.ThemeCondition} + * @param isConditionTrue {boolean} + */ + changeSubsectionAttribute: function(subsectionCondition, isConditionTrue) { + var subsectionConditionName = subsectionCondition.get('name'); + var action = isConditionTrue ? subsectionCondition.get("then") : subsectionCondition.get("else"); + if (subsectionCondition.get('id')) { + var valueAttributes = action.property_value_attributes; + if (valueAttributes && !Em.none(valueAttributes['visible'])) { + var themeResource; + if (subsectionCondition.get('type') === 'subsection') { + themeResource = App.SubSection.find().findProperty('name', subsectionConditionName); + } else if (subsectionCondition.get('type') === 'subsectionTab') { + themeResource = App.SubSectionTab.find().findProperty('name', subsectionConditionName); + } + themeResource.set('isHiddenByConfig', !valueAttributes['visible']); + } + } + }, + /**