Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
If a service has a conflicted config value then we don't allow them t…
Browse files Browse the repository at this point in the history
…o commit their queued changes
  • Loading branch information
Jeff Pihach committed Sep 30, 2014
1 parent 478a785 commit f20af7a
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
10 changes: 10 additions & 0 deletions app/templates/deployer-bar-summary.handlebars
@@ -1,6 +1,16 @@

<div class="content">
<h2 class="title">Confirm your changes</h2>
{{#if conflictedServiceCount}}
<div class="unplaced-panel">
<p>You have {{conflictedServiceCount}} {{pluralize 'service' conflictedServiceCount}} with conflicted configurations. Click the links below to visit the services inspectors to resolve these conflicts to continue.</p>
<ul>
{{#each conflictedServices}}
<a href="" class="resolve-conflict" service="{{id}}">{{id}}</a>
{{/each}}
</ul>
</div>
{{/if}}
{{#if unplacedCount}}
<div class="unplaced-panel">
<p>You have {{unplacedCount}} unplaced {{pluralize 'unit' unplacedCount}}, do you want to:</p>
Expand Down
46 changes: 45 additions & 1 deletion app/widgets/deployer-bar.js
Expand Up @@ -93,6 +93,9 @@ YUI.add('deployer-bar', function(Y) {
'.view-machines': {
click: '_viewMachines'
},
'.resolve-conflict': {
click: '_showInspectorConfig'
},
'.commit-onboarding .close': {
click: '_hideCommitOnboarding'
}
Expand Down Expand Up @@ -148,6 +151,9 @@ YUI.add('deployer-bar', function(Y) {
*/
deploy: function(evt) {
evt.halt();
if (evt.currentTarget.hasClass('disabled')) {
return;
}
var container = this.get('container'),
ecs = this.get('ecs'),
autodeploy = container.one('input[value="autodeploy"]');
Expand Down Expand Up @@ -286,6 +292,21 @@ YUI.add('deployer-bar', function(Y) {
return !db.services.getById(unit.service).get('subordinate');
}).length;

var conflictedServices = [];
db.services.each(function(service) {
if (service.get('_conflictedFields').length > 0) {
conflictedServices.push(service.getAttrs());
}
});
// We do not allow people to commit their config changes if there are
// conflicted config values.
var confirmButton = container.one('.confirm-button');
if (conflictedServices.length > 0) {
confirmButton.addClass('disabled');
} else {
confirmButton.removeClass('disabled');
}

if (container && container.get('parentNode')) {
container.one('.panel.summary section').setHTML(this.summaryTemplate({
changeCount: this._getChangeCount(ecs),
Expand All @@ -301,7 +322,9 @@ YUI.add('deployer-bar', function(Y) {
destroyedMachines: changes.destroyMachines,
configsChanged: changes.setConfigs,
majorChange: this._hasMajorChanges(changes),
unplacedCount: unplacedCount
unplacedCount: unplacedCount,
conflictedServiceCount: conflictedServices.length,
conflictedServices: conflictedServices
}));
}
container.addClass('summary-open');
Expand Down Expand Up @@ -441,6 +464,7 @@ YUI.add('deployer-bar', function(Y) {
Toggle the status of the deploy button.
@method _toggleDeployButtonStatus
@param {Boolean} enabled Whether the commit button should be active.
*/
_toggleDeployButtonStatus: function(enabled) {
if (enabled) {
Expand Down Expand Up @@ -862,6 +886,26 @@ YUI.add('deployer-bar', function(Y) {
});
},

/**
Closes the summary and opens the inspector that the user clicked on to
resolve config conflicts.
@method _showInspectorconfig
@param {Object} e The click event facade.
*/
_showInspectorConfig: function(e) {
e.halt();
this.hideSummary(e);
this.fire('changeState', {
sectionA: {
component: 'inspector',
metadata: {
id: e.currentTarget.getAttribute('service')
}
}
});
},

/**
Optionally show the onboarding message for the commit button.
Expand Down

0 comments on commit f20af7a

Please sign in to comment.