Skip to content

Commit 0b5cb64

Browse files
(core) allow pipelines to be disabled (spinnaker#2573)
1 parent e2e01ea commit 0b5cb64

12 files changed

+152
-9
lines changed

app/scripts/modules/core/delivery/executionGroup/executionGroup.directive.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88
analytics-label="{{vm.group.heading}}"
99
ng-click="vm.toggle()"
1010
ng-if="vm.group.heading">
11-
<div class="col-md-12 execution-group-heading" ng-class="vm.viewState.isRetired ? 'inactive' : 'active'">
11+
<div class="col-md-12 execution-group-heading" ng-class="vm.viewState.isRetired || vm.pipelineConfig.disabled ? 'inactive' : 'active'">
1212
<div class="row">
1313
<div class="col-md-5 col-sm-5">
1414
<h4 class="execution-group-title">
1515
<span class="glyphicon"
1616
ng-class="{'glyphicon-chevron-right': !vm.viewState.open, 'glyphicon-chevron-down': vm.viewState.open}">
1717
</span>
1818
<span class="execution-group-title">
19-
{{ vm.group.heading }}
19+
{{ vm.group.heading }} <span ng-if="vm.pipelineConfig.disabled">(disabled)</span>
2020
<span ng-if="vm.group.runningExecutions.length" class="badge">
2121
{{vm.group.runningExecutions.length}}
2222
</span>
@@ -39,7 +39,7 @@ <h4>
3939
Configure
4040
</a>
4141
</h4>
42-
<h4 ng-if="vm.viewState.canTriggerPipelineManually">
42+
<h4 ng-if="vm.viewState.canTriggerPipelineManually" is-visible="!vm.pipelineConfig.disabled">
4343
<a href
4444
class="btn btn-xs btn-link link-inverse"
4545
analytics-on="click"

app/scripts/modules/core/delivery/manualExecution/manualPipelineExecution.controller.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ module.exports = angular.module('spinnaker.core.delivery.manualPipelineExecution
178178
}
179179

180180
if (!pipeline) {
181-
this.pipelineOptions = application.pipelineConfigs.data;
181+
this.pipelineOptions = application.pipelineConfigs.data.filter(c => !c.disabled);
182182
}
183183

184184
});

