2015-02-26 22:45:28 +00:00
|
|
|
/**
|
|
|
|
* An element which displays information about a build that was triggered from an outside source.
|
|
|
|
*/
|
|
|
|
angular.module('quay').directive('triggeredBuildDescription', function () {
|
|
|
|
var directiveDefinitionObject = {
|
|
|
|
priority: 0,
|
|
|
|
templateUrl: '/static/directives/triggered-build-description.html',
|
|
|
|
replace: false,
|
|
|
|
transclude: false,
|
|
|
|
restrict: 'C',
|
|
|
|
scope: {
|
|
|
|
'build': '=build'
|
|
|
|
},
|
|
|
|
controller: function($scope, $element, KeyService, TriggerService) {
|
2015-04-30 19:33:19 +00:00
|
|
|
$scope.TriggerService = TriggerService;
|
2015-06-26 20:09:35 +00:00
|
|
|
$scope.showLongDescription = false;
|
|
|
|
|
|
|
|
$scope.toggleLongDescription = function() {
|
|
|
|
$scope.showLongDescription = !$scope.showLongDescription;
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.hasLongDescription = function(message) {
|
|
|
|
if (!message) { return ''; }
|
|
|
|
return message.length >= 80 || message.split('\n').length > 1;
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.getMessageSummary = function(message) {
|
|
|
|
if (!message) { return ''; }
|
|
|
|
var lines = message.split('\n');
|
|
|
|
return lines[0].substring(0, 79).trim();
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.getMessageLongDescription = function(message) {
|
|
|
|
if (!message) { return ''; }
|
|
|
|
var lines = message.split('\n');
|
|
|
|
if (lines[0].length >= 80) {
|
|
|
|
lines[0] = lines[0].substring(80);
|
|
|
|
} else {
|
|
|
|
lines.splice(0, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
return lines.join('\n').trim();
|
|
|
|
};
|
|
|
|
|
2015-04-29 23:50:13 +00:00
|
|
|
$scope.$watch('build', function(build) {
|
|
|
|
if (!build) { return; }
|
|
|
|
|
2015-04-30 19:33:19 +00:00
|
|
|
var triggerMetadata = build.trigger_metadata || {};
|
2018-05-14 19:30:52 +00:00
|
|
|
if (triggerMetadata.commit_info) {
|
|
|
|
$scope.infoDisplay = 'fullcommit';
|
2015-04-29 23:50:13 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-05-14 19:30:52 +00:00
|
|
|
if (!build.trigger) {
|
|
|
|
$scope.infoDisplay = build.manual_user ? 'manual+user' : 'manual';
|
2015-04-29 23:50:13 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-05-14 19:30:52 +00:00
|
|
|
if (build.trigger.build_source && TriggerService.getCommitSHA(triggerMetadata)) {
|
2015-04-29 23:50:13 +00:00
|
|
|
$scope.infoDisplay = 'commitsha';
|
2015-04-30 19:33:19 +00:00
|
|
|
return;
|
2015-04-29 23:50:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$scope.infoDisplay = 'source';
|
|
|
|
});
|
2015-02-26 22:45:28 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
return directiveDefinitionObject;
|
2015-06-02 19:32:28 +00:00
|
|
|
});
|