46 lines
1.3 KiB
JavaScript
46 lines
1.3 KiB
JavaScript
/**
|
|
* 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.$watch('build', function(build) {
|
|
if (!build) { return; }
|
|
|
|
var triggerMetadata = build.trigger_metadata || {};
|
|
|
|
if (!build.trigger && !build.manual_user) {
|
|
$scope.infoDisplay = 'manual';
|
|
return;
|
|
}
|
|
|
|
if (!build.trigger && build.manual_user) {
|
|
$scope.infoDisplay = 'manual+user';
|
|
return;
|
|
}
|
|
|
|
if (build.trigger && triggerMetadata.commit_info) {
|
|
$scope.infoDisplay = 'fullcommit';
|
|
return;
|
|
}
|
|
|
|
if (build.trigger && build.trigger.build_source && TriggerService.getCommitSHA(triggerMetadata)) {
|
|
$scope.infoDisplay = 'commitsha';
|
|
return;
|
|
}
|
|
|
|
$scope.infoDisplay = 'source';
|
|
});
|
|
}
|
|
};
|
|
return directiveDefinitionObject;
|
|
});
|