app/scripts/modules/core/delivery/manualExecution/manualPipelineExecution.controller.spec.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,17 @@ describe('Controller: ManualPipelineExecution', function () {
2828

2929
describe('Initialization', function () {
3030
describe('No pipeline provided', function () {
31-
it('sets pipeline options on controller from application', function () {
31+
it('sets pipeline options on controller from application, skipping disabled', function () {
3232
let application = {
3333
pipelineConfigs: { data: [
3434
{ id: 'a' },
35-
{ id: 'b' }
35+
{ id: 'b' },
36+
{ id: 'c', disabled: true }
3637
]}
3738
};
3839
this.initializeController(application);
3940

40-
expect(this.ctrl.pipelineOptions).toBe(application.pipelineConfigs.data);
41+
expect(this.ctrl.pipelineOptions).toEqual([ {id: 'a'}, {id: 'b'} ]);
4142
});
4243
});
4344

app/scripts/modules/core/pipeline/config/actions/actions.module.js

+2
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,6 @@ module.exports = angular.module('spinnaker.core.pipeline.config.actions', [
77
require('./json/editPipelineJson.module.js'),
88
require('./rename/rename.module.js'),
99
require('./history/showHistory.controller'),
10+
require('./enable/enable.module'),
11+
require('./disable/disable.module'),
1012
]);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
'use strict';
2+
3+
let angular = require('angular');
4+
5+
module.exports = angular.module('spinnaker.core.pipeline.config.actions.disable', [
6+
require('../../services/services.module.js'),
7+
])
8+
.controller('DisablePipelineModalCtrl', function($uibModalInstance, pipelineConfigService, pipeline) {
9+
10+
this.viewState = {};
11+
12+
this.pipelineName = pipeline.name;
13+
14+
this.cancel = $uibModalInstance.dismiss;
15+
16+
this.disablePipeline = () => {
17+
pipeline.disabled = true;
18+
return pipelineConfigService.savePipeline(pipeline).then(
19+
() => $uibModalInstance.close(),
20+
(response) => {
21+
this.viewState.saveError = true;
22+
this.viewState.errorMessage = response.message || 'No message provided';
23+
}
24+
);
25+
};
26+
27+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<div modal-page>
2+
<modal-close></modal-close>
3+
<div class="modal-header">
4+
<h3>Really Disable Pipeline?</h3>
5+
</div>
6+
<div class="modal-body">
7+
<div class="alert alert-danger" ng-if="ctrl.viewState.saveError">
8+
<p>Could not disable pipeline.</p>
9+
<p><b>Reason: </b>{{ctrl.viewState.errorMessage}}</p>
10+
<p><a href ng-click="ctrl.viewState.saveError = false">[dismiss]</a></p>
11+
</div>
12+
<form role="form" name="form" class="form-horizontal">
13+
<div class="form-group">
14+
<div class="col-md-12">
15+
<p>Are you sure you want to disable {{ctrl.pipelineName}}?</p>
16+
<p>This will prevent any triggers from firing, and will also prevent users from running the pipeline manually.</p>
17+
</div>
18+
</div>
19+
</form>
20+
</div>
21+
<div class="modal-footer">
22+
<button class="btn btn-default" ng-click="ctrl.cancel()">Cancel</button>
23+
<button class="btn btn-primary"
24+
ng-click="ctrl.disablePipeline()">
25+
Disable pipeline
26+
</button>
27+
</div>
28+
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
'use strict';
2+
3+
let angular = require('angular');
4+
5+
module.exports = angular.module('spinnaker.core.pipeline.config.actions.enable', [
6+
require('../../services/services.module.js'),
7+
])
8+
.controller('EnablePipelineModalCtrl', function($uibModalInstance, pipelineConfigService, pipeline) {
9+
10+
this.viewState = {};
11+
12+
this.pipelineName = pipeline.name;
13+
14+
this.cancel = $uibModalInstance.dismiss;
15+
16+
this.enablePipeline = () => {
17+
pipeline.disabled = false;
18+
return pipelineConfigService.savePipeline(pipeline).then(
19+
() => $uibModalInstance.close(),
20+
(response) => {
21+
this.viewState.saveError = true;
22+
this.viewState.errorMessage = response.message || 'No message provided';
23+
}
24+
);
25+
};
26+
27+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<div modal-page>
2+
<modal-close></modal-close>
3+
<div class="modal-header">
4+
<h3>Really Enable Pipeline?</h3>
5+
</div>
6+
<div class="modal-body">
7+
<div class="alert alert-danger" ng-if="ctrl.viewState.saveError">
8+
<p>Could not enable pipeline.</p>
9+
<p><b>Reason: </b>{{ctrl.viewState.errorMessage}}</p>
10+
<p><a href ng-click="ctrl.viewState.saveError = false">[dismiss]</a></p>
11+
</div>
12+
<form role="form" name="form" class="form-horizontal">
13+
<div class="form-group">
14+
<div class="col-md-12">
15+
<p>Are you sure you want to enable {{ctrl.pipelineName}}?</p>
16+
</div>
17+
</div>
18+
</form>
19+
</div>
20+
<div class="modal-footer">
21+
<button class="btn btn-default" ng-click="ctrl.cancel()">Cancel</button>
22+
<button class="btn btn-primary"
23+
ng-click="ctrl.enablePipeline()">
24+
Enable pipeline
25+
</button>
26+
</div>
27+
</div>

app/scripts/modules/core/pipeline/config/actions/pipelineConfigActions.html

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
<ul class="dropdown-menu" uib-dropdown-menu role="menu">
66
<li><a href ng-click="pipelineConfigurerCtrl.renamePipeline()">Rename</a></li>
77
<li><a href ng-click="pipelineConfigurerCtrl.deletePipeline()">Delete</a></li>
8+
<li ng-if="pipeline.disabled"><a href ng-click="pipelineConfigurerCtrl.enablePipeline()">Enable</a></li>
9+
<li ng-if="!pipeline.disabled"><a href ng-click="pipelineConfigurerCtrl.disablePipeline()">Disable</a></li>
810
<li><a href ng-click="pipelineConfigurerCtrl.editPipelineJson()">Edit as JSON</a></li>
911
<li ng-if="viewState.hasHistory"><a href ng-click="pipelineConfigurerCtrl.showHistory()">Show Revision History</a></li>
1012
<li ng-if="!viewState.hasHistory"><a class="disabled">No version history found</a></li>

app/scripts/modules/core/pipeline/config/createNew.html

+4-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@
1616
analytics-on="click"
1717
analytics-category="Pipelines"
1818
analytics-event="Configure pipeline (via top level)"
19-
ui-sref="^.pipelineConfig({pipelineId: pipeline.id})">{{pipeline.name}}</a></li>
19+
ui-sref="^.pipelineConfig({pipelineId: pipeline.id})">
20+
{{pipeline.name}} <span ng-if="pipeline.disabled">(disabled)</span>
21+
</a>
22+
</li>
2023
<li class="dropdown-header" style="margin-top:0" ng-if="application.strategyConfigs.data.length">DEPLOYMENT STRATEGIES</li>
2124
<li ng-repeat="pipeline in application.strategyConfigs.data">
2225
<a href

app/scripts/modules/core/pipeline/config/pipelineConfigurer.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ <h3>
77
<a href class="nav-popover"
88
ng-click="navMenuState.showMenu = !navMenuState.showMenu"
99
ng-blur="pipelineConfigurerCtrl.hideNavigationMenu()">
10-
{{pipeline.name}}
10+
{{pipeline.name}} <span ng-if="pipeline.disabled">(disabled)</span>
1111
</a>
1212
<pipeline-config-errors pipeline="pipeline"></pipeline-config-errors>
1313
</h3>

app/scripts/modules/core/pipeline/config/pipelineConfigurer.js

+26
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ module.exports = angular.module('spinnaker.core.pipeline.config.pipelineConfigur
2121

2222
this.actionsTemplateUrl = overrideRegistry.getTemplate('pipelineConfigActions', require('./actions/pipelineConfigActions.html'));
2323

24+
let original = _.cloneDeep($scope.pipeline);
25+
2426
pipelineConfigService.getHistory($scope.pipeline.id, 2).then(history => {
2527
if (history && history.length > 1) {
2628
$scope.viewState.hasHistory = true;
@@ -144,6 +146,30 @@ module.exports = angular.module('spinnaker.core.pipeline.config.pipelineConfigur
144146
});
145147
};
146148

149+
this.enablePipeline = () => {
150+
$uibModal.open({
151+
templateUrl: require('./actions/enable/enablePipelineModal.html'),
152+
controller: 'EnablePipelineModalCtrl as ctrl',
153+
resolve: {
154+
pipeline: () => original
155+
}
156+
}).result.then(disableToggled);
157+
};
158+
159+
this.disablePipeline = () => {
160+
$uibModal.open({
161+
templateUrl: require('./actions/disable/disablePipelineModal.html'),
162+
controller: 'DisablePipelineModalCtrl as ctrl',
163+
resolve: {
164+
pipeline: () => original
165+
}
166+
}).result.then(disableToggled);
167+
};
168+
169+
function disableToggled() {
170+
$scope.pipeline.disabled = !$scope.pipeline.disabled;
171+
}
172+
147173
this.showHistory = () => {
148174
$uibModal.open({
149175
templateUrl: require('./actions/history/showHistory.modal.html'),

0 commit comments

Comments
 (0)