This is an automated email from the ASF dual-hosted git repository. ababiichuk pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/ambari.git
The following commit(s) were added to refs/heads/trunk by this push: new 78730df AMBARI-24051 Save button is disabled after adding the custom property. (ababiichuk) 78730df is described below commit 78730df4677532a5c9fbba37a301cae588c718a2 Author: ababiichuk <ababiic...@hortonworks.com> AuthorDate: Thu Jun 7 14:47:51 2018 +0300 AMBARI-24051 Save button is disabled after adding the custom property. (ababiichuk) --- .../app/mixins/common/configs/enhanced_configs.js | 172 ++++++++++++++++++++- .../configs/service_config_layout_tab_view.js | 111 ------------- .../views/common/configs/service_config_view.js | 36 ----- .../app/views/wizard/step7/databases_tab_view.js | 6 +- .../app/views/wizard/step7/directories_tab_view.js | 1 - 5 files changed, 172 insertions(+), 154 deletions(-) diff --git a/ambari-web/app/mixins/common/configs/enhanced_configs.js b/ambari-web/app/mixins/common/configs/enhanced_configs.js index 26ab7db..78e65a9 100644 --- a/ambari-web/app/mixins/common/configs/enhanced_configs.js +++ b/ambari-web/app/mixins/common/configs/enhanced_configs.js @@ -71,8 +71,36 @@ App.EnhancedConfigsMixin = Em.Mixin.create(App.ConfigWithOverrideRecommendationP currentlyChangedConfig: null, dependenciesGroupMessage: Em.I18n.t('popup.dependent.configs.dependencies.for.groups'), + /** - * message fro alert box for dependent configs + * ConfigType-Widget map + * key - widget type + * value - widget view + * @type {object} + */ + widgetTypeMap: { + checkbox: 'CheckboxConfigWidgetView', + combo: 'ComboConfigWidgetView', + directory: 'TextFieldConfigWidgetView', + directories: 'DirectoryConfigWidgetView', + list: 'ListConfigWidgetView', + password: 'PasswordConfigWidgetView', + 'radio-buttons': 'RadioButtonConfigWidgetView', + slider: 'SliderConfigWidgetView', + 'text-field': 'TextFieldConfigWidgetView', + 'time-interval-spinner': 'TimeIntervalSpinnerView', + toggle: 'ToggleConfigWidgetView', + 'text-area': 'StringConfigWidgetView', + 'label': 'LabelView', + 'test-db-connection': 'TestDbConnectionWidgetView' + }, + + configNameWidgetMixinMap: { + num_llap_nodes: App.NumLlapNodesWidgetMixin + }, + + /** + * message for alert box for dependent configs * @type {string} */ dependenciesMessage: function() { @@ -611,6 +639,7 @@ App.EnhancedConfigsMixin = Em.Mixin.create(App.ConfigWithOverrideRecommendationP }, updateAttributesFromTheme: function (serviceName) { + this.prepareSectionsConfigProperties(serviceName); const serviceConfigs = this.get('stepConfigs').findProperty('serviceName', serviceName).get('configs'), configConditions = App.ThemeCondition.find().filter(condition => { const dependentConfigName = condition.get('configName'), @@ -629,6 +658,110 @@ App.EnhancedConfigsMixin = Em.Mixin.create(App.ConfigWithOverrideRecommendationP this.updateAttributesFromConditions(configConditions, serviceConfigs, serviceName); }, + prepareSectionsConfigProperties: function (serviceName) { + const tabs = App.Tab.find().filterProperty('serviceName', serviceName); + tabs.forEach(tab => { + this.processTab(tab); + tab.get('sectionRows').forEach(row => { + row.forEach(section => { + section.get('subsectionRows').forEach(subRow => { + subRow.forEach(subsection => { + this.setConfigsToContainer(subsection); + subsection.get('subSectionTabs').forEach(subSectionTab => { + this.setConfigsToContainer(subSectionTab); + }); + }); + }); + }); + }); + }); + }, + + /** + * set {code} configs {code} array of subsection or subsection tab. + * Also correct widget should be used for each config (it's selected according to <code>widget.type</code> and + * <code>widgetTypeMap</code>). It may throw an error if needed widget can't be found in the <code>widgetTypeMap</code> + * @param containerObject + */ + setConfigsToContainer: function (containerObject) { + containerObject.set('configs', []); + + containerObject.get('configProperties').forEach(function (configId) { + const config = App.configsCollection.getConfig(configId); + if (Em.get(config, 'widgetType')) { + const stepConfig = this.get('stepConfigs').findProperty('serviceName', Em.get(config, 'serviceName')); + if (!stepConfig) return; + + const configProperty = stepConfig.get('configs').findProperty('id', Em.get(config, 'id')); + if (!configProperty) return; + + containerObject.get('configs').pushObject(configProperty); + + const widget = this.getWidgetView(config); + Em.assert('Unknown config widget view for config ' + configProperty.get('id') + ' with type ' + Em.get(config, 'widgetType'), widget); + + let additionalProperties = { + widget, + stackConfigProperty: config + }; + + const configConditions = App.ThemeCondition.find().filter(_configCondition => { + // Filter config condition depending on the value of another config + const conditionalConfigs = _configCondition.getWithDefault('configs', []).filterProperty('fileName', Em.get(config, 'filename')).filterProperty('configName', Em.get(config, 'name')); + // Filter config condition depending on the service existence or service state + const serviceConfigConditionFlag = ((_configCondition.get('configName') === Em.get(config, 'name')) && (_configCondition.get('fileName') === Em.get(config, 'filename')) && (_configCondition.get('resource') === 'service')); + let conditions; + + if (serviceConfigConditionFlag) { + const configCondition = { + configName: _configCondition.get('configName'), + fileName: _configCondition.get('fileName') + }; + conditions = conditionalConfigs.concat(configCondition) + } else { + conditions = conditionalConfigs; + } + return (conditions && conditions.length); + }); + + if (configConditions && configConditions.length) { + additionalProperties.configConditions = configConditions; + } + + const configAction = App.ConfigAction.find().filterProperty('fileName', Em.get(config, 'filename')).findProperty('configName', Em.get(config, 'name')); + + if (configAction) { + additionalProperties.configAction = configAction; + } + + configProperty.setProperties(additionalProperties); + + if (configProperty.get('overrides')) { + configProperty.get('overrides').setEach('stackConfigProperty', config); + } + if (configProperty.get('compareConfigs')) { + configProperty.get('compareConfigs').invoke('setProperties', { + isComparison: false, + stackConfigProperty: config + }); + } + } + }, this); + }, + + /** + * + * @param {object} config + * @returns {Em.View} + */ + getWidgetView: function (config) { + const configWidgetType = Em.get(config, 'widgetType'), + name = Em.get(config, 'name'), + mixin = this.get('configNameWidgetMixinMap')[name], + viewClass = App[this.get('widgetTypeMap')[configWidgetType]]; + return Em.isNone(mixin) ? viewClass : viewClass.extend(mixin); + }, + updateAttributesFromConditions: function (configConditions, serviceConfigs, serviceName) { let isConditionTrue; configConditions.forEach(configCondition => { @@ -702,5 +835,42 @@ App.EnhancedConfigsMixin = Em.Mixin.create(App.ConfigWithOverrideRecommendationP themeResource.get('configs').setEach('hiddenBySubSection', !valueAttributes.visible); } } + }, + + /** + * Data reordering before tabs rendering. + * Reorder all sections/subsections into rows based on their rowIndex + * @param tab + */ + processTab: function (tab) { + // process sections + let sectionRows = []; + const sections = tab.get('sections'); + for (let j = 0; j < sections.get('length'); j++) { + const section = sections.objectAt(j); + let sectionRow = sectionRows[section.get('rowIndex')]; + if (!sectionRow) { + sectionRow = sectionRows[section.get('rowIndex')] = []; + } + sectionRow.push(section); + + //process subsections + const subsections = section.get('subSections'); + let subsectionRows = []; + for (let k = 0; k < subsections.get('length'); k++) { + const subsection = subsections.objectAt(k); + let subsectionRow = subsectionRows[subsection.get('rowIndex')]; + if (!subsectionRow) { + subsectionRow = subsectionRows[subsection.get('rowIndex')] = []; + } + subsectionRow.push(subsection); + // leave a title gap if one of the subsection on the same row within the same section has title + if (subsection.get('displayName')) { + subsectionRow.hasTitleGap = true; + } + } + section.set('subsectionRows', subsectionRows); + } + tab.set('sectionRows', sectionRows); } }); 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 b3c99a5..7c3fbec 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 @@ -51,32 +51,6 @@ App.ServiceConfigLayoutTabView = Em.View.extend(App.ConfigOverridable, App.Loadi fieldToObserve: 'controller.recommendationsInProgress', classNames: ['enhanced-config-tab-content'], - /** - * ConfigType-Widget map - * key - widget type - * value - widget view - * @type {object} - */ - widgetTypeMap: { - checkbox: App.CheckboxConfigWidgetView, - combo: App.ComboConfigWidgetView, - directory: App.TextFieldConfigWidgetView, - directories: App.DirectoryConfigWidgetView, - list: App.ListConfigWidgetView, - password: App.PasswordConfigWidgetView, - 'radio-buttons': App.RadioButtonConfigWidgetView, - slider: App.SliderConfigWidgetView, - 'text-field': App.TextFieldConfigWidgetView, - 'time-interval-spinner': App.TimeIntervalSpinnerView, - toggle: App.ToggleConfigWidgetView, - 'text-area': App.StringConfigWidgetView, - 'label': App.LabelView, - 'test-db-connection': App.TestDbConnectionWidgetView - }, - - configNameWidgetMixinMap: { - num_llap_nodes: App.NumLlapNodesWidgetMixin - }, checkOverlay: function () { this.handleFieldChanges(); @@ -105,90 +79,6 @@ App.ServiceConfigLayoutTabView = Em.View.extend(App.ConfigOverridable, App.Loadi }, /** - * set {code} configs {code} array of subsection or subsection tab. - * Also correct widget should be used for each config (it's selected according to <code>widget.type</code> and - * <code>widgetTypeMap</code>). It may throw an error if needed widget can't be found in the <code>widgetTypeMap</code> - * @param containerObject - */ - setConfigsToContainer: function(containerObject) { - containerObject.set('configs', []); - - containerObject.get('configProperties').forEach(function (configId) { - - var config = App.configsCollection.getConfig(configId); - var stepConfig = this.get('controller.stepConfigs').findProperty('serviceName', Em.get(config, 'serviceName')); - if (!stepConfig) return; - - var configProperty = stepConfig.get('configs').findProperty('id', Em.get(config, 'id')); - if (!configProperty) return; - - containerObject.get('configs').pushObject(configProperty); - - var widget = this.getWidgetView(config); - Em.assert('Unknown config widget view for config ' + configProperty.get('id') + ' with type ' + Em.get(config, 'widgetType'), widget); - - var additionalProperties = { - widget: widget, - stackConfigProperty: config - }; - - var configConditions = App.ThemeCondition.find().filter(function (_configCondition) { - // Filter config condition depending on the value of another config - var conditionalConfigs = _configCondition.getWithDefault('configs', []).filterProperty('fileName', Em.get(config,'filename')).filterProperty('configName', Em.get(config,'name')); - // Filter config condition depending on the service existence or service state - var serviceConfigConditionFlag = ((_configCondition.get('configName') === Em.get(config,'name')) && (_configCondition.get('fileName') === Em.get(config,'filename')) && (_configCondition.get('resource') === 'service')); - var conditions; - - if (serviceConfigConditionFlag) { - var configCondition = { - configName: _configCondition.get('configName'), - fileName: _configCondition.get('fileName') - }; - conditions = conditionalConfigs.concat(configCondition) - } else { - conditions = conditionalConfigs; - } - return (conditions && conditions.length); - }, this); - - if (configConditions && configConditions.length) { - additionalProperties.configConditions = configConditions; - } - - var configAction = App.ConfigAction.find().filterProperty('fileName', Em.get(config,'filename')).findProperty('configName', Em.get(config,'name')); - - if (configAction) { - additionalProperties.configAction = configAction; - } - - configProperty.setProperties(additionalProperties); - - if (configProperty.get('overrides')) { - configProperty.get('overrides').setEach('stackConfigProperty', config); - } - if (configProperty.get('compareConfigs')) { - configProperty.get('compareConfigs').invoke('setProperties', { - isComparison: false, - stackConfigProperty: config - }); - } - }, this); - }, - - /** - * - * @param {object} config - * @returns {Em.View} - */ - getWidgetView: function (config) { - var configWidgetType = Em.get(config, 'widgetType'); - var name = Em.get(config, 'name'); - var mixin = this.get('configNameWidgetMixinMap')[name]; - var viewClass = this.get('widgetTypeMap')[configWidgetType]; - return Em.isNone(mixin) ? viewClass : viewClass.extend(mixin); - }, - - /** * changes active subsection tab * @param event */ @@ -208,7 +98,6 @@ App.ServiceConfigLayoutTabView = Em.View.extend(App.ConfigOverridable, App.Loadi this.set('dataIsReady', false); this.set('content.isConfigsPrepared', false); this._super(); - this.prepareConfigProperties(); if (this.get('controller.isCompareMode')) { this.get('parentView').filterEnhancedConfigs(); } diff --git a/ambari-web/app/views/common/configs/service_config_view.js b/ambari-web/app/views/common/configs/service_config_view.js index 590c0bc..4051206 100644 --- a/ambari-web/app/views/common/configs/service_config_view.js +++ b/ambari-web/app/views/common/configs/service_config_view.js @@ -252,7 +252,6 @@ App.ServiceConfigView = Em.View.extend({ if (advancedTab) { advancedTab.set('isRendered', advancedTab.get('isActive')); } - this.processTabs(tabs); return tabs; }.property('controller.selectedService.serviceName'), @@ -292,41 +291,6 @@ App.ServiceConfigView = Em.View.extend({ }, /** - * Data reordering before rendering. - * Reorder all sections/subsections into rows based on their rowIndex - * @param tabs - */ - processTabs: function (tabs) { - for (var i = 0; i < tabs.length; i++) { - var tab = tabs[i]; - - // process sections - var sectionRows = []; - var sections = tab.get('sections'); - for (var j = 0; j < sections.get('length'); j++) { - var section = sections.objectAt(j); - var sectionRow = sectionRows[section.get('rowIndex')]; - if (!sectionRow) { sectionRow = sectionRows[section.get('rowIndex')] = []; } - sectionRow.push(section); - - //process subsections - var subsections = section.get('subSections'); - var subsectionRows = []; - for (var k = 0; k < subsections.get('length'); k++) { - var subsection = subsections.objectAt(k); - var subsectionRow = subsectionRows[subsection.get('rowIndex')]; - if (!subsectionRow) { subsectionRow = subsectionRows[subsection.get('rowIndex')] = []; } - subsectionRow.push(subsection); - // leave a title gap if one of the subsection on the same row within the same section has title - if (subsection.get('displayName')) {subsectionRow.hasTitleGap = true;} - } - section.set('subsectionRows', subsectionRows); - } - tab.set('sectionRows', sectionRows); - } - }, - - /** * Mark isHiddenByFilter flag for configs, sub-sections, and tab * @method filterEnhancedConfigs */ diff --git a/ambari-web/app/views/wizard/step7/databases_tab_view.js b/ambari-web/app/views/wizard/step7/databases_tab_view.js index ff052cd..5e8a74c 100644 --- a/ambari-web/app/views/wizard/step7/databases_tab_view.js +++ b/ambari-web/app/views/wizard/step7/databases_tab_view.js @@ -48,11 +48,7 @@ App.DatabasesTabOnStep7View = Em.View.extend({ $('.loading').empty(); this._super(); }, - tabs: function () { - var tabs = this.get('tabModels'); - this.processTabs(tabs); - return tabs; - }.property('tabModels'), + tabs: Em.computed.alias('tabModels'), hideTabs: function () { this.get('tabs').forEach(function (tab) { tab.set('isHidden', tab.get('isConfigsPrepared') && tab.get('isHiddenByFilter')); diff --git a/ambari-web/app/views/wizard/step7/directories_tab_view.js b/ambari-web/app/views/wizard/step7/directories_tab_view.js index 8353bf0..7a0eee1 100644 --- a/ambari-web/app/views/wizard/step7/directories_tab_view.js +++ b/ambari-web/app/views/wizard/step7/directories_tab_view.js @@ -72,7 +72,6 @@ App.DirectoriesTabOnStep7View = Em.View.extend({ themeTemplate: require('templates/wizard/step7/directories_theme_layout'), tabs: function () { var tabs = App.Tab.find().filterProperty('themeName', 'directories').filterProperty('serviceName', this.get('controller.selectedService.serviceName')); - this.processTabs(tabs); return tabs; }.property('controller.selectedService.serviceName'), updateFilterCounters: function () { -- To stop receiving notification emails like this one, please contact ababiic...@apache.org.