UI fixes for all the new trigger stuff

This commit is contained in:
Joseph Schorr 2015-04-30 15:33:19 -04:00
parent de29a441c8
commit b7317f894b
25 changed files with 260 additions and 149 deletions

View file

@ -42,15 +42,14 @@ angular.module('quay').directive('repoPanelBuilds', function () {
var unordered = $scope.allBuilds.map(function(build_info) {
var commit_sha = null;
var job_config = build_info.job_config || {};
if (job_config.trigger_metadata) {
commit_sha = job_config.trigger_metadata.commit_sha;
if (build_info.trigger_metadata) {
commit_sha = build_info.trigger_metadata.commit_sha;
}
return $.extend(build_info, {
'started_datetime': (new Date(build_info.started)).valueOf() * (-1),
'building_tags': job_config.docker_tags || [],
'building_tags': build_info.tags || [],
'commit_sha': commit_sha
});
});

View file

@ -10,6 +10,7 @@ angular.module('quay').directive('anchor', function () {
restrict: 'C',
scope: {
'href': '@href',
'target': '@target',
'isOnlyText': '=isOnlyText'
},
controller: function($scope, $element) {

View file

@ -6,11 +6,12 @@ angular.module('quay').directive('sourceCommitLink', function () {
priority: 0,
templateUrl: '/static/directives/source-commit-link.html',
replace: false,
transclude: false,
transclude: true,
restrict: 'C',
scope: {
'commitSha': '=commitSha',
'urlTemplate': '=urlTemplate'
'urlTemplate': '=urlTemplate',
'showTransclude': '=showTransclude'
},
controller: function($scope, $element) {
$scope.getUrl = function(sha, template) {

View file

@ -16,26 +16,38 @@ angular.module('quay').directive('stepView', function ($compile) {
'stepsCompleted': '&stepsCompleted'
},
controller: function($scope, $element, $rootScope) {
this.currentStepIndex = -1;
this.steps = [];
this.watcher = null;
var currentStepIndex = -1;
var steps = [];
var watcher = null;
this.getCurrentStep = function() {
return this.steps[this.currentStepIndex];
// Members on 'this' are accessed by the individual steps.
this.register = function(scope, element) {
element.hide();
steps.push({
'scope': scope,
'element': element
});
nextStep();
};
this.reset = function() {
this.currentStepIndex = -1;
for (var i = 0; i < this.steps.length; ++i) {
this.steps[i].element.hide();
var getCurrentStep = function() {
return steps[currentStepIndex];
};
var reset = function() {
currentStepIndex = -1;
for (var i = 0; i < steps.length; ++i) {
steps[i].element.hide();
}
$scope.currentStepValid = false;
};
this.next = function() {
if (this.currentStepIndex >= 0) {
var currentStep = this.getCurrentStep();
var next = function() {
if (currentStepIndex >= 0) {
var currentStep = getCurrentStep();
if (!currentStep || !currentStep.scope) { return; }
if (!currentStep.scope.completeCondition) {
@ -44,20 +56,20 @@ angular.module('quay').directive('stepView', function ($compile) {
currentStep.element.hide();
if (this.unwatch) {
this.unwatch();
this.unwatch = null;
if (unwatch) {
unwatch();
unwatch = null;
}
}
this.currentStepIndex++;
currentStepIndex++;
if (this.currentStepIndex < this.steps.length) {
var currentStep = this.getCurrentStep();
if (currentStepIndex < steps.length) {
var currentStep = getCurrentStep();
currentStep.element.show();
currentStep.scope.load()
this.unwatch = currentStep.scope.$watch('completeCondition', function(cc) {
unwatch = currentStep.scope.$watch('completeCondition', function(cc) {
$scope.currentStepValid = !!cc;
});
} else {
@ -65,23 +77,17 @@ angular.module('quay').directive('stepView', function ($compile) {
}
};
this.register = function(scope, element) {
element.hide();
var nextStep = function() {
if (!steps || !steps.length) { return; }
this.steps.push({
'scope': scope,
'element': element
});
if ($scope.nextStepCounter >= 0) {
next();
} else {
reset();
}
};
var that = this;
$scope.$watch('nextStepCounter', function(nsc) {
if (nsc >= 0) {
that.next();
} else {
that.reset();
}
});
$scope.$watch('nextStepCounter', nextStep);
}
};
return directiveDefinitionObject;

View file

@ -12,29 +12,30 @@ angular.module('quay').directive('triggeredBuildDescription', function () {
'build': '=build'
},
controller: function($scope, $element, KeyService, TriggerService) {
$scope.TriggerService = TriggerService;
$scope.$watch('build', function(build) {
if (!build) { return; }
var jobConfig = build.job_config || {};
var triggerMetadata = jobConfig.trigger_metadata || {};
var triggerMetadata = build.trigger_metadata || {};
if (!build.trigger && !jobConfig.manual_user) {
if (!build.trigger && !build.manual_user) {
$scope.infoDisplay = 'manual';
return;
}
if (!build.trigger && jobConfig.manual_user) {
if (!build.trigger && build.manual_user) {
$scope.infoDisplay = 'manual+user';
return;
}
if (triggerMetadata.commit_info) {
if (build.trigger && triggerMetadata.commit_info) {
$scope.infoDisplay = 'fullcommit';
return;
}
if (triggerMetadata.commit_sha) {
if (build.trigger && build.trigger.build_source && triggerMetadata.commit_sha) {
$scope.infoDisplay = 'commitsha';
return;
}
$scope.infoDisplay = 'source';

View file

@ -30,16 +30,14 @@
var determineDockerfilePath = function() {
var dockerfilePath = 'Dockerfile';
if ($scope.repobuild['job_config']) {
var dockerfileFolder = ($scope.repobuild['job_config']['build_subdir'] || '');
if (dockerfileFolder[0] == '/') {
dockerfileFolder = dockerfileFolder.substr(1);
}
if (dockerfileFolder && dockerfileFolder[dockerfileFolder.length - 1] != '/') {
dockerfileFolder += '/';
}
dockerfilePath = dockerfileFolder + 'Dockerfile';
var dockerfileFolder = ($scope.repobuild['subdirectory'] || '');
if (dockerfileFolder[0] == '/') {
dockerfileFolder = dockerfileFolder.substr(1);
}
if (dockerfileFolder && dockerfileFolder[dockerfileFolder.length - 1] != '/') {
dockerfileFolder += '/';
}
dockerfilePath = dockerfileFolder + 'Dockerfile';
return dockerfilePath;
};

View file

@ -70,15 +70,12 @@
$scope.restartBuild = function(build) {
$('#confirmRestartBuildModal').modal('hide');
var subdirectory = '';
if (build['job_config']) {
subdirectory = build['job_config']['build_subdir'] || '';
}
var subdirectory = build['subdirectory'] || '';
var data = {
'file_id': build['resource_key'],
'subdirectory': subdirectory,
'docker_tags': build['job_config']['docker_tags']
'docker_tags': build['tags']
};
if (build['pull_robot']) {

View file

@ -54,6 +54,14 @@ angular.module('quay').factory('TriggerService', ['UtilService', '$sanitize', 'K
'templates': {
'credentials': '/static/directives/trigger/githost/credentials.html',
'trigger-description': '/static/directives/trigger/github/trigger-description.html'
},
'repository_url': function(build) {
return KeyService['githubTriggerEndpoint'] + build.trigger.build_source;
},
'link_templates': {
'commit': '/commit/{sha}',
'branch': '/tree/{branch}',
'tag': '/releases/tag/{tag}',
}
},
@ -85,6 +93,14 @@ angular.module('quay').factory('TriggerService', ['UtilService', '$sanitize', 'K
'templates': {
'credentials': '/static/directives/trigger/githost/credentials.html',
'trigger-description': '/static/directives/trigger/bitbucket/trigger-description.html'
},
'repository_url': function(build) {
return 'https://bitbucket.org/' + build.trigger.build_source;
},
'link_templates': {
'commit': '/commits/{sha}',
'branch': '/branch/{branch}',
'tag': '/commits/tag/{tag}',
}
},
@ -125,6 +141,26 @@ angular.module('quay').factory('TriggerService', ['UtilService', '$sanitize', 'K
});
};
triggerService.getFullLinkTemplate = function(build, templateName) {
var name = build.trigger.service;
var type = triggerTypes[name];
if (!type) {
return null;
}
var repositoryUrl = type.repository_url;
if (!repositoryUrl) {
return null;
}
var linkTemplate = type.link_templates;
if (!linkTemplate || !linkTemplate[templateName]) {
return null;
}
return repositoryUrl(build) + linkTemplate[templateName];
};
triggerService.supportsFullListing = function(name) {
var type = triggerTypes[name];
if (!type) {