You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by on...@apache.org on 2015/05/28 15:15:56 UTC
ambari git commit: AMBARI-11482. Configs: compare versions not
working (onechiporenko)
Repository: ambari
Updated Branches:
refs/heads/trunk 283ec21ec -> 8775fe29c
AMBARI-11482. Configs: compare versions not working (onechiporenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/8775fe29
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/8775fe29
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/8775fe29
Branch: refs/heads/trunk
Commit: 8775fe29cd931e588df009a3ff25e77fc9aed40a
Parents: 283ec21
Author: Oleg Nechiporenko <on...@apache.org>
Authored: Thu May 28 16:09:06 2015 +0300
Committer: Oleg Nechiporenko <on...@apache.org>
Committed: Thu May 28 16:09:06 2015 +0300
----------------------------------------------------------------------
.../controllers/main/service/info/configs.js | 16 +-
.../views/common/configs/service_config_view.js | 68 +++-
.../configs/service_configs_by_category_view.js | 83 ++---
.../app/views/common/filter_combo_cleanable.js | 7 +-
.../service_config_container_view_test.js | 13 +-
.../common/configs/service_config_view_test.js | 6 +-
.../service_configs_by_category_view_test.js | 347 +++++--------------
ambari-web/test/views/main/menu_test.js | 26 --
8 files changed, 210 insertions(+), 356 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/8775fe29/ambari-web/app/controllers/main/service/info/configs.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/info/configs.js b/ambari-web/app/controllers/main/service/info/configs.js
index 1a5c39d..8e6386d 100644
--- a/ambari-web/app/controllers/main/service/info/configs.js
+++ b/ambari-web/app/controllers/main/service/info/configs.js
@@ -495,8 +495,10 @@ App.MainServiceInfoConfigsController = Em.Controller.extend(App.ServerValidatorM
this.getCompareVersionConfigs(compareServiceVersions).done(function (json) {
self.initCompareConfig(allConfigs, json);
- self.set('compareServiceVersion', null);
- self.set('isCompareMode', true);
+ self.setProperties({
+ compareServiceVersion: null,
+ isCompareMode: true
+ });
dfd.resolve(true);
}).fail(function () {
self.set('compareServiceVersion', null);
@@ -655,9 +657,11 @@ App.MainServiceInfoConfigsController = Em.Controller.extend(App.ServerValidatorM
}
compareObject.serviceVersion = App.ServiceConfigVersion.find(this.get('content.serviceName') + "_" + compareConfig.service_config_version);
compareObject = App.ServiceConfigProperty.create(compareObject);
- compareObject.set('isFinal', compareConfig.isFinal);
- compareObject.set('value', App.config.formatOverrideValue(serviceConfig, compareConfig.value));
- compareObject.set('compareConfigs', null);
+ compareObject.setProperties({
+ isFinal: compareConfig.isFinal,
+ value: App.config.formatOverrideValue(serviceConfig, compareConfig.value),
+ compareConfigs: null
+ });
}
return compareObject;
},
@@ -688,7 +692,7 @@ App.MainServiceInfoConfigsController = Em.Controller.extend(App.ServerValidatorM
},
/**
- * check value and final attribute of original and compare config for differencies
+ * check value and final attribute of original and compare config for differences
* @param originalConfig
* @param compareConfig
* @return {Boolean}
http://git-wip-us.apache.org/repos/asf/ambari/blob/8775fe29/ambari-web/app/views/common/configs/service_config_view.js
----------------------------------------------------------------------
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 a616df7..c9da165 100644
--- a/ambari-web/app/views/common/configs/service_config_view.js
+++ b/ambari-web/app/views/common/configs/service_config_view.js
@@ -19,12 +19,27 @@
var App = require('app');
App.ServiceConfigView = Em.View.extend({
+
templateName: require('templates/common/configs/service_config'),
+
isRestartMessageCollapsed: false,
- filter: '', //from template
- columns: [], //from template
+
+ /**
+ * Bound from parent view in the template
+ * @type {string}
+ */
+ filter: '',
+
+ /**
+ * Bound from parent view in the template
+ * @type {object[]}
+ */
+ columns: [],
+
propertyFilterPopover: [Em.I18n.t('services.service.config.propertyFilterPopover.title'), Em.I18n.t('services.service.config.propertyFilterPopover.content')],
+
canEdit: true, // View is editable or read-only?
+
supportsHostOverrides: function () {
switch (this.get('controller.name')) {
case 'wizardStep7Controller':
@@ -37,6 +52,10 @@ App.ServiceConfigView = Em.View.extend({
}
}.property('controller.name', 'controller.selectedService'),
+ /**
+ * Determines if user is on the service configs page
+ * @type {boolean}
+ */
isOnTheServicePage: function () {
return this.get('controller.name') === 'mainServiceInfoConfigsController';
}.property('controller.name'),
@@ -101,6 +120,7 @@ App.ServiceConfigView = Em.View.extend({
this.$('.service-body').toggle('blind', 200);
this.set('isRestartMessageCollapsed', !this.get('isRestartMessageCollapsed'));
},
+
didInsertElement: function () {
if (this.get('isNotEditable') === true) {
this.set('canEdit', false);
@@ -120,6 +140,7 @@ App.ServiceConfigView = Em.View.extend({
/**
* Check if we should show Custom Property category
+ * @method checkCanEdit
*/
checkCanEdit: function () {
var controller = this.get('controller');
@@ -182,6 +203,9 @@ App.ServiceConfigView = Em.View.extend({
var firstHotHiddenTab = tabs.filterProperty('isHiddenByFilter', false).get('firstObject');
if(firstHotHiddenTab) {
firstHotHiddenTab.set('isActive', true);
+ if (firstHotHiddenTab.get('isAdvanced') && !firstHotHiddenTab.get('isRendered')) {
+ firstHotHiddenTab.set('isRendered', true);
+ }
}
}
},
@@ -227,6 +251,46 @@ App.ServiceConfigView = Em.View.extend({
*/
filterEnhancedConfigs: function () {
var self = this;
+
+ var serviceConfigs = this.get('controller.selectedService.configs').filterProperty('isVisible', true);
+ var filter = (this.get('filter')|| '').toLowerCase();
+ var selectedFilters = (this.get('columns') || []).filterProperty('selected');
+
+ if (selectedFilters.length > 0 || filter.length > 0) {
+ serviceConfigs.forEach(function (config) {
+ var passesFilters = true;
+
+ selectedFilters.forEach(function (filter) {
+ if (config.get(filter.attributeName) !== filter.attributeValue) {
+ passesFilters = false;
+ }
+ });
+
+ if (!passesFilters) {
+ config.set('isHiddenByFilter', true);
+ return false;
+ }
+
+ var searchString = config.get('savedValue') + config.get('description') +
+ config.get('displayName') + config.get('name') + config.get('value') + config.getWithDefault('stackConfigProperty.displayName', '');
+
+ if (config.get('overrides')) {
+ config.get('overrides').forEach(function (overriddenConf) {
+ searchString += overriddenConf.get('value') + overriddenConf.get('group.name');
+ });
+ }
+
+ if (filter != null && typeof searchString === "string") {
+ config.set('isHiddenByFilter', !(searchString.toLowerCase().indexOf(filter) > -1));
+ } else {
+ config.set('isHiddenByFilter', false);
+ }
+ });
+ }
+ else {
+ serviceConfigs.setEach('isHiddenByFilter', false);
+ }
+
Em.run.next(function () {
self.pickActiveTab(self.get('tabs'));
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/8775fe29/ambari-web/app/views/common/configs/service_configs_by_category_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/configs/service_configs_by_category_view.js b/ambari-web/app/views/common/configs/service_configs_by_category_view.js
index f4229ca..1d5e730 100644
--- a/ambari-web/app/views/common/configs/service_configs_by_category_view.js
+++ b/ambari-web/app/views/common/configs/service_configs_by_category_view.js
@@ -36,12 +36,22 @@ App.ServiceConfigsByCategoryView = Em.View.extend(App.UserPref, App.ConfigOverri
service: null,
- canEdit: true, // View is editable or read-only?
+ /**
+ * View is editable or read-only?
+ * @type {boolean}
+ */
+ canEdit: true,
- serviceConfigs: null, // General, Advanced, NameNode, SNameNode, DataNode, etc.
+ /**
+ * All configs for current <code>service</code>
+ * @type {App.ServiceConfigProperty[]}
+ */
+ serviceConfigs: null,
/**
- * @type {Array}
+ * Configs for current category filtered by <code>isVisible</code>
+ * and sorted by <code>displayType</code> and <code>index</code>
+ * @type {App.ServiceConfigProperty[]}
*/
categoryConfigs: function () {
// sort content type configs, sort the rest of configs based on index and then add content array at the end (as intended)
@@ -59,6 +69,7 @@ App.ServiceConfigsByCategoryView = Em.View.extend(App.UserPref, App.ConfigOverri
* is helpful in Oozie/Hive database configuration, where
* MySQL etc. database options don't show up, because
* they were not visible initially.
+ * @type {App.ServiceConfigProperty[]}
*/
categoryConfigsAll: function () {
return this.get('serviceConfigs').filterProperty('category', this.get('category.name'));
@@ -81,17 +92,19 @@ App.ServiceConfigsByCategoryView = Em.View.extend(App.UserPref, App.ConfigOverri
var isCustomPropertiesCategory = this.get('category.customCanAddProperty');
var emptyFiltered = this.get('categoryConfigs').filterProperty('isHiddenByFilter', false).length > 0;
var isWidgetsOnlyCategory = this.get('categoryConfigs.length') == this.get('categoryConfigs').filterProperty('widget').length;
- return isCustomPropertiesCategory && this.get('controller.filter') === '' && !this.get('parentView.columns').someProperty('selected') || (emptyFiltered && !isWidgetsOnlyCategory);
+ return isCustomPropertiesCategory && this.get('controller.filter') === '' && !this.get('parentView.columns').someProperty('selected') ||
+ (emptyFiltered && !isWidgetsOnlyCategory);
}.property('category.customCanAddProperty', 'categoryConfigs.@each.isHiddenByFilter', 'categoryConfigs.@each.widget', 'controller.filter', 'parentView.columns.@each.selected'),
/**
* Re-order the configs to list content displayType properties at last in the category
- * @param categoryConfigs
+ * @param {App.ServiceConfigProperty[]} categoryConfigs
+ * @method orderContentAtLast
*/
orderContentAtLast: function (categoryConfigs) {
var contentProperties = categoryConfigs.filterProperty('displayType', 'content');
if (!contentProperties.length) {
- return categoryConfigs
+ return categoryConfigs;
}
else {
return categoryConfigs.sort(function (a, b) {
@@ -100,12 +113,7 @@ App.ServiceConfigsByCategoryView = Em.View.extend(App.UserPref, App.ConfigOverri
if (aContent && bContent) {
return 0;
}
- else if (aContent) {
- return 1;
- }
- else {
- return -1;
- }
+ return aContent ? 1 : -1;
});
}
},
@@ -220,47 +228,16 @@ App.ServiceConfigsByCategoryView = Em.View.extend(App.UserPref, App.ConfigOverri
/**
* Filtered <code>categoryConfigs</code> array. Used to show filtered result
+ * @method filteredCategoryConfigs
*/
filteredCategoryConfigs: function () {
$('.popover').remove();
var filter = this.get('parentView.filter').toLowerCase();
- var selectedFilters = this.get('parentView.columns').filterProperty('selected');
var filteredResult = this.get('categoryConfigs');
var isInitialRendering = !arguments.length || arguments[1] != 'categoryConfigs';
- if (selectedFilters.length > 0 || filter.length > 0 || this.get('state') === 'inDOM') {
- filteredResult.forEach(function (config) {
- var passesFilters = true;
-
- selectedFilters.forEach(function (filter) {
- if (config.get(filter.attributeName) !== filter.attributeValue) {
- passesFilters = false;
- }
- });
-
- if (!passesFilters) {
- config.set('isHiddenByFilter', true);
- return false;
- }
-
- var searchString = config.get('savedValue') + config.get('description') +
- config.get('displayName') + config.get('name') + config.get('value') + config.getWithDefault('stackConfigProperty.displayName', '');
-
- if (config.get('overrides')) {
- config.get('overrides').forEach(function (overriddenConf) {
- searchString += overriddenConf.get('value') + overriddenConf.get('group.name');
- });
- }
-
- if (filter != null && typeof searchString === "string") {
- config.set('isHiddenByFilter', !(searchString.toLowerCase().indexOf(filter) > -1));
- } else {
- config.set('isHiddenByFilter', false);
- }
- });
- }
- filteredResult = this.sortByIndex(filteredResult);
filteredResult = filteredResult.filterProperty('isHiddenByFilter', false);
+ filteredResult = this.sortByIndex(filteredResult);
if (filter) {
if (filteredResult.length && typeof this.get('category.collapsedByDefault') === 'undefined') {
@@ -268,13 +245,17 @@ App.ServiceConfigsByCategoryView = Em.View.extend(App.UserPref, App.ConfigOverri
this.set('category.collapsedByDefault', this.get('category.isCollapsed'));
}
this.set('category.isCollapsed', !filteredResult.length);
- } else if (typeof this.get('category.collapsedByDefault') !== 'undefined') {
- // If user clear filter -- restore defaults
- this.set('category.isCollapsed', this.get('category.collapsedByDefault'));
- this.set('category.collapsedByDefault', undefined);
- } else if (isInitialRendering && !filteredResult.length) {
- this.set('category.isCollapsed', true);
}
+ else
+ if (typeof this.get('category.collapsedByDefault') !== 'undefined') {
+ // If user clear filter -- restore defaults
+ this.set('category.isCollapsed', this.get('category.collapsedByDefault'));
+ this.set('category.collapsedByDefault', undefined);
+ }
+ else
+ if (isInitialRendering && !filteredResult.length) {
+ this.set('category.isCollapsed', true);
+ }
var categoryBlock = $('.' + this.get('category.name').split(' ').join('.') + '>.accordion-body');
this.get('category.isCollapsed') ? categoryBlock.hide() : categoryBlock.show();
http://git-wip-us.apache.org/repos/asf/ambari/blob/8775fe29/ambari-web/app/views/common/filter_combo_cleanable.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/filter_combo_cleanable.js b/ambari-web/app/views/common/filter_combo_cleanable.js
index ecf744e..6f26ca5 100644
--- a/ambari-web/app/views/common/filter_combo_cleanable.js
+++ b/ambari-web/app/views/common/filter_combo_cleanable.js
@@ -38,9 +38,10 @@ App.FilterComboCleanableView = Ember.View.extend({
this.clearFilter();
},
- placeHolder: function(){
- return this.t('common.combobox.placeholder');
- }.property(),
+ /**
+ * @type {string}
+ */
+ placeHolder: Em.I18n.t('common.combobox.placeholder'),
/**
* Onclick handler for dropdown menu
http://git-wip-us.apache.org/repos/asf/ambari/blob/8775fe29/ambari-web/test/views/common/configs/service_config_container_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/configs/service_config_container_view_test.js b/ambari-web/test/views/common/configs/service_config_container_view_test.js
index 57c7fc2..0cdef1e 100644
--- a/ambari-web/test/views/common/configs/service_config_container_view_test.js
+++ b/ambari-web/test/views/common/configs/service_config_container_view_test.js
@@ -28,7 +28,9 @@ describe('App.ServiceConfigContainerView', function () {
};
beforeEach(function () {
- view = App.ServiceConfigContainerView.create();
+ view = App.ServiceConfigContainerView.create({
+ filter: ''
+ });
});
describe('#pushView', function () {
@@ -44,7 +46,8 @@ describe('App.ServiceConfigContainerView', function () {
it('should add a child view', function () {
view.set('controller', Em.Object.create({
selectedService: {
- configCategories: []
+ configCategories: [],
+ configs: []
}
}));
expect(view.get('childViews')).to.have.length(1);
@@ -54,7 +57,8 @@ describe('App.ServiceConfigContainerView', function () {
view.set('controller', Em.Object.create({
name: 'controller',
selectedService: {
- configCategories: []
+ configCategories: [],
+ configs: []
}
}));
expect(view.get('childViews.firstObject.controller.name')).to.equal('controller');
@@ -63,7 +67,8 @@ describe('App.ServiceConfigContainerView', function () {
it('should add config categories', function () {
view.set('controller', Em.Object.create({
selectedService: {
- configCategories: [Em.Object.create(), Em.Object.create()]
+ configCategories: [Em.Object.create(), Em.Object.create()],
+ configs: []
}
}));
expect(view.get('childViews.firstObject.serviceConfigsByCategoryView.childViews')).to.have.length(2);
http://git-wip-us.apache.org/repos/asf/ambari/blob/8775fe29/ambari-web/test/views/common/configs/service_config_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/configs/service_config_view_test.js b/ambari-web/test/views/common/configs/service_config_view_test.js
index f02b8ff..1f0cd60 100644
--- a/ambari-web/test/views/common/configs/service_config_view_test.js
+++ b/ambari-web/test/views/common/configs/service_config_view_test.js
@@ -46,7 +46,8 @@ describe('App.ServiceConfigView', function () {
App.ServiceConfigCategory.create({ name: 'category1', canAddProperty: false}),
App.ServiceConfigCategory.create({ name: 'category2', siteFileName: 'xml', canAddProperty: true}),
App.ServiceConfigCategory.create({ name: 'category3', siteFileName: 'xml', canAddProperty: false})
- ]
+ ],
+ configs: []
}
},
{
@@ -63,7 +64,8 @@ describe('App.ServiceConfigView', function () {
App.ServiceConfigCategory.create({ name: 'category1', canAddProperty: true}),
App.ServiceConfigCategory.create({ name: 'category2', siteFileName: 'xml', canAddProperty: true}),
App.ServiceConfigCategory.create({ name: 'category3', siteFileName: 'xml', canAddProperty: false})
- ]
+ ],
+ configs: []
}
}
];
http://git-wip-us.apache.org/repos/asf/ambari/blob/8775fe29/ambari-web/test/views/common/configs/service_configs_by_category_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/configs/service_configs_by_category_view_test.js b/ambari-web/test/views/common/configs/service_configs_by_category_view_test.js
index d743179..618ec7b 100644
--- a/ambari-web/test/views/common/configs/service_configs_by_category_view_test.js
+++ b/ambari-web/test/views/common/configs/service_configs_by_category_view_test.js
@@ -102,270 +102,93 @@ describe('App.ServiceConfigsByCategoryView', function () {
})
});
- describe('#filteredCategoryConfigs', function () {
-
- var view,
- cases = [
- {
- filter: '',
- serviceConfigs: [],
- propertyToChange: null,
- isCollapsed: false,
- expectedIsCollapsed: true,
- title: 'no filter, empty category, initial rendering'
- },
- {
- filter: '',
- serviceConfigs: [],
- propertyToChange: 'categoryConfigs',
- isCollapsed: false,
- expectedIsCollapsed: false,
- title: 'no filter, new property added'
- },
- {
- filter: '',
- serviceConfigs: [
- Em.Object.create({
- category: 'c',
- isVisible: true,
- isHiddenByFilter: false
- })
- ],
- propertyToChange: null,
- isCollapsed: false,
- expectedIsCollapsed: false,
- title: 'no filter, initial rendering, not empty category'
- },
- {
- filter: '',
- serviceConfigs: [],
- propertyToChange: null,
- isCollapsed: false,
- collapsedByDefault: true,
- expectedIsCollapsed: true,
- title: 'no filter, restore after filtering'
- },
- {
- filter: 'n',
- serviceConfigs: [
- Em.Object.create({
- name: 'nm',
- category: 'c',
- isVisible: true
- })
- ],
- propertyToChange: null,
- isCollapsed: false,
- expectedIsCollapsed: false,
- title: 'filtering by name, not empty category'
- },
- {
- filter: 'd',
- serviceConfigs: [
- Em.Object.create({
- displayName: 'dn',
- category: 'c',
- isVisible: true
- })
- ],
- propertyToChange: null,
- isCollapsed: false,
- expectedIsCollapsed: false,
- title: 'filtering by display name, not empty category'
- },
- {
- filter: 'd',
- serviceConfigs: [
- Em.Object.create({
- description: 'desc',
- category: 'c',
- isVisible: true
- })
- ],
- propertyToChange: null,
- isCollapsed: false,
- expectedIsCollapsed: false,
- title: 'filtering by description, not empty category'
- },
- {
- filter: 'd',
- serviceConfigs: [
- Em.Object.create({
- savedValue: 'dv',
- category: 'c',
- isVisible: true
- })
- ],
- propertyToChange: null,
- isCollapsed: false,
- expectedIsCollapsed: false,
- title: 'filtering by default value, not empty category'
- },
- {
- filter: 'v',
- serviceConfigs: [
- Em.Object.create({
- value: 'val',
- category: 'c',
- isVisible: true
- })
- ],
- propertyToChange: null,
- isCollapsed: false,
- expectedIsCollapsed: false,
- title: 'filtering by value, not empty category'
- },
- {
- filter: 'v',
- serviceConfigs: [
- Em.Object.create({
- category: 'c',
- isVisible: true,
- overrides: [
- Em.Object.create({
- value: 'val'
- })
- ]
- })
- ],
- propertyToChange: null,
- isCollapsed: false,
- expectedIsCollapsed: false,
- title: 'filtering by overridden property value, not empty category'
- },
- {
- filter: 'n',
- serviceConfigs: [
- Em.Object.create({
- category: 'c',
- isVisible: true,
- overrides: [
- Em.Object.create({
- group: {
- name: 'nm'
- }
- })
- ]
- })
- ],
- propertyToChange: null,
- isCollapsed: false,
- expectedIsCollapsed: false,
- title: 'filtering by overridden property name, not empty category'
- }
- ];
-
- cases.forEach(function (item) {
- it(item.title, function () {
- view = App.ServiceConfigsByCategoryView.create({
- parentView: {
- filter: item.filter,
- columns: []
- },
- category: {
- name: 'c',
- isCollapsed: item.isCollapsed,
- collapsedByDefault: item.collapsedByDefault
- },
- serviceConfigs: item.serviceConfigs
- });
- if (item.propertyToChange) {
- view.propertyDidChange(item.propertyToChange);
- } else {
- view.filteredCategoryConfigs();
- }
- expect(view.get('category.isCollapsed')).to.equal(item.expectedIsCollapsed);
- });
- });
-
- describe('#isShowBlock', function() {
- var tests = [
- {
- categoryConfigs: Em.A([
- { isHiddenByFilter: false }
- ]),
- category: {},
- m: 'no configs with widget, filtered properties are visible. Panel should be shown',
- e: true
- },
- {
- categoryConfigs: Em.A([]),
- category: Em.Object.create({ customCanAddProperty: true}),
- m: 'Category with custom properties. Panel shouldn\'t be shown',
- e: false
- },
- {
- categoryConfigs: Em.A([
- { isHiddenByFilter: false }
- ]),
- category: Em.Object.create({ customCanAddProperty: true}),
- m: 'Category with custom properties. Filtered configs are hidden. Panel should be shown',
- e: true
- },
- {
- categoryConfigs: Em.A([
- { isHiddenByFilter: true }
- ]),
- category: Em.Object.create({ customCanAddProperty: false }),
- m: 'Filtered configs are hidden. Category not for custom properties. Panel should be hidden',
- e: false
- },
- {
- categoryConfigs: Em.A([]),
- category: Em.Object.create({ customCanAddProperty: false }),
- m: 'Category without properties and not for custom configurations. Panel should be hidden',
- e: false
- },
- {
- categoryConfigs: Em.A([
- { widget: {someProp: 'a'}},
- { widget: {someProp: 'b'}}
- ]),
- category: Em.Object.create({ customCanAddProperty: false }),
- m: 'All properties have widgets and category is not custom. Panel should be hidden',
- e: false
- },
- {
- categoryConfigs: Em.A([
- { widget: null },
- { widget: null }
- ]),
- category: Em.Object.create({ customCanAddProperty: false }),
- m: 'All properties have widgets set to `null` and category is not custom. Panel should be hidden',
- e: false
- },
- {
- categoryConfigs: Em.A([
- { widget: {someProp: 'a'} },
- { isHiddenByFilter: true }
- ]),
- category: Em.Object.create({ customCanAddProperty: false }),
- m: 'Category contains mixed properties. Properties are hidden by filter. Panel should be hidden',
- e: false
- },
- {
- categoryConfigs: Em.A([
- { widget: {someProp: 'a'} },
- { isHiddenByFilter: false }
- ]),
- category: Em.Object.create({ customCanAddProperty: false }),
- m: 'Category contains mixed properties. Properties are visible. Panel should be shown',
- e: true
- }
- ];
+ describe('#isShowBlock', function() {
+ var tests = [
+ {
+ categoryConfigs: Em.A([
+ { isHiddenByFilter: false }
+ ]),
+ category: {},
+ m: 'no configs with widget, filtered properties are visible. Panel should be shown',
+ e: true
+ },
+ {
+ categoryConfigs: Em.A([]),
+ category: Em.Object.create({ customCanAddProperty: true}),
+ m: 'Category with custom properties. Panel shouldn\'t be shown',
+ e: false
+ },
+ {
+ categoryConfigs: Em.A([
+ { isHiddenByFilter: false }
+ ]),
+ category: Em.Object.create({ customCanAddProperty: true}),
+ m: 'Category with custom properties. Filtered configs are hidden. Panel should be shown',
+ e: true
+ },
+ {
+ categoryConfigs: Em.A([
+ { isHiddenByFilter: true }
+ ]),
+ category: Em.Object.create({ customCanAddProperty: false }),
+ m: 'Filtered configs are hidden. Category not for custom properties. Panel should be hidden',
+ e: false
+ },
+ {
+ categoryConfigs: Em.A([]),
+ category: Em.Object.create({ customCanAddProperty: false }),
+ m: 'Category without properties and not for custom configurations. Panel should be hidden',
+ e: false
+ },
+ {
+ categoryConfigs: Em.A([
+ { widget: {someProp: 'a'}},
+ { widget: {someProp: 'b'}}
+ ]),
+ category: Em.Object.create({ customCanAddProperty: false }),
+ m: 'All properties have widgets and category is not custom. Panel should be hidden',
+ e: false
+ },
+ {
+ categoryConfigs: Em.A([
+ { widget: null },
+ { widget: null }
+ ]),
+ category: Em.Object.create({ customCanAddProperty: false }),
+ m: 'All properties have widgets set to `null` and category is not custom. Panel should be hidden',
+ e: false
+ },
+ {
+ categoryConfigs: Em.A([
+ { widget: {someProp: 'a'} },
+ { isHiddenByFilter: true }
+ ]),
+ category: Em.Object.create({ customCanAddProperty: false }),
+ m: 'Category contains mixed properties. Properties are hidden by filter. Panel should be hidden',
+ e: false
+ },
+ {
+ categoryConfigs: Em.A([
+ { widget: {someProp: 'a'} },
+ { isHiddenByFilter: false }
+ ]),
+ category: Em.Object.create({ customCanAddProperty: false }),
+ m: 'Category contains mixed properties. Properties are visible. Panel should be shown',
+ e: true
+ }
+ ];
- tests.forEach(function(test) {
- it(test.m, function() {
- var _view = App.ServiceConfigsByCategoryView.create({
- serviceConfigs: Em.A([]),
- category: test.category,
- categoryConfigs: test.categoryConfigs
- });
- sinon.stub(_view, 'filteredCategoryConfigs', Em.K);
- _view.filteredCategoryConfigs.restore();
- expect(_view.get('isShowBlock')).to.be.eql(test.e);
- _view.destroy();
+ tests.forEach(function(test) {
+ it(test.m, function() {
+ var _view = App.ServiceConfigsByCategoryView.create({
+ serviceConfigs: Em.A([]),
+ category: test.category,
+ categoryConfigs: test.categoryConfigs
});
+ sinon.stub(_view, 'filteredCategoryConfigs', Em.K);
+ _view.filteredCategoryConfigs.restore();
+ expect(_view.get('isShowBlock')).to.be.eql(test.e);
+ _view.destroy();
});
});
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/8775fe29/ambari-web/test/views/main/menu_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/menu_test.js b/ambari-web/test/views/main/menu_test.js
index 1332bbe..1d4f9d5 100644
--- a/ambari-web/test/views/main/menu_test.js
+++ b/ambari-web/test/views/main/menu_test.js
@@ -23,32 +23,6 @@ require('views/main/menu');
var mainMenuView = App.MainMenuView.create();
describe('App.MainMenuView', function () {
- describe('#content', function () {
- beforeEach(function () {
- this.mock = sinon.stub(App, 'get');
- sinon.stub(App.router, 'get')
- .withArgs('clusterController.isLoaded').returns(true)
- .withArgs('loggedIn').returns(true);
- });
- afterEach(function () {
- this.mock.restore();
- App.router.get.restore();
- });
-
- it('menu should be populated if cluster installation is completed', function () {
- this.mock.withArgs('router.clusterInstallCompleted').returns(true);
- App.router.notifyPropertyChange('clusterInstallCompleted');
- expect(mainMenuView.get('content').length > 1).to.be.true;
- });
-
- it('menu should not be populated if cluster installation is not completed', function () {
- this.mock.withArgs('router.clusterInstallCompleted').returns(false);
- App.router.notifyPropertyChange('clusterInstallCompleted');
- expect(mainMenuView.get('content').length > 1).to.be.false;
- });
-
- });
-
describe('#itemViewClass', function () {
beforeEach(function () {