Skip to content

Commit

Permalink
feat(core/triggers): More relevant info when selecting execution (#4983)
Browse files Browse the repository at this point in the history
* feat(core/triggers): More relevant info when selecting execution

Add execution build title and scm info if available to the "Start Manual Execution" modal.

* fix tests

* Single quotes

* Move a br tag
  • Loading branch information
jervi authored and anotherchrisberry committed Mar 9, 2018
1 parent 9bc82e6 commit 53395ac
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
Expand Up @@ -6,22 +6,23 @@
</p>
</div>
<div class="col-md-6" ng-if="vm.viewState.loadError">Error loading executions!</div>
<div class="col-md-6" ng-if="!vm.viewState.executionsLoading">
<div class="col-md-7" ng-if="!vm.viewState.executionsLoading">
<div ng-if="!vm.executions.length"><p class="form-control-static">No recent executions found</p></div>
<ui-select class="form-control input-sm"
ng-model="vm.viewState.selectedExecution"
on-select="vm.updateSelectedExecution($item)"
ng-if="vm.executions.length">
<ui-select-match placeholder="Select...">
<span>
{{$select.selected.buildTime | timestamp}}
<execution-build-title execution="$select.selected" default-to-timestamp="true" ></execution-build-title>
<strong>({{$select.selected.status}})</strong>
</span>
</ui-select-match>
<ui-select-choices repeat="execution in vm.executions | anyFieldFilter: {status: $select.search}">
<span>
{{execution.buildTime | timestamp}}
<strong>({{execution.status}})</strong>
<strong><execution-build-title execution="execution" default-to-timestamp="false" ></execution-build-title></strong>
{{execution.buildTime | timestamp}} ({{execution.status}})
<span ng-if="execution.buildInfo.scm"><br />{{execution.buildInfo.scm[0].branch}} ({{execution.buildInfo.scm[0].sha1 | limitTo:6}}): {{execution.buildInfo.scm[0].message | limitTo:30}}<span ng-if="execution.buildInfo.scm[0].message.length > 30"></span></span></span>
</span>
</ui-select-choices>
</ui-select>
Expand Down
Expand Up @@ -20,10 +20,11 @@ module.exports = angular
scope: {}
};
})
.controller('PipelineTriggerOptionsCtrl', function ($scope, executionService) {
.controller('PipelineTriggerOptionsCtrl', function ($scope, executionService, executionsTransformer) {
let executionLoadSuccess = (executions) => {
this.executions = executions;
if (this.executions.length) {
this.executions.forEach(execution => executionsTransformer.addBuildInfo(execution));
// default to what is supplied by the trigger if possible; otherwise, use the latest
let defaultSelection = this.executions.find(e => e.id === this.command.trigger.parentPipelineId) || this.executions[0];
this.viewState.selectedExecution = defaultSelection;
Expand Down
Expand Up @@ -2,7 +2,7 @@

describe('Pipeline Trigger: PipelineTriggerOptionsCtrl', function() {

var $scope, executionService, ctrl, $q, command;
var $scope, executionService, executionsTransformer, ctrl, $q, command;

beforeEach(
window.module(
Expand All @@ -16,9 +16,10 @@ describe('Pipeline Trigger: PipelineTriggerOptionsCtrl', function() {
$qProvider.errorOnUnhandledRejections(false);
}));

beforeEach(window.inject(function($rootScope, _executionService_, $controller, _$q_) {
beforeEach(window.inject(function($rootScope, _executionService_, _executionsTransformer_, $controller, _$q_) {
$scope = $rootScope.$new();
executionService = _executionService_;
executionsTransformer = _executionsTransformer_;
$q = _$q_;

command = {
Expand All @@ -32,6 +33,7 @@ describe('Pipeline Trigger: PipelineTriggerOptionsCtrl', function() {
this.initialize = function() {
ctrl = $controller('PipelineTriggerOptionsCtrl', {
executionService: executionService,
executionsTransformer: executionsTransformer,
$scope: $scope,
}, { command: command });
ctrl.$onInit();
Expand All @@ -41,6 +43,7 @@ describe('Pipeline Trigger: PipelineTriggerOptionsCtrl', function() {
it('loads executions on initialization, setting state flags', function () {
let executions = [];
spyOn(executionService, 'getExecutionsForConfigIds').and.returnValue($q.when(executions));
spyOn(executionsTransformer, 'addBuildInfo');

this.initialize();
expect(ctrl.viewState.executionsLoading).toBe(true);
Expand All @@ -57,6 +60,7 @@ describe('Pipeline Trigger: PipelineTriggerOptionsCtrl', function() {
{ pipelineConfigId: 'b', buildTime: 1, id: 'b-1', application: 'a' },
];
spyOn(executionService, 'getExecutionsForConfigIds').and.returnValue($q.when(executions));
spyOn(executionsTransformer, 'addBuildInfo');

this.initialize();
expect(ctrl.viewState.executionsLoading).toBe(true);
Expand All @@ -71,6 +75,7 @@ describe('Pipeline Trigger: PipelineTriggerOptionsCtrl', function() {

it('sets flags when execution load fails', function () {
spyOn(executionService, 'getExecutionsForConfigIds').and.returnValue($q.reject('does not matter'));
spyOn(executionsTransformer, 'addBuildInfo');

this.initialize();
expect(ctrl.viewState.executionsLoading).toBe(true);
Expand Down Expand Up @@ -98,6 +103,7 @@ describe('Pipeline Trigger: PipelineTriggerOptionsCtrl', function() {
}
return $q.when(executions);
});
spyOn(executionsTransformer, "addBuildInfo");

this.initialize();
$scope.$digest();
Expand Down

0 comments on commit 53395ac

Please sign in to comment.