Fix resetting of cluster settings from Dashboard

Updating of cluster settings should support three modes:
* update settings from group 'network' only
* update settings except 'network' group
* update all settings

Closes-Bug: #1587392

Change-Id: I03054107490ff0bece79a1c115179e9e8e8e68ed
This commit is contained in:
Julia Aranovich 2016-05-31 13:11:34 +03:00 committed by Vitaly Kramskikh
parent 3d1391bf80
commit dee4e9c0de
1 changed files with 19 additions and 4 deletions

View File

@ -854,11 +854,22 @@ models.Settings = Backbone.DeepModel
});
return _.intersection(this.groupList, groups);
},
updateAttributes(newSettings, models, updateNetworkSettings = false) {
updateAttributes(newSettings, models, updateNetworkSettings) {
/*
* updateNetworkSettings (boolean):
* if true, update settings from 'network' group only
* if false, do not update settings from 'network' group
* if not specified (default), update all settings
**/
this.validationError = null;
_.each(this.attributes, (section, sectionName) => {
var isNetworkGroup = section.metadata.group === 'network';
if (updateNetworkSettings === isNetworkGroup) {
var shouldSectionBeUpdated = _.isUndefined(updateNetworkSettings) ||
updateNetworkSettings === isNetworkGroup;
if (shouldSectionBeUpdated) {
if (this.isPlugin(section)) {
if (newSettings.get(sectionName)) {
var pathToMetadata = utils.makePath(sectionName, 'metadata');
@ -871,9 +882,13 @@ models.Settings = Backbone.DeepModel
} else {
_.each(section, (setting, settingName) => {
// do not update hidden settings (hack for #1442143)
if (setting.type === 'hidden') return;
var shouldSettingBeUpdated = setting.type !== 'hidden' && (
_.isUndefined(updateNetworkSettings) ||
isNetworkGroup ||
setting.group !== 'network'
);
if (isNetworkGroup || setting.group !== 'network') {
if (shouldSettingBeUpdated) {
var path = utils.makePath(sectionName, settingName);
this.set(path, newSettings.get(path));
}