This repository has been archived on 2020-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
quay/static/js/directives/ui/triggered-build-description.js

47 lines
1.3 KiB
JavaScript
Raw Normal View History

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;
$scope.$watch('build', function(build) {
if (!build) { return; }
2015-04-30 19:33:19 +00:00
var triggerMetadata = build.trigger_metadata || {};
2015-04-30 19:33:19 +00:00
if (!build.trigger && !build.manual_user) {
$scope.infoDisplay = 'manual';
return;
}
2015-04-30 19:33:19 +00:00
if (!build.trigger && build.manual_user) {
$scope.infoDisplay = 'manual+user';
return;
}
2015-04-30 19:33:19 +00:00
if (build.trigger && triggerMetadata.commit_info) {
$scope.infoDisplay = 'fullcommit';
return;
}
if (build.trigger && build.trigger.build_source && TriggerService.getCommitSHA(triggerMetadata)) {
$scope.infoDisplay = 'commitsha';
2015-04-30 19:33:19 +00:00
return;
}
$scope.infoDisplay = 'source';
});
2015-02-26 22:45:28 +00:00
}
};
return directiveDefinitionObject;
});