initial import for Open Source 🎉
This commit is contained in:
parent
1898c361f3
commit
9c0dd3b722
2048 changed files with 218743 additions and 0 deletions
69
static/js/directives/ui/triggered-build-description.js
Normal file
69
static/js/directives/ui/triggered-build-description.js
Normal file
|
@ -0,0 +1,69 @@
|
|||
/**
|
||||
* 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) {
|
||||
$scope.TriggerService = TriggerService;
|
||||
$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();
|
||||
};
|
||||
|
||||
$scope.$watch('build', function(build) {
|
||||
if (!build) { return; }
|
||||
|
||||
var triggerMetadata = build.trigger_metadata || {};
|
||||
if (triggerMetadata.commit_info) {
|
||||
$scope.infoDisplay = 'fullcommit';
|
||||
return;
|
||||
}
|
||||
|
||||
if (!build.trigger) {
|
||||
$scope.infoDisplay = build.manual_user ? 'manual+user' : 'manual';
|
||||
return;
|
||||
}
|
||||
|
||||
if (build.trigger.build_source && TriggerService.getCommitSHA(triggerMetadata)) {
|
||||
$scope.infoDisplay = 'commitsha';
|
||||
return;
|
||||
}
|
||||
|
||||
$scope.infoDisplay = 'source';
|
||||
});
|
||||
}
|
||||
};
|
||||
return directiveDefinitionObject;
|
||||
});
|
Reference in a new issue