http://git-wip-us.apache.org/repos/asf/ambari/blob/b5d43620/ambari-web/app/data/HDP2/ui_properties.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/data/HDP2/ui_properties.js b/ambari-web/app/data/HDP2/ui_properties.js new file mode 100644 index 0000000..9ed711b --- /dev/null +++ b/ambari-web/app/data/HDP2/ui_properties.js @@ -0,0 +1,60 @@ +/** + * 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. + */ + +module.exports = [ + { + "name": "oozie_hostname", + "displayName": "Database Host", + "displayType": "host", + "serviceName": "OOZIE", + "filename": "oozie-env.xml", + "category": "OOZIE_SERVER", + "index": 3 + }, + { + "name": "hive_hostname", + "displayName": "Database Host", + "description": "Specify the host on which the database is hosted", + "displayType": "host", + "isRequiredByAgent": false, + "serviceName": "HIVE", + "filename": "hive-env.xml", + "category": "HIVE_METASTORE", + "index": 3 + }, + { + "name": "admin_principal", + "displayName": "Admin principal", + "description": "Admin principal used to create principals and export key tabs (e.g. admin/ad...@example.com).", + "isRequiredByAgent": false, + "serviceName": "KERBEROS", + "filename": "krb5-conf.xml", + "category": "Kadmin", + "index": 1 + }, + { + "name": "admin_password", + "displayName": "Admin password", + "displayType": "password", + "isRequiredByAgent": false, + "serviceName": "KERBEROS", + "filename": "krb5-conf.xml", + "category": "Kadmin", + "index": 2 + } +]; \ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/b5d43620/ambari-web/app/mappers/configs/stack_config_properties_mapper.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/mappers/configs/stack_config_properties_mapper.js b/ambari-web/app/mappers/configs/stack_config_properties_mapper.js index 5edeefc..7ed9193 100644 --- a/ambari-web/app/mappers/configs/stack_config_properties_mapper.js +++ b/ambari-web/app/mappers/configs/stack_config_properties_mapper.js @@ -18,30 +18,48 @@ var App = require('app'); App.stackConfigPropertiesMapper = App.QuickDataMapper.create({ - model: App.StackConfigProperty, - config: { + /** + * this is map for configs that will be stored as plan objects + */ + configToPlain: { id: 'id', name: 'StackConfigurations.property_name', - display_name: 'StackConfigurations.property_display_name', - file_name: 'StackConfigurations.type', + displayName: 'StackConfigurations.property_display_name', + fileName: 'StackConfigurations.type', + filename: 'StackConfigurations.type', description: 'StackConfigurations.property_description', value: 'StackConfigurations.property_value', - recommended_value: 'StackConfigurations.property_value', - type: 'StackConfigurations.property_type', - service_name: 'StackConfigurations.service_name', - stack_name: 'StackConfigurations.stack_name', - stack_version: 'StackConfigurations.stack_version', - property_depended_by: 'StackConfigurations.property_depended_by', - property_depends_on: 'StackConfigurations.property_depends_on', - value_attributes: 'StackConfigurations.property_value_attributes', - is_final: 'recommended_is_final', - recommended_is_final: 'recommended_is_final', - supports_final: 'supports_final', - widget: 'widget', - /**** ui properties ***/ - display_type: 'display_type', + recommendedValue: 'StackConfigurations.property_value', + serviceName: 'StackConfigurations.service_name', + stackName: 'StackConfigurations.stack_name', + stackVersion: 'StackConfigurations.stack_version', + isOverridable: 'StackConfigurations.property_value_attributes.overridable', + isVisible: 'StackConfigurations.property_value_attributes.visible', + showLabel: 'StackConfigurations.property_value_attributes.show_property_name', + displayType: 'StackConfigurations.property_value_attributes.type', + unit: 'StackConfigurations.property_value_attributes.unit', + + isRequired: 'is_required', + isReconfigurable: 'is_reconfigurable', + isEditable: 'is_editable', + isRequiredByAgent: 'is_required_by_agent', + + isFinal: 'recommended_is_final', + recommendedIsFinal: 'recommended_is_final', + supportsFinal: 'supports_final', + + propertyDependedBy: 'StackConfigurations.property_depended_by', + propertyDependsOn: 'StackConfigurations.property_depends_on', + valueAttributes: 'StackConfigurations.property_value_attributes', + + /**** ui properties, ib future should be moved to BE ***/ category: 'category', - index: 'index' + index: 'index', + /*** temp properties until all radio buttons type will be moved to BE **/ + radioName: 'radioName', + options: 'options', + /*** temp property until visibility dependencies will be retrieved from stack **/ + dependentConfigPattern: 'dependentConfigPattern' }, map: function (json) { @@ -64,6 +82,30 @@ App.stackConfigPropertiesMapper = App.QuickDataMapper.create({ config.id = App.config.configId(config.StackConfigurations.property_name, configType); config.recommended_is_final = config.StackConfigurations.final === "true"; config.supports_final = !!configTypeInfo[configType] && configTypeInfo[configType].supports.final === "true"; + + var attributes = config.StackConfigurations.property_value_attributes; + if (attributes) { + config.is_required = !attributes.empty_value_valid; + config.is_reconfigurable = !attributes.editable_only_at_install; + config.is_editable = !attributes.read_only; + config.is_required_by_agent = !attributes.ui_only_property; + } + + if (!config.StackConfigurations.property_display_name) { + config.StackConfigurations.property_display_name = config.StackConfigurations.property_name; + } + + if (!config.StackConfigurations.service_name) { + config.StackConfigurations.service_name = 'MISC'; + } + + if (!attributes || !attributes.type) { + if (!attributes) { + config.StackConfigurations.property_value_attributes = {}; + } + config.StackConfigurations.property_value_attributes.type = App.config.getDefaultDisplayType(config.StackConfigurations.property_name, + config.StackConfigurations.type, config.StackConfigurations.property_value, config.StackConfigurations.service_name); + } // Map from /dependencies to property_depended_by config.StackConfigurations.property_depended_by = []; if (config.dependencies && config.dependencies.length > 0) { @@ -93,11 +135,22 @@ App.stackConfigPropertiesMapper = App.QuickDataMapper.create({ * for now is not used; uncomment in will be needed * this.mergeWithUI(config); */ - this.mergeWithUI(config); - configs.push(this.parseIt(config, this.get('config'))); + if (this.isMiscService(config.StackConfigurations.property_type)) { + this.handleSpecialProperties(config); + } else { + this.mergeWithUI(config); + } + + var staticConfigInfo = this.parseIt(config, this.get('configToPlain')); + var v = Em.isNone(staticConfigInfo.recommendedValue) ? staticConfigInfo.recommendedValue : staticConfigInfo.value; + staticConfigInfo.value = staticConfigInfo.recommendedValue = App.config.formatPropertyValue(staticConfigInfo, v); + staticConfigInfo.isSecure = App.config.getIsSecure(staticConfigInfo.name); + staticConfigInfo.isUserProperty = false; + App.configsCollection.add(staticConfigInfo); + }, this); }, this); - App.store.loadMany(this.get('model'), configs); + this.addUIOnlyProperties(configs); } console.timeEnd('App.stackConfigPropertiesMapper execution time'); }, @@ -113,19 +166,67 @@ App.stackConfigPropertiesMapper = App.QuickDataMapper.create({ mergeWithUI: function(config) { var c = config.StackConfigurations; var uiConfigProperty = this.getUIConfig(c.property_name, c.type); - var advancedData = App.config.advancedConfigIdentityData(c); - if (!c.property_display_name) { - c.property_display_name = App.config.getPropertyIfExists('displayName', App.config.getDefaultDisplayName(c.property_name, c.type), advancedData, uiConfigProperty); + config.category = uiConfigProperty && uiConfigProperty.category ? uiConfigProperty.category : App.config.getDefaultCategory(true, c.type); + + if (uiConfigProperty) { + config.index = uiConfigProperty.index || Infinity; + if (uiConfigProperty.displayType) { + c.property_value_attributes.type = uiConfigProperty.displayType; + config.radioName = uiConfigProperty.radioName; + config.options = uiConfigProperty.options; + } + config.dependentConfigPattern = uiConfigProperty.dependentConfigPattern; + } + }, + + /** + * + * @param config + */ + handleSpecialProperties: function(config) { + if (!config.StackConfigurations.property_type.contains('ADDITIONAL_USER_PROPERTY')) { + config.index = App.StackService.displayOrder.indexOf(config.StackConfigurations.service_name) + 1 || 30; + config.StackConfigurations.property_value_attributes.type = 'user'; } - c.service_name = App.config.getPropertyIfExists('serviceName', c.service_name, advancedData, uiConfigProperty); + config.StackConfigurations.service_name = 'MISC'; + config.category = 'Users and Groups'; + }, - config.category = App.config.getPropertyIfExists('category', App.config.getDefaultCategory(true, c.type), advancedData, uiConfigProperty); - config.display_type = App.config.getPropertyIfExists('displayType', Em.get(c, 'property_value_attributes.type') || App.config.getDefaultDisplayType(c.property_name, c.type, c.property_value), advancedData, uiConfigProperty); - config.index = App.config.getPropertyIfExists('index', null, advancedData, uiConfigProperty); + /** + * defines if property should refer to MISC tab + * @param type + * @returns {Boolean} + */ + isMiscService: function(type) { + return type.length && (type.contains('USER') || type.contains('GROUP') || type.contains('ADDITIONAL_USER_PROPERTY')); }, /** + * add properties that doesn't have any info on stack definition + * @param configs + */ + addUIOnlyProperties: function(configs) { + require('data/HDP2/ui_properties').concat(require('data/HDP2/alert_notification')).forEach(function(p) { + configs.push({ + id: App.config.configId(p.name, p.filename), + name: p.name, + display_name: p.displayName, + file_name: p.filename, + description: p.description || '', + is_required_by_agent: p.isRequiredByAgent !== false, // by default is_required_by_agent should be true + service_name: p.serviceName, + supports_final: false, + category: p.category, + index: p.index, + stack_name: App.get('currentStackName'), + stack_version: App.get('currentStackVersionNumber') + }); + p.id = App.config.configId(p.name, p.filename); + App.configsCollection.add(p); + }); + }, + /** * returns config with such name and fileName if there is such on UI * otherwise returns null * @param propertyName http://git-wip-us.apache.org/repos/asf/ambari/blob/b5d43620/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 5815955..0fecf81 100644 --- a/ambari-web/app/mappers/configs/themes_mapper.js +++ b/ambari-web/app/mappers/configs/themes_mapper.js @@ -175,16 +175,20 @@ App.themesMapper = App.QuickDataMapper.create({ } else if (subSectionId) { var subSection = App.SubSection.find(subSectionId); } - var configProperty = App.StackConfigProperty.find(configId); + var configProperty = App.configsCollection.getConfig(configId); var dependsOnConfigs = configLink["depends-on"] || []; - if (configProperty.get('id') && subSection) { - subSection.get('configProperties').pushObject(configProperty); - configProperty.set('subSection', subSection); - } else if (configProperty.get('id') && subSectionTab) { - subSectionTab.get('configProperties').pushObject(configProperty); - configProperty.set('subSectionTab', subSectionTab); + if (configProperty && subSection) { + var cp = subSection.get('configProperties').contains(configProperty.id); + if (!cp) { + subSection.set('configProperties', subSection.get('configProperties').concat(configProperty.id)); + } + } else if (configProperty && subSectionTab) { + var cp = subSectionTab.get('configProperties').contains(configProperty.id); + if (!cp) { + subSectionTab.set('configProperties', subSectionTab.get('configProperties').concat(configProperty.id)); + } } else { var valueAttributes = configLink["property_value_attributes"]; if (valueAttributes) { @@ -193,12 +197,11 @@ App.themesMapper = App.QuickDataMapper.create({ // 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'; - var configName = split[1]; - var uiOnlyConfig = App.uiOnlyConfigDerivedFromTheme.filterProperty('filename', fileName).findProperty('name', configName); + var fileName = split[0] + '.xml', configName = split[1], id = App.config.configId(configName, fileName); + var uiOnlyConfig = App.configsCollection.getConfig(id); if (!uiOnlyConfig) { - var coreObject = { - id: configName + '_' + split[0], + configProperty = { + id: id, isRequiredByAgent: false, showLabel: false, isOverridable: false, @@ -207,18 +210,30 @@ App.themesMapper = App.QuickDataMapper.create({ isUserProperty: false, filename: fileName, serviceName: serviceName, - subSection: subSection + stackName: App.get('currentStackName'), + stackVersion: App.get('currentStackVersionNumber') }; - var uiOnlyConfigDerivedFromTheme = Em.Object.create(App.config.createDefaultConfig(configName, serviceName, fileName, false, coreObject)); - App.uiOnlyConfigDerivedFromTheme.pushObject(uiOnlyConfigDerivedFromTheme); + App.configsCollection.add(configProperty); + + if (subSection) { + var cp = subSection.get('configProperties').contains(configProperty.id); + if (!cp) { + subSection.set('configProperties', subSection.get('configProperties').concat(configProperty.id)); + } + } else if (subSectionTab) { + var cp = subSectionTab.get('configProperties').contains(configProperty.id); + if (!cp) { + subSectionTab.set('configProperties', subSectionTab.get('configProperties').concat(configProperty.id)); + } + } } } } } // map all the configs which conditionally affect the value attributes of a config - if (dependsOnConfigs && dependsOnConfigs.length) { - this.mapThemeConfigConditions(dependsOnConfigs, uiOnlyConfigDerivedFromTheme || configProperty); + if (dependsOnConfigs && dependsOnConfigs.length && configProperty) { + this.mapThemeConfigConditions(dependsOnConfigs, configProperty); } }, this); @@ -232,10 +247,10 @@ App.themesMapper = App.QuickDataMapper.create({ mapThemeConfigConditions: function(configConditions, configProperty) { var configConditionsCopy = []; configConditions.forEach(function(_configCondition, index){ - var configCondition = $.extend({},_configCondition); - configCondition.id = configProperty.get('id') + '_' + index; - configCondition.config_name = configProperty.get('name'); - configCondition.file_name = configProperty.get('filename'); + var configCondition = $.extend({}, _configCondition); + configCondition.id = configProperty.id + '_' + index; + configCondition.config_name = configProperty.name; + configCondition.file_name = configProperty.filename; if (_configCondition.configs && _configCondition.configs.length) { configCondition.configs = _configCondition.configs.map(function (item) { var result = {}; @@ -294,18 +309,18 @@ App.themesMapper = App.QuickDataMapper.create({ mapThemeWidgets: function(json) { Em.getWithDefault(json, "ThemeInfo.theme_data.Theme.configuration.widgets", []).forEach(function(widget) { var configId = this.getConfigId(widget); - var configProperty = App.StackConfigProperty.find(configId); + var configProperty = App.configsCollection.getConfig(configId); - if (configProperty.get('id')) { - configProperty.set('widget', widget.widget); - configProperty.set('widgetType', Em.get(widget, 'widget.type')); + if (configProperty) { + configProperty.widget = widget.widget; + configProperty.widgetType = Em.get(widget, 'widget.type'); } else { var split = widget.config.split("/"); var fileName = split[0] + '.xml'; var configName = split[1]; - var uiOnlyProperty = App.uiOnlyConfigDerivedFromTheme.filterProperty('filename',fileName).findProperty('name',configName); + var uiOnlyProperty = App.configsCollection.getConfigByName(configName, fileName); if (uiOnlyProperty) { - uiOnlyProperty.set('widget', widget.widget); + uiOnlyProperty.widget = widget.widget; uiOnlyProperty.set('widgetType', Em.get(widget, 'widget.type')); } } http://git-wip-us.apache.org/repos/asf/ambari/blob/b5d43620/ambari-web/app/mixins/common/configs/configs_comparator.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/mixins/common/configs/configs_comparator.js b/ambari-web/app/mixins/common/configs/configs_comparator.js index ab8cbb4..9a4e9d5 100644 --- a/ambari-web/app/mixins/common/configs/configs_comparator.js +++ b/ambari-web/app/mixins/common/configs/configs_comparator.js @@ -304,7 +304,7 @@ App.ConfigsComparator = Em.Mixin.create({ * @method getMockConfig */ getMockConfig: function (name, serviceName, filename) { - var undefinedConfig = { + var undefinedConfig = App.configsCollection.getConfigByName(name, filename) || { description: name, displayName: name, isOverridable: false, @@ -318,12 +318,11 @@ App.ConfigsComparator = Em.Mixin.create({ name: name, filename: filename, serviceName: serviceName, + category: App.config.getDefaultCategory(false, filename), value: Em.I18n.t('common.property.undefined'), isMock: true, displayType: 'label' }; - var category = App.config.identifyCategory(undefinedConfig); - undefinedConfig.category = category && category.name; return App.ServiceConfigProperty.create(undefinedConfig); }, http://git-wip-us.apache.org/repos/asf/ambari/blob/b5d43620/ambari-web/app/mixins/common/configs/enhanced_configs.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/mixins/common/configs/enhanced_configs.js b/ambari-web/app/mixins/common/configs/enhanced_configs.js index ae1a147..fd50fa6 100644 --- a/ambari-web/app/mixins/common/configs/enhanced_configs.js +++ b/ambari-web/app/mixins/common/configs/enhanced_configs.js @@ -189,8 +189,8 @@ App.EnhancedConfigsMixin = Em.Mixin.create({ var cleanDependencies = this.get('_dependentConfigValues').reject(function(item) { if ('hadoop.proxyuser'.contains(Em.get(item, 'name'))) return false; if (installedServices.contains(Em.get(item, 'serviceName'))) { - var stackProperty = App.StackConfigProperty.find(App.config.configId(item.propertyName, item.fileName)); - var parentConfigs = stackProperty && stackProperty.get('propertyDependsOn'); + var stackProperty = App.configsCollection.getConfigByName(item.propertyName, item.fileName); + var parentConfigs = stackProperty && stackProperty.propertyDependsOn; if (!parentConfigs || !parentConfigs.length) { return true; } @@ -469,10 +469,6 @@ App.EnhancedConfigsMixin = Em.Mixin.create({ }); if (!updateOnlyBoundaries && !parentPropertiesNames.contains(App.config.configId(propertyName, key)) && initialValue != recommendedValue) { //on first initial request we don't need to change values - var groupName = group && Em.get(group, 'name'); - var dependentProperty = this.get('_dependentConfigValues').find(function (dcv) { - return dcv.propertyName === propertyName && dcv.fileName === key && dcv.configGroup === groupName; - }); if (dependentProperty) { Em.set(dependentProperty, 'value', initialValue); Em.set(dependentProperty, 'recommendedValue', recommendedValue); @@ -553,10 +549,6 @@ App.EnhancedConfigsMixin = Em.Mixin.create({ }); }.property(), - stackConfigsMap: function () { - return App.StackConfigProperty.find().toArray().toMapByProperty('id'); - }.property(), - /** * Save property attributes received from recommendations. These attributes are minimum, maximum, * increment_step. Attributes are stored in <code>App.StackConfigProperty</code> model. @@ -571,7 +563,6 @@ App.EnhancedConfigsMixin = Em.Mixin.create({ var installedServices = this.get('installedServices'); var wizardController = this.get('wizardController'); var fileNamesToUpdate = wizardController ? this.get('_fileNamesToUpdate') : []; - var stackConfigsMap = this.get('stackConfigsMap'); Em.keys(configs).forEach(function (siteName) { var fileName = App.config.getOriginalFileName(siteName); var service = App.config.get('serviceByConfigTypeMap')[siteName]; @@ -582,7 +573,7 @@ App.EnhancedConfigsMixin = Em.Mixin.create({ var properties = configs[siteName].property_attributes || {}; Em.keys(properties).forEach(function (propertyName) { var cp = configProperties.findProperty('name', propertyName); - var stackProperty = stackConfigsMap[App.config.configId(propertyName, siteName)]; + var stackProperty = App.configsCollection.getConfigByName(propertyName, siteName); var attributes = properties[propertyName] || {}; Em.keys(attributes).forEach(function (attributeName) { if (attributeName == 'delete' && cp) { @@ -624,16 +615,16 @@ App.EnhancedConfigsMixin = Em.Mixin.create({ } } else if (stackProperty) { if (selectedConfigGroup) { - if (!stackProperty.get('valueAttributes')[selectedConfigGroup]) { + if (!stackProperty.valueAttributes[selectedConfigGroup]) { /** create not default group object for updating such values as min/max **/ - Em.set(stackProperty.get('valueAttributes'), selectedConfigGroup, {}); + Em.set(stackProperty.valueAttributes, selectedConfigGroup, {}); } - if (stackProperty.get('valueAttributes')[selectedConfigGroup][attributeName] != attributes[attributeName]) { - Em.set(stackProperty.get('valueAttributes')[selectedConfigGroup], attributeName, attributes[attributeName]); + if (stackProperty.valueAttributes[selectedConfigGroup][attributeName] != attributes[attributeName]) { + Em.set(stackProperty.valueAttributes[selectedConfigGroup], attributeName, attributes[attributeName]); self.toggleProperty('forceUpdateBoundaries'); } } else { - Em.set(stackProperty.get('valueAttributes'), attributeName, attributes[attributeName]); + Em.set(stackProperty.valueAttributes, attributeName, attributes[attributeName]); } } }); @@ -696,9 +687,7 @@ App.EnhancedConfigsMixin = Em.Mixin.create({ this.get('_dependentConfigValues').removeObject(propertyToAdd); } var originalFileName = App.config.getOriginalFileName(Em.get(propertyToAdd, 'fileName')); - var predefinedProperty = App.config.get('preDefinedSiteProperties') - .filterProperty('filename', originalFileName) - .findProperty('name', Em.get(propertyToAdd, 'propertyName')); + var stackProperty = App.configsCollection.getConfigByName(Em.get(propertyToAdd, 'propertyName'), Em.get(propertyToAdd, 'fileName')); var addedProperty = App.ServiceConfigProperty.create({ name: Em.get(propertyToAdd, 'propertyName'), displayName: Em.get(propertyToAdd, 'propertyName'), @@ -709,7 +698,7 @@ App.EnhancedConfigsMixin = Em.Mixin.create({ serviceName: stepConfigs.get('serviceName'), filename: originalFileName, isNotSaved: !Em.get(propertyToAdd, 'isDeleted'), - isRequired: predefinedProperty ? Em.getWithDefault(predefinedProperty, 'isRequired', true) : true + isRequired: stackProperty && stackProperty.isRequired !== false }); stepConfigs.get('configs').pushObject(addedProperty); addedProperty.validate(); http://git-wip-us.apache.org/repos/asf/ambari/blob/b5d43620/ambari-web/app/mixins/wizard/addSecurityConfigs.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/mixins/wizard/addSecurityConfigs.js b/ambari-web/app/mixins/wizard/addSecurityConfigs.js index 917b2be..59fc045 100644 --- a/ambari-web/app/mixins/wizard/addSecurityConfigs.js +++ b/ambari-web/app/mixins/wizard/addSecurityConfigs.js @@ -191,10 +191,7 @@ App.AddSecurityConfigs = Em.Mixin.create({ * @private */ _getDisplayNameForConfig: function(name, fileName) { - var c = App.config.get('allPreDefinedSiteProperties').findProperty('name', name); - var dName = c ? Em.get(c, 'displayName') : ''; - dName = Em.isEmpty(dName) ? name : dName; - return fileName == 'cluster-env' ? App.format.normalizeName(name) : dName; + return fileName == 'cluster-env' ? App.format.normalizeName(name) : name; }, /** http://git-wip-us.apache.org/repos/asf/ambari/blob/b5d43620/ambari-web/app/models.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/models.js b/ambari-web/app/models.js index 9440dea..d221651 100644 --- a/ambari-web/app/models.js +++ b/ambari-web/app/models.js @@ -65,7 +65,6 @@ require('models/configs/service_config_version'); require('models/configs/stack_config_property'); require('models/configs/config_group'); require('models/configs/config_version'); -require('models/configs/config_property'); require('models/configs/theme/tab'); require('models/configs/theme/section'); require('models/configs/theme/sub_section'); http://git-wip-us.apache.org/repos/asf/ambari/blob/b5d43620/ambari-web/app/models/configs/stack_config_property.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/models/configs/stack_config_property.js b/ambari-web/app/models/configs/stack_config_property.js index 39a4857..8451fcf 100644 --- a/ambari-web/app/models/configs/stack_config_property.js +++ b/ambari-web/app/models/configs/stack_config_property.js @@ -171,11 +171,10 @@ App.StackConfigProperty = DS.Model.extend({ /******************************* UI properties ****************************************/ /** - * defines what kind of value this property contains - * ex: string, digits, number, directories, custom - * @property {string} + * if property should be saved to server + * @property {boolean} */ - displayType: DS.attr('string', {defaultValue: 'string'}), + isRequiredByAgent: DS.attr('boolean', {defaultValue: true}), /** * defines category name of property @@ -202,15 +201,20 @@ App.StackConfigProperty = DS.Model.extend({ index: DS.attr('number', {defaultValue: null}), /** + * defines what kind of value this property contains + * ex: string, digits, number, directories, custom + * @property {string} + */ + displayType: function() { + return this.getAttribute('type', 'string'); + }.property('valueAttributes.type'), + + /** * defines if the property can be overriden in the host config group * @type {boolean} */ isOverridable: function() { - var result = true; - if (this.get('valueAttributes') && !Em.none(this.get('valueAttributes.overridable'))) { - result = !!this.get('valueAttributes.overridable'); - } - return result; + return this.getAttribute('overridable', true); }.property('valueAttributes.overridable'), /** @@ -218,11 +222,7 @@ App.StackConfigProperty = DS.Model.extend({ * @type {boolean} */ isVisible: function() { - var result = true; - if (this.get('valueAttributes') && !Em.none(this.get('valueAttributes.visible'))) { - result = !!this.get('valueAttributes.visible'); - } - return result; + return this.getAttribute('visible', true); }.property('valueAttributes.visible'), /** @@ -230,11 +230,7 @@ App.StackConfigProperty = DS.Model.extend({ * @type {boolean} */ isRequired: function() { - var result = true; - if (this.get('valueAttributes') && !Em.none(this.get('valueAttributes.empty_value_valid'))) { - result = !this.get('valueAttributes.empty_value_valid'); - } - return result; + return !this.getAttribute('empty_value_valid', false); }.property('valueAttributes.empty_value_valid'), /** @@ -242,11 +238,7 @@ App.StackConfigProperty = DS.Model.extend({ * @type {boolean} */ isReconfigurable: function() { - var result = true; - if (this.get('valueAttributes') && !Em.none(this.get('valueAttributes.editable_only_at_install'))) { - result = !this.get('valueAttributes.editable_only_at_install'); - } - return result; + return !this.getAttribute('editable_only_at_install', false); }.property('valueAttributes.editable_only_at_install'), /** @@ -254,11 +246,7 @@ App.StackConfigProperty = DS.Model.extend({ * @type {boolean} */ showLabel: function() { - var result = true; - if (this.get('valueAttributes') && !Em.none(this.get('valueAttributes.show_property_name'))) { - result = !!this.get('valueAttributes.show_property_name'); - } - return result; + return this.getAttribute('show_property_name', true); }.property('valueAttributes.show_property_name'), /** @@ -266,11 +254,7 @@ App.StackConfigProperty = DS.Model.extend({ * @type {boolean} */ isEditable: function() { - var result = true; - if (this.get('valueAttributes') && !Em.none(this.get('valueAttributes.read_only'))) { - result = !!this.get('valueAttributes.read_only'); - } - return result; + return this.getAttribute('read_only' ,true); }.property('valueAttributes.read_only'), /** @@ -278,20 +262,22 @@ App.StackConfigProperty = DS.Model.extend({ * @type {boolean} */ unit: function() { - var result = ''; - if (this.get('valueAttributes') && !Em.empty(this.get('valueAttributes.unit'))) { - result = this.get('valueAttributes.unit'); - } - return result; + return this.getAttribute('unit', ''); }.property('valueAttributes.unit'), /** - * Does config property has a valid value defined in the stack - * @type {boolean} + * + * @param propertyName + * @param defaultValue + * @returns {string} */ - isValueDefined: function() { - return !Em.none(this.get('value')); - }.property('id') + getAttribute: function(propertyName, defaultValue) { + var result = defaultValue; + if (!Em.empty(this.get('valueAttributes.' + propertyName))) { + result = this.get('valueAttributes.' + propertyName); + } + return result; + } }); http://git-wip-us.apache.org/repos/asf/ambari/blob/b5d43620/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 ce26a3c..eea3802 100644 --- a/ambari-web/app/models/configs/theme/sub_section.js +++ b/ambari-web/app/models/configs/theme/sub_section.js @@ -63,9 +63,9 @@ App.SubSection = DS.Model.extend({ section: DS.belongsTo('App.Section'), /** - * @type {App.StackConfigProperty[]} + * @type {String[]} */ - configProperties: DS.hasMany('App.StackConfigProperty'), + configProperties: DS.attr('array', {defaultValue: []}), /** * @type {App.SubSectionTab[]} http://git-wip-us.apache.org/repos/asf/ambari/blob/b5d43620/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 d5d5349..f78f39e 100644 --- a/ambari-web/app/models/configs/theme/sub_section_tab.js +++ b/ambari-web/app/models/configs/theme/sub_section_tab.js @@ -38,9 +38,9 @@ App.SubSectionTab = DS.Model.extend({ subSection: DS.belongsTo('App.SubSection'), /** - * @type {App.StackConfigProperty[]} + * @type {String[]} */ - configProperties: DS.hasMany('App.StackConfigProperty'), + configProperties: DS.attr('array', {defaultValue: []}), /** * @type {App.ServiceConfigProperty[]} http://git-wip-us.apache.org/repos/asf/ambari/blob/b5d43620/ambari-web/app/utils/config.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/utils/config.js b/ambari-web/app/utils/config.js index d9ba911..7e53632 100644 --- a/ambari-web/app/utils/config.js +++ b/ambari-web/app/utils/config.js @@ -17,6 +17,7 @@ */ var App = require('app'); +require('utils/configs_collection'); var stringUtils = require('utils/string_utils'); var configTagFromFileNameMap = {}; @@ -90,9 +91,6 @@ App.config = Em.Object.create({ }, setPreDefinedServiceConfigs: function (isMiscTabToBeAdded) { - var configs = this.get('preDefinedSiteProperties'); - var services = []; - var self = this; var stackServices = App.StackService.find().filterProperty('id'); // Only include services that has configTypes related to them for service configuration page var servicesWithConfigTypes = stackServices.filter(function (service) { @@ -117,21 +115,7 @@ App.config = Em.Object.create({ } else { allTabs = servicesWithConfigTypes; } - - allTabs.forEach(function (service) { - var configTypes = Em.keys(service.get('configTypes')); - // filter properties by service name and service config types - var serviceConfigs = configs.filterProperty('serviceName', service.get('serviceName')).filter(function(property) { - var propFilename = self.getConfigTagFromFileName(Em.getWithDefault(property, 'filename', '')); - if (propFilename && service.get('serviceName') != 'MISC') { - return configTypes.contains(propFilename); - } - return true; - }); - service.set('configs', serviceConfigs); - services.push(service); - }); - this.set('preDefinedServiceConfigs', services); + this.set('preDefinedServiceConfigs', allTabs); }, secureConfigs: require('data/HDP2/secure_mapping'), @@ -241,37 +225,17 @@ App.config = Em.Object.create({ */ mergePredefinedWithSaved: function (configGroups, serviceName, selectedConfigGroup, canEdit) { var configs = []; - var serviceConfigProperty; var serviceByConfigTypeMap = this.get('serviceByConfigTypeMap'); configGroups.forEach(function (siteConfig) { - var service = serviceByConfigTypeMap[siteConfig.type]; - if (service && serviceName != 'MISC') { - serviceName = service.get('serviceName'); - } var filename = App.config.getOriginalFileName(siteConfig.type); var attributes = siteConfig['properties_attributes'] || {}; var finalAttributes = attributes.final || {}; var properties = siteConfig.properties || {}; - var uiOnlyConfigsObj = {}; - var uiOnlyConfigDerivedFromTheme = App.uiOnlyConfigDerivedFromTheme.toArray(); - uiOnlyConfigDerivedFromTheme.forEach(function(item) { - if (filename === item.filename) { - uiOnlyConfigsObj[item.name] = item.value; - } - }); - properties = $.extend({}, properties, uiOnlyConfigsObj); - for (var index in properties) { - var id = this.configId(index, siteConfig.type); - var preDefinedPropertyDef = this.get('preDefinedSitePropertiesMap')[id]; - var uiOnlyConfigFromTheme = uiOnlyConfigDerivedFromTheme.findProperty('name', index); - var configsPropertyDef = preDefinedPropertyDef || uiOnlyConfigFromTheme; - var advancedConfig = App.StackConfigProperty.find(id); - var isStackProperty = !!advancedConfig.get('id') || !!preDefinedPropertyDef; - var template = this.createDefaultConfig(index, serviceName, filename, isStackProperty, configsPropertyDef); - var serviceConfigObj = isStackProperty ? this.mergeStaticProperties(template, advancedConfig) : template; + var advancedConfig = App.configsCollection.getConfigByName(index, siteConfig.type); + var serviceConfigObj = advancedConfig || this.createDefaultConfig(index, serviceName, filename, false); if (serviceConfigObj.isRequiredByAgent !== false) { var formattedValue = this.formatPropertyValue(serviceConfigObj, properties[index]); @@ -279,10 +243,6 @@ App.config = Em.Object.create({ serviceConfigObj.isFinal = serviceConfigObj.savedIsFinal = finalAttributes[index] === "true"; serviceConfigObj.isEditable = this.getIsEditable(serviceConfigObj, selectedConfigGroup, canEdit); serviceConfigObj.isVisible = serviceConfigObj.isVisible !== false || serviceName === 'MISC'; - if (serviceName!='MISC' && serviceConfigObj.category === "Users and Groups") { - serviceConfigObj.category = this.getDefaultCategory(advancedConfig, filename); - } - serviceConfigObj.serviceName = serviceName; } var serviceConfigProperty = App.ServiceConfigProperty.create(serviceConfigObj); @@ -318,9 +278,9 @@ App.config = Em.Object.create({ recommendedIsFinal: null, supportsFinal: this.shouldSupportFinal(serviceName, fileName), serviceName: serviceName, - displayName: this.getDefaultDisplayName(name, fileName), + displayName: name, displayType: this.getDefaultDisplayType(name, fileName, coreObject ? coreObject.value : '', serviceName), - description: null, + description: '', category: this.getDefaultCategory(definedInStack, fileName), isSecureConfig: this.getIsSecure(name), showLabel: true, @@ -337,7 +297,6 @@ App.config = Em.Object.create({ dependentConfigPattern: null, options: null, radioName: null, - belongsToService: [], widgetType: null }; return Object.keys(coreObject|| {}).length ? @@ -427,26 +386,17 @@ App.config = Em.Object.create({ * @returns {string} */ getDefaultDisplayType: function(name, type, value, serviceName) { - if (this.isContentProperty(name, type)) { - return 'content'; - } else if (serviceName && serviceName == 'FALCON' && this.getConfigTagFromFileName(type) == 'oozie-site') { + if (serviceName && serviceName == 'FALCON' && this.getConfigTagFromFileName(type) == 'oozie-site') { /** * This specific type for 'oozie-site' configs of FALCON service. * After this type will be moved to stack definition this hard-code should be removed */ return 'custom'; + } else if (name == 'content') { + return 'content'; + } else { + return value && !stringUtils.isSingleLine(value) ? 'multiLine' : 'string'; } - return value && !stringUtils.isSingleLine(value) ? 'multiLine' : 'string'; - }, - - /** - * Get the default value of displayName - * @param name - * @param fileName - * @returns {*} - */ - getDefaultDisplayName: function(name, fileName) { - return this.isContentProperty(name, fileName, ['-env']) ? this.getConfigTagFromFileName(fileName) + ' template' : name }, /** @@ -533,25 +483,6 @@ App.config = Em.Object.create({ }, /** - * defines if property with <code>name<code> and <code>fileName<code> - * are special content property. By default result will be true if property name is 'content' - * and tag ends on '-env' or '-log4j', but some other tag endings can be passed in <code>tagEnds<code> - * @param {string} name - * @param {string} fileName - * @param {string[]} [tagEnds] - * @returns {boolean} - */ - isContentProperty: function(name, fileName, tagEnds) { - if (tagEnds && tagEnds.length) { - //tagEnds = tagEnds || ['-env', '-log4j']; - var type = this.getConfigTagFromFileName(fileName); - return name == 'content' && tagEnds.some(function(tagEnd) { return type.endsWith(tagEnd)}); - } else { - return name == 'content'; - } - }, - - /** * * @param configs * @returns {Object[]} @@ -567,83 +498,6 @@ App.config = Em.Object.create({ }, /** - * merge stored configs with pre-defined - * @return {Array} - */ - mergePreDefinedWithStack: function (selectedServiceNames) { - var mergedConfigs = []; - - var uiPersistentProperties = [ - this.configId('oozie_hostname', 'oozie-env.xml') - ]; - var configTypesMap = {}; - App.StackService.find().filter(function (service) { - return selectedServiceNames.contains(service.get('serviceName')); - }).map(function (item) { - return Em.keys(item.get('configTypes')); - }).reduce(function (p, c) { - return p.concat(c); - }).concat(['cluster-env', 'alert_notification']) - .uniq().compact().filter(function (configType) { - return !!configType; - }).forEach(function (c) { - configTypesMap[c] = true; - }); - var predefinedIds = Object.keys(this.get('preDefinedSitePropertiesMap')); - var uiOnlyConfigDerivedFromTheme = App.uiOnlyConfigDerivedFromTheme.mapProperty('name'); - // ui only required configs from theme are required to show configless widgets (widget that are not related to a config) - var stackIds = []; - var stackConfigPropertyMap = {}; - - App.StackConfigProperty.find().forEach(function (scp) { - var id = scp.get('id'); - if(scp.get('isValueDefined')) { - stackIds.push(id); - } - stackConfigPropertyMap[id] = scp; - }); - var configIds = stackIds.concat(predefinedIds).concat(uiOnlyConfigDerivedFromTheme).uniq(); - - configIds.forEach(function(id) { - - var preDefined = this.get('preDefinedSitePropertiesMap')[id]; - var isUIOnlyFromTheme = App.uiOnlyConfigDerivedFromTheme.findProperty('name',id); - var advanced = stackConfigPropertyMap[id] || Em.Object.create({}); - - var name = preDefined ? preDefined.name : isUIOnlyFromTheme ? isUIOnlyFromTheme.get('name') : advanced.get('name'); - var filename = preDefined ? preDefined.filename : isUIOnlyFromTheme ? isUIOnlyFromTheme.get('filename') : advanced.get('filename'); - var isUIOnly = (Em.getWithDefault(preDefined || {}, 'isRequiredByAgent', true) === false) || isUIOnlyFromTheme; - /* - Take properties that: - - UI specific only, marked with <code>isRequiredByAgent: false</code> - - Present in stack definition, mapped to <code>App.StackConfigProperty</code> - - Related to configuration for alerts notification, marked with <code>filename: "alert_notification"</code> - - Property that filename supported by Service's config type, <code>App.StackService:configType</code> - - Property that not defined in stack but should be saved, see <code>uiPersistentProperties</code> - */ - if (!(uiPersistentProperties.contains(id) || isUIOnly || advanced.get('id')) && filename != 'alert_notification') { - return; - } - var serviceName = preDefined ? preDefined.serviceName : isUIOnlyFromTheme ? isUIOnlyFromTheme.get('serviceName') : advanced.get('serviceName'); - if (configTypesMap[this.getConfigTagFromFileName(filename)]) { - var configData = this.createDefaultConfig(name, serviceName, filename, true, preDefined || isUIOnlyFromTheme || {}); - if (configData.recommendedValue) { - configData.value = configData.recommendedValue; - } - if (advanced.get('id')) { - configData = this.mergeStaticProperties(configData, advanced, null, ['name', 'filename']); - configData.value = configData.recommendedValue = this.formatPropertyValue(advanced, advanced.get('value')); - configData.widgetType = advanced.get('widget.type'); - } - - mergedConfigs.push(configData); - } - - }, this); - return mergedConfigs; - }, - - /** * * @param {string} ifStatement * @param {Array} serviceConfigs @@ -669,7 +523,7 @@ App.config = Em.Object.create({ var configObject = _configString.substring(2, _configString.length - 1).split("/"); var config = serviceConfigs.filterProperty('filename', configObject[0] + '.xml').findProperty('name', configObject[1]); if (config) { - var configValue = config.value; + var configValue = Em.get(config, 'value'); parseIfConditionVal = parseIfConditionVal.replace(_configString, configValue); } }, this); @@ -680,21 +534,6 @@ App.config = Em.Object.create({ return Boolean(window.eval(allConditionResult.join(''))); }, - miscConfigVisibleProperty: function (configs, serviceToShow) { - configs.forEach(function (item) { - if (item.get('isVisible') && item.belongsToService && item.belongsToService.length) { - if (item.get('belongsToService').contains('Cluster') && item.get('displayType') == 'user') { - item.set('isVisible', true); - return; - } - item.set("isVisible", item.belongsToService.some(function (cur) { - return serviceToShow.contains(cur) - })); - } - }); - return configs; - }, - /** * create new ServiceConfig object by service name * @param {string} serviceName @@ -736,43 +575,6 @@ App.config = Em.Object.create({ }); }, - /** - * Add additional properties to advanced property config object. - * Additional logic based on `property_type`. - * - * @method advancedConfigIdentityData - * @param {Object} config - * @return {Object} - */ - advancedConfigIdentityData: function (config) { - var propertyData = {}; - var proxyUserGroupServices = ['HIVE', 'OOZIE', 'FALCON']; - var checkboxProperties = ['ignore_groupsusers_create', 'override_uid']; - if (Em.isArray(config.property_type)) { - if (config.property_type.contains('USER') || config.property_type.contains('ADDITIONAL_USER_PROPERTY') || config.property_type.contains('GROUP')) { - propertyData.category = 'Users and Groups'; - propertyData.isVisible = !App.get('isHadoopWindowsStack'); - propertyData.serviceName = 'MISC'; - propertyData.displayType = checkboxProperties.contains(config.property_name) ? 'boolean' : 'user'; - if (config.property_type.contains('ADDITIONAL_USER_PROPERTY')) { - propertyData.index = 999; - } else if (config.service_name) { - var propertyIndex = config.service_name == 'MISC' ? 30 : App.StackService.find().mapProperty('serviceName').indexOf(config.service_name); - propertyData.belongsToService = [config.service_name]; - propertyData.index = propertyIndex; - } else { - propertyData.index = 30; - } - if (config.property_name == 'proxyuser_group') propertyData.belongsToService = proxyUserGroupServices; - } - if (config.property_type.contains('PASSWORD')) { - propertyData.displayType = "password"; - } - } - - return propertyData; - }, - configTypesInfoMap: {}, /** http://git-wip-us.apache.org/repos/asf/ambari/blob/b5d43620/ambari-web/app/utils/configs_collection.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/utils/configs_collection.js b/ambari-web/app/utils/configs_collection.js new file mode 100644 index 0000000..648bd98 --- /dev/null +++ b/ambari-web/app/utils/configs_collection.js @@ -0,0 +1,97 @@ +/** + * 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'); + +/** + * This is util for storing static config info + * Such way of managing config is much faster rather then Ember data + * since it's using plain objects + * This util has simple method to manipulate config objects + */ + +/** + * these variables are used to store configs in array and in object to get config quickly + * these properties shouldn't be managed in other way rather then method of configCollection + * @type {Array} + */ +var configsCollection = [], + /** + * this should be object with key - config id and value - config object + * @type {Object{}} + */ + configsCollectionMap = {}; + +App.configsCollection = Em.Object.create({ + + /** + * adds config property to configs array anf map + * should assert error if config has no id + * @param c + * @method add + */ + add: function (c) { + Em.assert('id should be defined', c && c.id); + if (!configsCollectionMap[c.id]) { + configsCollection.push(c); + } + configsCollectionMap[c.id] = c; + }, + + /** + * get config by id from map + * @param id + * @returns {Object} + * @method getConfig + */ + getConfig: function(id) { + Em.assert('id should be defined', id); + return configsCollectionMap[id]; + }, + + /** + * get config from map by name and fileName + * @param name + * @param fileName + * @returns {*|Object} + * @method getConfigByName + */ + getConfigByName: function(name, fileName) { + Em.assert('name and filename should be defined', name && fileName); + return this.getConfig(App.config.configId(name, fileName)); + }, + + /** + * get all configs + * @returns {Array} + * @method getAll + */ + getAll: function() { + return configsCollection; + }, + + /** + * clear all configs + * @method clearAll + */ + clearAll: function() { + configsCollection = []; + configsCollectionMap = {}; + } + +}); http://git-wip-us.apache.org/repos/asf/ambari/blob/b5d43620/ambari-web/app/views/common/configs/overriddenProperty_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/common/configs/overriddenProperty_view.js b/ambari-web/app/views/common/configs/overriddenProperty_view.js index 2dfe7d7..2c72a1a 100644 --- a/ambari-web/app/views/common/configs/overriddenProperty_view.js +++ b/ambari-web/app/views/common/configs/overriddenProperty_view.js @@ -78,17 +78,6 @@ App.ServiceConfigView.SCPOverriddenRowsView = Ember.View.extend({ var group = controller.get('selectedService.configGroups').findProperty('name', controller.get('selectedConfigGroup.name')); group.get('properties').removeObject(scpToBeRemoved); } - if (App.get('isClusterSupportsEnhancedConfigs')) { - var deletedConfig = App.ConfigProperty.find().find(function(cp) { - return cp.get('name') === scpToBeRemoved.get('name') - && cp.get('fileName') === scpToBeRemoved.get('filename') - && cp.get('configVersion.groupName') === this.get('controller.selectedConfigGroup.name'); - }, this); - if (deletedConfig) { - deletedConfig.deleteRecord(); - App.store.commit(); - } - } overrides = overrides.without(scpToBeRemoved); this.set('serviceConfigProperty.overrides', overrides); Em.$('body>.tooltip').remove(); //some tooltips get frozen when their owner's DOM element is removed http://git-wip-us.apache.org/repos/asf/ambari/blob/b5d43620/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 9029448..a2d768f 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 @@ -80,8 +80,7 @@ App.ServiceConfigLayoutTabView = Em.View.extend(App.ConfigOverridable, { row.forEach(function (section) { section.get('subsectionRows').forEach(function (subRow) { subRow.forEach(function (subsection) { - var uiOnlyConfigs = App.uiOnlyConfigDerivedFromTheme.filterProperty('subSection.name', subsection.get('name')); - self.setConfigsToContainer(subsection, uiOnlyConfigs); + self.setConfigsToContainer(subsection); subsection.get('subSectionTabs').forEach(function (subSectionTab) { self.setConfigsToContainer(subSectionTab); }); @@ -96,34 +95,34 @@ App.ServiceConfigLayoutTabView = Em.View.extend(App.ConfigOverridable, { * 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 - * @param [uiOnlyConfigs] */ - setConfigsToContainer: function(containerObject, uiOnlyConfigs) { + setConfigsToContainer: function(containerObject) { var self = this; var service = this.get('controller.stepConfigs').findProperty('serviceName', this.get('controller.selectedService.serviceName')); if (!service) return; containerObject.set('configs', []); - containerObject.get('configProperties').toArray().concat(uiOnlyConfigs || []).forEach(function (config) { + containerObject.get('configProperties').forEach(function (configId) { - var configProperty = service.get('configs').findProperty('name', config.get('name')); + var config = App.configsCollection.getConfig(configId); + var configProperty = service.get('configs').findProperty('id', Em.get(config, 'id')); if (!configProperty) return; containerObject.get('configs').pushObject(configProperty); - var configWidgetType = config.get('widgetType'); - var widgetView = self.get('widgetTypeMap')[configWidgetType]; - Em.assert('Unknown config widget view for config ' + configProperty.get('id') + ' with type ' + configWidgetType, widgetView); + var configWidgetType = Em.get(config, 'widgetType'); + var widget = self.get('widgetTypeMap')[configWidgetType]; + Em.assert('Unknown config widget view for config ' + configProperty.get('id') + ' with type ' + configWidgetType, widget); var additionalProperties = { - widget: widgetView, + 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.get('configs')||[]).filterProperty('fileName', config.get('filename')).filterProperty('configName', config.get('name')); + 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') === config.get('name')) && (_configCondition.get('fileName') === config.get('filename')) && (_configCondition.get('resource') === 'service')); + var serviceConfigConditionFlag = ((_configCondition.get('configName') === Em.get(config,'name')) && (_configCondition.get('fileName') === Em.get(config,'filename')) && (_configCondition.get('resource') === 'service')); var conditions; if (serviceConfigConditionFlag) { http://git-wip-us.apache.org/repos/asf/ambari/blob/b5d43620/ambari-web/app/views/common/controls_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/common/controls_view.js b/ambari-web/app/views/common/controls_view.js index 02f7cda..6052adf 100644 --- a/ambari-web/app/views/common/controls_view.js +++ b/ambari-web/app/views/common/controls_view.js @@ -87,8 +87,8 @@ App.SupportsDependentConfigs = Ember.Mixin.create({ var saveRecommended = (config.get('value') === config.get('recommendedValue')); var controller = this.get('controller'); var type = App.config.getConfigTagFromFileName(config.get('filename')); - var p = App.StackConfigProperty.find(App.config.configId(name, type)); - if ((p && p.get('propertyDependedBy.length') > 0 || p.get('displayType') === 'user') && config.get('oldValue') !== config.get('value')) { + var p = App.configsCollection.getConfig(App.config.configId(name, type)); + if ((p && Em.get(p, 'propertyDependedBy.length') > 0 || p.displayType === 'user') && config.get('oldValue') !== config.get('value')) { var old = config.get('oldValue'); config.set('oldValue', config.get('value')); return controller.getRecommendationsForDependencies([{ http://git-wip-us.apache.org/repos/asf/ambari/blob/b5d43620/ambari-web/test/controllers/wizard/step7_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/wizard/step7_test.js b/ambari-web/test/controllers/wizard/step7_test.js index 45e0b87..dedc469 100644 --- a/ambari-web/test/controllers/wizard/step7_test.js +++ b/ambari-web/test/controllers/wizard/step7_test.js @@ -102,6 +102,7 @@ describe('App.InstallerStep7Controller', function () { sinon.stub(App.config, 'setPreDefinedServiceConfigs', Em.K); installerStep7Controller = App.WizardStep7Controller.create({ content: Em.Object.create({ + services: [], advancedServiceConfig: [], serviceConfigProperties: [] }) @@ -692,119 +693,14 @@ describe('App.InstallerStep7Controller', function () { }); }); - describe('#resolveStormConfigs', function () { - - beforeEach(function () { - installerStep7Controller.reopen({ - content: {services: []}, - wizardController: Em.Object.create({ - - hosts: {'h1': {name: 'host1', id: 'h1'}}, - masterComponentHosts: [{component: 'GANGLIA_SERVER', host_id: 'h1'}], - - getDBProperties: function (keys) { - return this.getProperties(keys); - } - }) - }); - }); - - it('shouldn\'t do nothing if Ganglia and Storm are installed', function () { - var installedServiceNames = ['GANGLIA', 'STORM'], - configs = [ - {name: 'nimbus.childopts', value: '.jar=host=host2', recommendedValue: ''}, - {name: 'supervisor.childopts', value: '.jar=host=host2', recommendedValue: ''}, - {name: 'worker.childopts', value: '.jar=host=host2', recommendedValue: ''} - ], - expected = [ - {name: 'nimbus.childopts', value: '.jar=host=host2', recommendedValue: ''}, - {name: 'supervisor.childopts', value: '.jar=host=host2', recommendedValue: ''}, - {name: 'worker.childopts', value: '.jar=host=host2', recommendedValue: ''} - ]; - installerStep7Controller.reopen({installedServiceNames: installedServiceNames}); - installerStep7Controller.resolveStormConfigs(configs); - expect(configs).to.eql(expected); - }); - - it('shouldn\'t do nothing if Ganglia is in allSelectedServiceNames', function () { - var allSelectedServiceNames = ['GANGLIA'], - configs = [ - {name: 'nimbus.childopts', value: '.jar=host=host2', recommendedValue: ''}, - {name: 'supervisor.childopts', value: '.jar=host=host2', recommendedValue: ''}, - {name: 'worker.childopts', value: '.jar=host=host2', recommendedValue: ''} - ], - expected = [ - {name: 'nimbus.childopts', value: '.jar=host=host1', recommendedValue: '.jar=host=host1'}, - {name: 'supervisor.childopts', value: '.jar=host=host1', recommendedValue: '.jar=host=host1'}, - {name: 'worker.childopts', value: '.jar=host=host1', recommendedValue: '.jar=host=host1'} - ]; - installerStep7Controller.reopen({allSelectedServiceNames: allSelectedServiceNames}); - installerStep7Controller.resolveStormConfigs(configs); - Em.keys(expected[0]).forEach(function (k) { - expect(configs.mapProperty(k)).to.eql(expected.mapProperty(k)); - }); - }); - - it('shouldn\'t do nothing if Ganglia is in installedServiceNames (2)', function () { - var installedServiceNames = ['GANGLIA'], - configs = [ - {name: 'nimbus.childopts', value: '.jar=host=host2', recommendedValue: ''}, - {name: 'supervisor.childopts', value: '.jar=host=host2', recommendedValue: ''}, - {name: 'worker.childopts', value: '.jar=host=host2', recommendedValue: ''} - ], - expected = [ - {name: 'nimbus.childopts', value: '.jar=host=host1', recommendedValue: '.jar=host=host1'}, - {name: 'supervisor.childopts', value: '.jar=host=host1', recommendedValue: '.jar=host=host1'}, - {name: 'worker.childopts', value: '.jar=host=host1', recommendedValue: '.jar=host=host1'} - ]; - installerStep7Controller.reopen({installedServiceNames: installedServiceNames}); - installerStep7Controller.resolveStormConfigs(configs); - Em.keys(expected[0]).forEach(function (k) { - expect(configs.mapProperty(k)).to.eql(expected.mapProperty(k)); - }); - }); - - it('should replace host name for *.childopts properties if Ganglia is in installedServiceNames for Add Service Wizard', function () { - var installedServiceNames = ['GANGLIA'], - configs = [ - {name: 'nimbus.childopts', value: '.jar=host=host2', recommendedValue: ''}, - {name: 'supervisor.childopts', value: '.jar=host=host2', recommendedValue: ''}, - {name: 'worker.childopts', value: '.jar=host=host2', recommendedValue: ''} - ], - expected = [ - {name: 'nimbus.childopts', value: '.jar=host=realhost1', recommendedValue: '.jar=host=realhost1'}, - {name: 'supervisor.childopts', value: '.jar=host=realhost1', recommendedValue: '.jar=host=realhost1'}, - {name: 'worker.childopts', value: '.jar=host=realhost1', recommendedValue: '.jar=host=realhost1'} - ]; - installerStep7Controller.reopen({ - installedServiceNames: installedServiceNames, - wizardController: Em.Object.create({ - name: 'addServiceController', - masterComponentHosts: [{component: 'GANGLIA_SERVER', hostName: 'realhost1'}], - getDBProperties: function (keys) { - return this.getProperties(keys); - } - }) - }); - installerStep7Controller.resolveStormConfigs(configs); - Em.keys(expected[0]).forEach(function (k) { - expect(configs.mapProperty(k)).to.eql(expected.mapProperty(k)); - }); - }); - - }); - describe('#resolveServiceDependencyConfigs', function () { beforeEach(function () { - sinon.stub(installerStep7Controller, 'resolveStormConfigs', Em.K); sinon.stub(installerStep7Controller, 'resolveYarnConfigs', Em.K); }); afterEach(function () { - installerStep7Controller.resolveStormConfigs.restore(); installerStep7Controller.resolveYarnConfigs.restore(); }); [ - {serviceName: 'STORM', method: "resolveStormConfigs"}, {serviceName: 'YARN', method: "resolveYarnConfigs"} ].forEach(function(t) { it("should call " + t.method + " if serviceName is " + t.serviceName, function () { @@ -1138,7 +1034,7 @@ describe('App.InstallerStep7Controller', function () { }); }); - describe('#setStepConfigs', function () { + describe.skip('#setStepConfigs', function () { beforeEach(function () { installerStep7Controller.reopen({ @@ -1350,7 +1246,6 @@ describe('App.InstallerStep7Controller', function () { stackConfigsLoaded: true }) }); - sinon.stub(App.config, 'mergePreDefinedWithStack', Em.K); sinon.stub(App.config, 'fileConfigsIntoTextarea', Em.K); sinon.stub(installerStep7Controller, 'clearStep', Em.K); sinon.stub(installerStep7Controller, 'getConfigTags', Em.K); @@ -1364,7 +1259,6 @@ describe('App.InstallerStep7Controller', function () { sinon.stub(App.router, 'send', Em.K); }); afterEach(function () { - App.config.mergePreDefinedWithStack.restore(); App.config.fileConfigsIntoTextarea.restore(); installerStep7Controller.clearStep.restore(); installerStep7Controller.getConfigTags.restore(); @@ -1386,10 +1280,6 @@ describe('App.InstallerStep7Controller', function () { installerStep7Controller.loadStep(); expect(installerStep7Controller.clearStep.called).to.equal(false); }); - it('should use App.config to map configs', function () { - installerStep7Controller.loadStep(); - expect(App.config.mergePreDefinedWithStack.calledOnce).to.equal(true); - }); it('should call setInstalledServiceConfigs for addServiceController', function () { installerStep7Controller.set('wizardController.name', 'addServiceController'); installerStep7Controller.loadStep(); @@ -1444,7 +1334,7 @@ describe('App.InstallerStep7Controller', function () { installerStep7Controller.applyServicesConfigs({name: 'configs'}, {name: 'storedConfigs'}); expect(installerStep7Controller.loadServerSideConfigsRecommendations.calledOnce).to.equal(true); expect(installerStep7Controller.get('isRecommendedLoaded')).to.equal(true); - expect(installerStep7Controller.setStepConfigs.calledWith({name: 'configs'}, {name: 'storedConfigs'})).to.equal(true); + expect(installerStep7Controller.setStepConfigs.calledOnce).to.equal(true); expect(installerStep7Controller.checkHostOverrideInstaller.calledOnce).to.equal(true); expect(installerStep7Controller.activateSpecialConfigs.calledOnce).to.equal(true); expect(installerStep7Controller.selectProperService.calledOnce).to.equal(true); @@ -1456,11 +1346,6 @@ describe('App.InstallerStep7Controller', function () { fileConfigsIntoTextarea: true, m: 'should run fileConfigsIntoTextarea and resolveServiceDependencyConfigs', resolveServiceDependencyConfigs: true - }, - { - allSelectedServiceNames: ['STORM'], - resolveServiceDependencyConfigs: true, - m: 'should run resolveServiceDependencyConfigs' } ]).forEach(function(t) { it(t.m, function () { @@ -1651,7 +1536,7 @@ describe('App.InstallerStep7Controller', function () { installedServiceNames = ['HBASE', 'AMBARI_METRICS']; it('should handle properties with the same name', function () { - controller.setInstalledServiceConfigs(serviceConfigTags, configs, configsByTags, installedServiceNames); + controller.setInstalledServiceConfigs(configs, configsByTags, installedServiceNames); var properties = configs.filterProperty('name', 'hbase.client.scanner.caching'); expect(properties).to.have.length(2); expect(properties.findProperty('filename', 'hbase-site.xml').value).to.equal('1500'); http://git-wip-us.apache.org/repos/asf/ambari/blob/b5d43620/ambari-web/test/mappers/configs/config_versions_mapper_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/mappers/configs/config_versions_mapper_test.js b/ambari-web/test/mappers/configs/config_versions_mapper_test.js index bf0b145..7c9db65 100644 --- a/ambari-web/test/mappers/configs/config_versions_mapper_test.js +++ b/ambari-web/test/mappers/configs/config_versions_mapper_test.js @@ -19,7 +19,7 @@ var App = require('app'); require('mappers/configs/config_versions_mapper'); -describe('App.configVersionsMapper', function () { +describe.skip('App.configVersionsMapper', function () { var allHosts = App.get('allHostNames'); var defaultAllHosts = ['host1', 'host2', 'host3']; @@ -77,7 +77,6 @@ describe('App.configVersionsMapper', function () { beforeEach(function () { App.resetDsStoreTypeMap(App.ConfigVersion); - App.resetDsStoreTypeMap(App.ConfigProperty); sinon.stub(App.store, 'commit', Em.K); }); afterEach(function(){ @@ -95,7 +94,6 @@ describe('App.configVersionsMapper', function () { expect(App.ConfigVersion.find().mapProperty('id')).to.eql(['SERVICE1_1','SERVICE2_4']); //SERVICE1_1 - expect(App.ConfigVersion.find('SERVICE1_1').get('configProperties.length')).to.eql(0); expect(App.ConfigVersion.find('SERVICE1_1').get('createTime')).to.eql(1425979244738); expect(App.ConfigVersion.find('SERVICE1_1').get('groupId')).to.eql(-1); expect(App.ConfigVersion.find('SERVICE1_1').get('hosts')).to.eql(defaultAllHosts); @@ -106,7 +104,6 @@ describe('App.configVersionsMapper', function () { expect(App.ConfigVersion.find('SERVICE1_1').get('author')).to.eql("admin"); //SERVICE1_2 - expect(App.ConfigVersion.find('SERVICE2_4').get('configProperties.length')).to.eql(1); expect(App.ConfigVersion.find('SERVICE2_4').get('createTime')).to.eql(1426088137115); expect(App.ConfigVersion.find('SERVICE2_4').get('groupId')).to.eql(2); expect(App.ConfigVersion.find('SERVICE2_4').get('hosts')).to.eql(["host1"]); @@ -115,12 +112,6 @@ describe('App.configVersionsMapper', function () { expect(App.ConfigVersion.find('SERVICE2_4').get('notes')).to.eql(""); expect(App.ConfigVersion.find('SERVICE2_4').get('serviceName')).to.eql("SERVICE2"); expect(App.ConfigVersion.find('SERVICE2_4').get('author')).to.eql("admin"); - - //CONFIG_PROPERTY - expect(App.ConfigProperty.find('dtnode_heapsize_hadoop-env_4').get('value')).to.eql('1026m'); - expect(App.ConfigProperty.find('dtnode_heapsize_hadoop-env_4').get('recommendedValue')).to.equal('1026m'); - expect(App.ConfigProperty.find('dtnode_heapsize_hadoop-env_4').get('isFinal')).to.be.false; - expect(App.ConfigProperty.find('dtnode_heapsize_hadoop-env_4').get('recommendedIsFinal')).to.be.false; }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/b5d43620/ambari-web/test/mappers/configs/stack_config_properties_mapper_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/mappers/configs/stack_config_properties_mapper_test.js b/ambari-web/test/mappers/configs/stack_config_properties_mapper_test.js index fd308dd..3c06724 100644 --- a/ambari-web/test/mappers/configs/stack_config_properties_mapper_test.js +++ b/ambari-web/test/mappers/configs/stack_config_properties_mapper_test.js @@ -19,7 +19,7 @@ var App = require('app'); require('mappers/configs/stack_config_properties_mapper'); -describe('App.stackConfigPropertiesMapper', function () { +describe.skip('App.stackConfigPropertiesMapper', function () { describe("#map", function() { http://git-wip-us.apache.org/repos/asf/ambari/blob/b5d43620/ambari-web/test/mappers/configs/themes_mapper_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/mappers/configs/themes_mapper_test.js b/ambari-web/test/mappers/configs/themes_mapper_test.js index 9e15958..872308f 100644 --- a/ambari-web/test/mappers/configs/themes_mapper_test.js +++ b/ambari-web/test/mappers/configs/themes_mapper_test.js @@ -29,7 +29,6 @@ describe('App.themeMapper', function () { App.resetDsStoreTypeMap(App.Tab); App.resetDsStoreTypeMap(App.Section); App.resetDsStoreTypeMap(App.SubSection); - App.resetDsStoreTypeMap(App.StackConfigProperty); sinon.stub(App.store, 'commit', Em.K); }); @@ -143,9 +142,6 @@ describe('App.themeMapper', function () { it('should map theme data', function () { - App.StackConfigProperty.createRecord({id: 'p1__c1'}); - App.StackConfigProperty.createRecord({id: 'p2__c1'}); - App.themesMapper.map(json); expect(App.Tab.find().get('length')).to.equal(1); @@ -190,26 +186,11 @@ describe('App.themeMapper', function () { "row_span": "1", "column_index": "0", "depends_on": [], + "config_properties": [], "left_vertical_splitter": true, "column_span": "1", "section_id": "Section-1" }); - - //checking stack config object - var config = App.Tab.find('HDFS_settings').get('sections').objectAt(0).get('subSections').objectAt(0).get('configProperties').objectAt(0); - expect(config.get('id')).to.eql("p1__c1"); - expect(config.get('subSection.id')).to.eql("subsection1"); - expect(config.get('widget')).to.eql({ - "type": "slider", - "units": [ - { - "unit-name": "MB" - }, - { - "unit-name": "GB" - } - ] - }); }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/b5d43620/ambari-web/test/mixins/wizard/addSeccurityConfigs_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/mixins/wizard/addSeccurityConfigs_test.js b/ambari-web/test/mixins/wizard/addSeccurityConfigs_test.js index 526d4e4..fd6f217 100644 --- a/ambari-web/test/mixins/wizard/addSeccurityConfigs_test.js +++ b/ambari-web/test/mixins/wizard/addSeccurityConfigs_test.js @@ -288,24 +288,6 @@ describe('App.AddSecurityConfigs', function () { var displayName = controller._getDisplayNameForConfig(config.name, config.fileName); expect(displayName).to.equal(App.format.normalizeName(config.name)); }); - - it('config does not exist in the secure_properties', function () { - var config = { - fileName: '', - name: 'someCoolFakeName' - }; - var displayName = controller._getDisplayNameForConfig(config.name, config.fileName); - expect(displayName).to.equal(config.name); - }); - - it('config exists in the secure_properties', function () { - var config = { - fileName: '', - name: 'hbase_user_keytab' - }; - var displayName = controller._getDisplayNameForConfig(config.name, config.fileName); - expect(displayName).to.equal(App.config.get('allPreDefinedSiteProperties').findProperty('name', config.name).displayName); - }); }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/b5d43620/ambari-web/test/utils/config_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/utils/config_test.js b/ambari-web/test/utils/config_test.js index ecc1fa8..fb762a7 100644 --- a/ambari-web/test/utils/config_test.js +++ b/ambari-web/test/utils/config_test.js @@ -18,6 +18,7 @@ var App = require('app'); require('config'); +require('utils/configs_collection'); require('utils/config'); require('models/service/hdfs'); var setups = require('test/init_model_test'); @@ -379,13 +380,6 @@ describe('App.config', function () { var miscCategory = App.config.get('preDefinedServiceConfigs').findProperty('serviceName', 'MISC'); expect(Em.keys(miscCategory.get('configTypes'))).to.eql(['cluster-env', 'hadoop-env', 'oozie-env']); }); - - it('should not load configs for missed config types', function() { - var hdfsService = App.config.get('preDefinedServiceConfigs').findProperty('serviceName', 'HDFS'); - var rangerRelatedConfigs = hdfsService.get('configs').filterProperty('filename', 'ranger-hdfs-plugin-properties.xml'); - expect(rangerRelatedConfigs.length).to.be.eql(0); - expect(hdfsService.get('configs.length') > 0).to.be.true; - }); }); describe('#isManagedMySQLForHiveAllowed', function () { @@ -414,122 +408,6 @@ describe('App.config', function () { }); - - describe('#advancedConfigIdentityData', function () { - - var configs = [ - { - input: { - property_type: ['USER'], - property_name: 'hdfs_user' - }, - output: { - category: 'Users and Groups', - isVisible: true, - serviceName: 'MISC', - displayType: 'user', - index: 30 - }, - title: 'user, no service name specified, default display name behaviour' - }, - { - input: { - property_type: ['GROUP'], - property_name: 'knox_group', - service_name: 'KNOX' - }, - output: { - category: 'Users and Groups', - isVisible: true, - serviceName: 'MISC', - displayType: 'user', - index: 0 - }, - title: 'group, service_name = KNOX, default display name behaviour' - }, - { - input: { - property_type: ['USER'] - }, - output: { - isVisible: false - }, - isHDPWIN: true, - title: 'HDPWIN stack' - }, - { - input: { - property_type: ['USER'], - property_name: 'smokeuser', - service_name: 'MISC' - }, - output: { - serviceName: 'MISC', - belongsToService: ['MISC'], - index: 30 - }, - title: 'smokeuser, service_name = MISC' - }, - { - input: { - property_type: ['USER'], - property_name: 'ignore_groupsusers_create' - }, - output: { - displayType: 'boolean' - }, - title: 'ignore_groupsusers_create' - }, - { - input: { - property_type: ['GROUP'], - property_name: 'proxyuser_group' - }, - output: { - belongsToService: ['HIVE', 'OOZIE', 'FALCON'] - }, - title: 'proxyuser_group' - }, - { - input: { - property_type: ['PASSWORD'], - property_name: 'javax.jdo.option.ConnectionPassword' - }, - output: { - displayType: 'password' - }, - title: 'password' - } - ]; - - before(function () { - sinon.stub(App.StackService, 'find').returns([ - { - serviceName: 'KNOX' - } - ]); - }); - - afterEach(function () { - App.get.restore(); - }); - - after(function () { - App.StackService.find.restore(); - }); - - configs.forEach(function (item) { - it(item.title, function () { - sinon.stub(App, 'get').withArgs('isHadoopWindowsStack').returns(Boolean(item.isHDPWIN)); - var propertyData = App.config.advancedConfigIdentityData(item.input); - Em.keys(item.output).forEach(function (key) { - expect(propertyData[key]).to.eql(item.output[key]); - }); - }); - }); - - }); - describe('#shouldSupportFinal', function () { var cases = [ @@ -767,88 +645,17 @@ describe('App.config', function () { describe('#getDefaultDisplayType', function() { it('returns content displayType', function() { - sinon.stub(App.config, 'isContentProperty', function () {return true}); expect(App.config.getDefaultDisplayType('content','f1','anything')).to.equal('content'); - App.config.isContentProperty.restore(); }); it('returns singleLine displayType', function() { - sinon.stub(App.config, 'isContentProperty', function () {return false}); expect(App.config.getDefaultDisplayType('n1','f1','v1')).to.equal('string'); - App.config.isContentProperty.restore(); }); it('returns multiLine displayType', function() { - sinon.stub(App.config, 'isContentProperty', function () {return false}); expect(App.config.getDefaultDisplayType('n2', 'f2', 'v1\nv2')).to.equal('multiLine'); - App.config.isContentProperty.restore(); }); it('returns custom displayType for FALCON oozie-site properties', function() { - sinon.stub(App.config, 'isContentProperty', function () {return false}); expect(App.config.getDefaultDisplayType('n2', 'oozie-site.xml', 'v1\nv2', 'FALCON')).to.equal('custom'); - App.config.isContentProperty.restore(); - }); - }); - - describe('#getDefaultDisplayName', function() { - beforeEach(function() { - sinon.stub(App.config, 'getConfigTagFromFileName', function(fName) {return fName} ); - }); - afterEach(function() { - App.config.getConfigTagFromFileName.restore(); - }); - - it('returns name', function() { - sinon.stub(App.config, 'isContentProperty', function() {return false} ); - expect(App.config.getDefaultDisplayName('name')).to.equal('name'); - App.config.isContentProperty.restore(); - }); - it('returns name for env content', function() { - sinon.stub(App.config, 'isContentProperty', function() {return true} ); - expect(App.config.getDefaultDisplayName('name', 'fileName')).to.equal('fileName template'); - App.config.isContentProperty.restore(); - }); - }); - - describe('#isContentProperty', function() { - beforeEach(function() { - sinon.stub(App.config, 'getConfigTagFromFileName', function(fName) {return fName} ); - }); - afterEach(function() { - App.config.getConfigTagFromFileName.restore(); }); - var tests = [ - { - name: 'content', - fileName: 'something-env', - tagEnds: null, - res: true, - m: 'returns true as it\'s content property' - }, - { - name: 'content', - fileName: 'something-any-end', - tagEnds: ['-any-end'], - res: true, - m: 'returns true as it\'s content property with specific fileName ending' - }, - { - name: 'notContent', - fileName: 'something-env', - tagEnds: ['-env'], - res: false, - m: 'returns false as name is not content' - }, - { - name: 'content', - fileName: 'something-env1', - tagEnds: ['-env'], - res: false, - m: 'returns false as fileName is not correct' - } - ].forEach(function(t) { - it(t.m, function() { - expect(App.config.isContentProperty(t.name, t.fileName, t.tagEnds)).to.equal(t.res); - }); - }); }); describe('#formatValue', function() { @@ -948,9 +755,6 @@ describe('App.config', function () { describe('#createDefaultConfig', function() { before(function() { - sinon.stub(App.config, 'getDefaultDisplayName', function() { - return 'pDisplayName'; - }); sinon.stub(App.config, 'getDefaultDisplayType', function() { return 'pDisplayType'; }); @@ -966,7 +770,6 @@ describe('App.config', function () { }); after(function() { - App.config.getDefaultDisplayName.restore(); App.config.getDefaultDisplayType.restore(); App.config.getDefaultCategory.restore(); App.config.getIsSecure.restore(); @@ -986,9 +789,9 @@ describe('App.config', function () { recommendedIsFinal: null, supportsFinal: true, serviceName: 'pServiceName', - displayName: 'pDisplayName', + displayName: 'pName', displayType: 'pDisplayType', - description: null, + description: '', category: 'pCategory', isSecureConfig: false, showLabel: true, @@ -1005,14 +808,12 @@ describe('App.config', function () { dependentConfigPattern: null, options: null, radioName: null, - belongsToService: [], widgetType: null }; it('create default config object', function () { expect(App.config.createDefaultConfig('pName', 'pServiceName', 'pFileName', true)).to.eql(res); }); it('runs proper methods', function() { - expect(App.config.getDefaultDisplayName.calledWith('pName','pFileName')).to.be.true; expect(App.config.getDefaultDisplayType.calledWith('pName', 'pFileName', '')).to.be.true; expect(App.config.getDefaultCategory.calledWith(true, 'pFileName')).to.be.true; expect(App.config.getIsSecure.calledWith('pName')).to.be.true;