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
2015-04-29 19:50:13 -04:00

45 lines
No EOL
1.2 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.$watch('build', function(build) {
if (!build) { return; }
var jobConfig = build.job_config || {};
var triggerMetadata = jobConfig.trigger_metadata || {};
if (!build.trigger && !jobConfig.manual_user) {
$scope.infoDisplay = 'manual';
return;
}
if (!build.trigger && jobConfig.manual_user) {
$scope.infoDisplay = 'manual+user';
return;
}
if (triggerMetadata.commit_info) {
$scope.infoDisplay = 'fullcommit';
return;
}
if (triggerMetadata.commit_sha) {
$scope.infoDisplay = 'commitsha';
}
$scope.infoDisplay = 'source';
});
}
};
return directiveDefinitionObject;
});