Fix calculation of role dependency for environment settings

User should be able to turn off a setting if there are no deployed
or ready for deployment nodes in environment with a role,
which depends on this setting.

Closes-Bug: #1581506

Change-Id: I732c6b64a7cd90b73162789231255c29006bb21f
This commit is contained in:
Julia Aranovich 2016-05-13 16:19:30 +03:00
parent 7ba0011d81
commit f7aedfc054
3 changed files with 16 additions and 11 deletions

View File

@ -391,6 +391,13 @@ models.Cluster = BaseModel.extend({
},
hasChanges({configModels}) {
return this.get('nodes').hasChanges() || this.isConfigurationChanged({configModels});
},
getAllocatedRoles() {
return _.chain(this.get('nodes').filter({pending_deletion: false}))
.map((node) => node.get('roles').concat(node.get('pending_roles')))
.flatten()
.uniq()
.value();
}
});

View File

@ -1780,8 +1780,8 @@ var NetworkSettings = React.createClass({
render() {
var {cluster, locked} = this.props;
var settings = cluster.get('settings');
var allocatedRoles = _.uniq(_.flatten(_.union(cluster.get('nodes').pluck('roles'),
cluster.get('nodes').pluck('pending_roles'))));
var allocatedRoles = cluster.getAllocatedRoles();
return (
<div className='forms-box network'>
{

View File

@ -215,15 +215,13 @@ var SettingsTab = React.createClass({
return this.state.actionInProgress || !this.props.cluster.isAvailableForSettingsChanges();
},
render() {
var cluster = this.props.cluster;
var {cluster, activeSettingsSectionName, setActiveSettingsGroupName} = this.props;
var settings = cluster.get('settings');
var settingsGroupList = this.constructor.getSubtabs({cluster});
var locked = this.isLocked();
var hasChanges = this.hasChanges();
var allocatedRoles = _.uniq(_.flatten(_.union(
cluster.get('nodes').pluck('roles'),
cluster.get('nodes').pluck('pending_roles')
)));
var allocatedRoles = cluster.getAllocatedRoles();
var classes = {
row: true,
'changes-locked': locked
@ -293,12 +291,12 @@ var SettingsTab = React.createClass({
settingsGroupList={settingsGroupList}
groupedSettings={groupedSettings}
configModels={this.state.configModels}
setActiveSettingsGroupName={this.props.setActiveSettingsGroupName}
activeSettingsSectionName={this.props.activeSettingsSectionName}
setActiveSettingsGroupName={setActiveSettingsGroupName}
activeSettingsSectionName={activeSettingsSectionName}
checkRestrictions={this.checkRestrictions}
/>
{_.map(groupedSettings, (selectedGroup, groupName) => {
if (groupName !== this.props.activeSettingsSectionName) return null;
if (groupName !== activeSettingsSectionName) return null;
var sortedSections = _.sortBy(
_.keys(selectedGroup), (name) => settings.get(name + '.metadata.weight')
@ -316,7 +314,7 @@ var SettingsTab = React.createClass({
return <SettingSection
{... _.pick(this.state, 'initialAttributes', 'settingsForChecks', 'configModels')}
key={sectionName}
cluster={this.props.cluster}
cluster={cluster}
sectionName={sectionName}
settingsToDisplay={settingsToDisplay}
onChange={_.partial(this.onChange, sectionName)}