Further fixes to make everything work nicely with Github Enterprise

This commit is contained in:
Joseph Schorr 2014-11-26 12:54:02 -05:00
parent b7a489813a
commit 52b7896835
4 changed files with 84 additions and 69 deletions

View file

@ -1,7 +1,10 @@
<span class="trigger-description-element" ng-switch on="trigger.service">
<span ng-switch-when="github">
<i class="fa fa-github fa-lg" style="margin-right: 6px" data-title="GitHub" bs-tooltip="tooltip.title"></i>
Push to GitHub repository <a href="https://github.com/{{ trigger.config.build_source }}" target="_new">{{ trigger.config.build_source }}</a>
Push to GitHub <span ng-if="KeyService.isEnterprise('github-trigger')">Enterprise</span> repository
<a href="{{ KeyService['githubTriggerEndpoint'] }}{{ trigger.config.build_source }}" target="_new">
{{ trigger.config.build_source }}
</a>
<div style="margin-top: 4px; margin-left: 26px; font-size: 12px; color: gray;" ng-if="!short">
<div>
<span class="trigger-description-subtitle">Branches/Tags:</span>

View file

@ -1729,14 +1729,22 @@ quayApp = angular.module('quay', quayDependencies, function($provide, cfpLoading
keyService['githubEndpoint'] = oauth['GITHUB_LOGIN_CONFIG']['GITHUB_ENDPOINT'];
keyService['githubTriggerEndpoint'] = oauth['GITHUB_TRIGGER_CONFIG']['GITHUB_ENDPOINT'];
keyService['githubTriggerAuthorizeUrl'] = oauth['GITHUB_TRIGGER_CONFIG']['AUTHORIZE_ENDPOINT'];
keyService['githubLoginScope'] = 'user:email';
keyService['googleLoginScope'] = 'openid email';
keyService.isEnterprise = function(service) {
var isGithubEnterprise = keyService['githubLoginUrl'].indexOf('https://github.com/') < 0;
return service == 'github' && isGithubEnterprise;
switch (service) {
case 'github':
return keyService['githubLoginUrl'].indexOf('https://github.com/') < 0;
case 'github-trigger':
return keyService['githubTriggerAuthorizeUrl'].indexOf('https://github.com/') < 0;
}
return false;
};
keyService.getExternalLoginUrl = function(service, action) {
@ -4806,7 +4814,9 @@ quayApp.directive('triggerDescription', function () {
'trigger': '=trigger',
'short': '=short'
},
controller: function($scope, $element) {
controller: function($scope, $element, KeyService, TriggerService) {
$scope.KeyService = KeyService;
$scope.TriggerService = TriggerService;
}
};
return directiveDefinitionObject;

View file

@ -59,13 +59,13 @@ function PlansCtrl($scope, $location, UserService, PlanService, $routeParams) {
$scope.signedIn = function() {
$('#signinModal').modal('hide');
PlanService.handleNotedPlan();
PlanService.handleNotedPlan();
};
$scope.buyNow = function(plan) {
PlanService.notePlan(plan);
if ($scope.user && !$scope.user.anonymous) {
PlanService.handleNotedPlan();
PlanService.handleNotedPlan();
} else {
$('#signinModal').modal({});
}
@ -77,7 +77,7 @@ function PlansCtrl($scope, $location, UserService, PlanService, $routeParams) {
if ($scope && $routeParams['trial-plan']) {
$scope.buyNow($routeParams['trial-plan']);
}
}
}, /* include the personal plan */ true);
}
@ -94,7 +94,7 @@ function TutorialCtrl($scope, AngularTour, AngularTourSignals, UserService, Conf
'steps': [
{
'title': 'Welcome to the ' + Config.REGISTRY_TITLE_SHORT + ' tutorial!',
'templateUrl': '/static/tutorial/welcome.html'
'templateUrl': '/static/tutorial/welcome.html'
},
{
'title': 'Sign in to get started',
@ -235,7 +235,7 @@ function RepoListCtrl($scope, $sanitize, Restangular, UserService, ApiService) {
$scope.namespace = null;
$scope.page = 1;
$scope.publicPageCount = null;
// Monitor changes in the user.
UserService.updateUserIn($scope, function() {
loadMyRepos($scope.namespace);
@ -269,7 +269,7 @@ function RepoListCtrl($scope, $sanitize, Restangular, UserService, ApiService) {
}
var options = {'public': false, 'sort': true, 'namespace': namespace};
$scope.user_repositories = ApiService.listReposAsResource().withOptions(options).get(function(resp) {
return resp.repositories;
});
@ -318,7 +318,7 @@ function LandingCtrl($scope, UserService, ApiService, Features, Config) {
if (namespace == $scope.user.username) {
return true;
}
if ($scope.user.organizations) {
for (var i = 0; i < $scope.user.organizations.length; ++i) {
var org = $scope.user.organizations[i];
@ -483,7 +483,7 @@ function RepoCtrl($scope, $sanitize, Restangular, ImageMetadataService, ApiServi
$scope.currentPullCommand = $scope.pullCommands[0];
};
$scope.showNewBuildDialog = function() {
$scope.buildDialogShowCounter++;
};
@ -655,7 +655,7 @@ function RepoCtrl($scope, $sanitize, Restangular, ImageMetadataService, ApiServi
$scope.setImage = function(imageId, opt_updateURL) {
if (!$scope.images) { return; }
var image = null;
for (var i = 0; i < $scope.images.length; ++i) {
var currentImage = $scope.images[i];
@ -691,7 +691,7 @@ function RepoCtrl($scope, $sanitize, Restangular, ImageMetadataService, ApiServi
// We must find a good default.
for (tagName in repo.tags) {
if (!proposedTag || tagName == 'latest') {
proposedTag = repo.tags[tagName];
proposedTag = repo.tags[tagName];
}
}
}
@ -702,7 +702,7 @@ function RepoCtrl($scope, $sanitize, Restangular, ImageMetadataService, ApiServi
if ($scope.tree) {
$scope.tree.setTag(proposedTag.name);
}
}
if (opt_updateURL) {
$location.search('image', null);
@ -871,7 +871,7 @@ function RepoCtrl($scope, $sanitize, Restangular, ImageMetadataService, ApiServi
};
var listImages = function() {
var params = {'repository': namespace + '/' + name};
var params = {'repository': namespace + '/' + name};
$scope.imageHistory = ApiService.listRepositoryImagesAsResource(params).get(function(resp) {
$scope.images = resp.images;
$scope.specificImages = [];
@ -971,7 +971,7 @@ function BuildPackageCtrl($scope, Restangular, ApiService, DataFileService, $rou
return dockerfilePath;
};
var processBuildPack = function(uint8array) {
var processBuildPack = function(uint8array) {
var archiveread = function(files) {
var getpath = function(file) {
return file.path;
@ -1056,7 +1056,7 @@ function BuildPackageCtrl($scope, Restangular, ApiService, DataFileService, $rou
$scope.accessDenied = true;
return;
}
$rootScope.title = 'Repository Build Pack - ' + resp['display_name'];
$scope.repobuild = resp;
$scope.repo = {
@ -1115,7 +1115,7 @@ function RepoBuildCtrl($scope, Restangular, ApiService, $routeParams, $rootScope
$('#confirmRestartBuildModal').modal('hide');
var subdirectory = '';
if (build['job_config']) {
if (build['job_config']) {
subdirectory = build['job_config']['build_subdir'] || '';
}
@ -1159,7 +1159,7 @@ function RepoBuildCtrl($scope, Restangular, ApiService, $routeParams, $rootScope
$scope.processANSI = function(message, container) {
var filter = container.logs._filter = (container.logs._filter || ansi2html.create());
// Note: order is important here.
var setup = filter.getSetupHtml();
var stream = filter.addInputToStream(message);
@ -1194,7 +1194,7 @@ function RepoBuildCtrl($scope, Restangular, ApiService, $routeParams, $rootScope
if ($scope.pollChannel) {
$scope.pollChannel.stop();
}
// Create a new channel for polling the build status and logs.
var conductStatusAndLogRequest = function(callback) {
getBuildStatusAndLogs(build, callback);
@ -1230,7 +1230,7 @@ function RepoBuildCtrl($scope, Restangular, ApiService, $routeParams, $rootScope
return endIndex;
};
var getBuildStatusAndLogs = function(build, callback) {
var getBuildStatusAndLogs = function(build, callback) {
var params = {
'repository': namespace + '/' + name,
'build_uuid': build.id
@ -1258,9 +1258,9 @@ function RepoBuildCtrl($scope, Restangular, ApiService, $routeParams, $rootScope
'start': $scope.logStartIndex
};
ApiService.getRepoBuildLogsAsResource(params, true).withOptions(options).get(function(resp) {
ApiService.getRepoBuildLogsAsResource(params, true).withOptions(options).get(function(resp) {
if (build != $scope.currentBuild) { callback(false); return; }
// Process the logs we've received.
$scope.logStartIndex = processLogs(resp['logs'], resp['start'], resp['total']);
@ -1323,7 +1323,7 @@ function RepoBuildCtrl($scope, Restangular, ApiService, $routeParams, $rootScope
fetchRepository();
}
function RepoAdminCtrl($scope, Restangular, ApiService, KeyService, TriggerService, $routeParams,
function RepoAdminCtrl($scope, Restangular, ApiService, KeyService, TriggerService, $routeParams,
$rootScope, $location, UserService, Config, Features, ExternalNotificationData) {
var namespace = $routeParams.namespace;
@ -1331,11 +1331,12 @@ function RepoAdminCtrl($scope, Restangular, ApiService, KeyService, TriggerServi
$scope.Features = Features;
$scope.TriggerService = TriggerService;
$scope.KeyService = KeyService;
$scope.permissions = {'team': [], 'user': [], 'loading': 2};
$scope.logsShown = 0;
$scope.deleting = false;
$scope.permissionCache = {};
$scope.showTriggerSetupCounter = 0;
@ -1436,7 +1437,7 @@ function RepoAdminCtrl($scope, Restangular, ApiService, KeyService, TriggerServi
var permission = $scope.permissions[kind][entityName];
var currentRole = permission.role;
permission.role = role;
var permissionPut = Restangular.one(getRestUrl('repository', namespace, name, 'permissions', kind, entityName));
permissionPut.customPUT(permission).then(function() {}, function(resp) {
$scope.permissions[kind][entityName] = {'role': currentRole};
@ -1534,7 +1535,7 @@ function RepoAdminCtrl($scope, Restangular, ApiService, KeyService, TriggerServi
$scope.deleting = true;
ApiService.deleteRepository(null, params).then(function() {
$scope.repo = null;
setTimeout(function() {
document.location = '/repository/';
}, 1000);
@ -1545,7 +1546,7 @@ function RepoAdminCtrl($scope, Restangular, ApiService, KeyService, TriggerServi
};
$scope.showNewNotificationCounter = 0;
$scope.showNewNotificationDialog = function() {
$scope.showNewNotificationCounter++;
};
@ -1629,7 +1630,7 @@ function RepoAdminCtrl($scope, Restangular, ApiService, KeyService, TriggerServi
};
$scope.showManualBuildDialog = 0;
$scope.startTrigger = function(trigger, opt_custom) {
var parameters = TriggerService.getRunParameters(trigger.service);
if (parameters.length && !opt_custom) {
@ -1765,7 +1766,7 @@ function UserAdminCtrl($scope, $timeout, $location, ApiService, PlanService, Use
$scope.logsShown = 0;
$scope.invoicesShown = 0;
$scope.loadAuthedApps = function() {
if ($scope.authorizedApps) { return; }
@ -1808,7 +1809,7 @@ function UserAdminCtrl($scope, $timeout, $location, ApiService, PlanService, Use
$scope.orgPlans = plans;
});
}
$scope.convertStep = 1;
};
@ -1883,7 +1884,7 @@ function UserAdminCtrl($scope, $timeout, $location, ApiService, PlanService, Use
UserService.load();
}, function(result) {
$scope.updatingUser = false;
UIService.showFormError('#changePasswordForm', result);
UIService.showFormError('#changePasswordForm', result);
});
};
@ -1900,7 +1901,7 @@ function UserAdminCtrl($scope, $timeout, $location, ApiService, PlanService, Use
};
}
function ImageViewCtrl($scope, $routeParams, $rootScope, $timeout, ApiService, ImageMetadataService) {
function ImageViewCtrl($scope, $routeParams, $rootScope, $timeout, ApiService, ImageMetadataService) {
var namespace = $routeParams.namespace;
var name = $routeParams.name;
var imageid = $routeParams.image;
@ -1924,7 +1925,7 @@ function ImageViewCtrl($scope, $routeParams, $rootScope, $timeout, ApiService, I
if (index < 0) {
return '';
}
return filepath.substr(0, index).split('/');
};
@ -1947,10 +1948,10 @@ function ImageViewCtrl($scope, $routeParams, $rootScope, $timeout, ApiService, I
$scope.search['$'] = filter;
document.getElementById('change-filter').value = filter;
};
$scope.initializeTree = function() {
if ($scope.tree) { return; }
$scope.tree = new ImageFileChangeTree($scope.image, $scope.combinedChanges);
$timeout(function() {
$scope.tree.draw('changes-tree-container');
@ -1970,7 +1971,7 @@ function ImageViewCtrl($scope, $routeParams, $rootScope, $timeout, ApiService, I
var fetchImage = function() {
var params = {
'repository': namespace + '/' + name,
'image_id': imageid
'image_id': imageid
};
$scope.image = ApiService.getImageAsResource(params).get(function(image) {
@ -1995,14 +1996,14 @@ function ImageViewCtrl($scope, $routeParams, $rootScope, $timeout, ApiService, I
var fetchChanges = function() {
var params = {
'repository': namespace + '/' + name,
'image_id': imageid
'image_id': imageid
};
ApiService.getImageChanges(null, params).then(function(changes) {
var combinedChanges = [];
var addCombinedChanges = function(c, kind) {
for (var i = 0; i < c.length; ++i) {
combinedChanges.push({
combinedChanges.push({
'kind': kind,
'file': c[i]
});
@ -2046,7 +2047,7 @@ function NewRepoCtrl($scope, $location, $http, $timeout, UserService, ApiService
$scope.$watch('repo.namespace', function(namespace) {
// Note: Can initially be undefined.
if (!namespace) { return; }
var isUserNamespace = (namespace == $scope.user.username);
$scope.planRequired = null;
@ -2083,7 +2084,7 @@ function NewRepoCtrl($scope, $location, $http, $timeout, UserService, ApiService
}
}
});
return true;
};
@ -2156,7 +2157,7 @@ function NewRepoCtrl($scope, $location, $http, $timeout, UserService, ApiService
var isUserNamespace = $scope.isUserNamespace;
ApiService.getPrivateAllowed(isUserNamespace ? null : $scope.repo.namespace).then(function(resp) {
$scope.checkingPlan = false;
if (resp['privateAllowed']) {
$scope.planRequired = null;
return;
@ -2198,8 +2199,8 @@ function OrgViewCtrl($rootScope, $scope, ApiService, $routeParams) {
{ 'id': 'creator', 'title': 'Creator', 'kind': 'success' },
{ 'id': 'admin', 'title': 'Admin', 'kind': 'primary' }
];
$scope.setRole = function(role, teamname) {
$scope.setRole = function(role, teamname) {
var previousRole = $scope.organization.teams[teamname].role;
$scope.organization.teams[teamname].role = role;
@ -2211,7 +2212,7 @@ function OrgViewCtrl($rootScope, $scope, ApiService, $routeParams) {
var data = $scope.organization.teams[teamname];
ApiService.updateOrganizationTeam(data, params).then(function(resp) {
}, function(resp) {
}, function(resp) {
$scope.organization.teams[teamname].role = previousRole;
$scope.roleError = resp.data || '';
$('#cannotChangeTeamModal').modal({});
@ -2286,7 +2287,7 @@ function OrgAdminCtrl($rootScope, $scope, $timeout, Restangular, $routeParams, U
PlanService.getPlans(function(plans) {
$scope.plans = plans;
$scope.plan_map = {};
for (var i = 0; i < plans.length; ++i) {
$scope.plan_map[plans[i].stripeId] = plans[i];
}
@ -2301,7 +2302,7 @@ function OrgAdminCtrl($rootScope, $scope, $timeout, Restangular, $routeParams, U
$scope.invoicesShown = 0;
$scope.applicationsShown = 0;
$scope.changingOrganization = false;
$scope.loadLogs = function() {
$scope.logsShown++;
};
@ -2424,7 +2425,7 @@ function TeamViewCtrl($rootScope, $scope, $timeout, Features, Restangular, ApiSe
$scope.addNewMember = function(member) {
if (!member || $scope.memberMap[member.name]) { return; }
var params = {
'orgname': orgname,
'teamname': teamname,
@ -2519,7 +2520,7 @@ function TeamViewCtrl($rootScope, $scope, $timeout, Features, Restangular, ApiSe
$scope.membersResource = ApiService.getOrganizationTeamMembersAsResource(params).get(function(resp) {
$scope.members = resp.members;
$scope.canEditMembers = resp.can_edit;
$('.info-icon').popover({
'trigger': 'hover',
'html': true
@ -2667,7 +2668,7 @@ function OrgMemberLogsCtrl($scope, $routeParams, $rootScope, $timeout, Restangul
});
return resp.member;
});
});
};
// Load the org info and the member info.
@ -2763,7 +2764,7 @@ function ManageApplicationCtrl($scope, $routeParams, $rootScope, $location, $tim
' under organization ' + $scope.orgname;
return resp;
});
});
};

View file

@ -12,7 +12,7 @@
subsection="'Admin'"></span>
</h3>
</div>
<div class="row">
<!-- Side tabs -->
<div class="col-md-2">
@ -30,8 +30,8 @@
<!-- Content -->
<div class="col-md-10">
<div class="tab-content">
<div class="tab-content">
<!-- Logs tab -->
<div id="logs" class="tab-pane">
<div class="logs-view" repository="repo" makevisible="logsShown"></div>
@ -48,7 +48,7 @@
Note: This repository is currently <b>private</b>. Publishing this badge will reveal the status information of your repository (and links may
not work for unregistered users).
</div>
<!-- Status Image -->
<a ng-href="/repository/{{ repo.namespace }}/{{ repo.name }}" ng-if="repo && repo.name">
<img ng-src="/repository/{{ repo.namespace }}/{{ repo.name }}/status?token={{ repo.status_token }}" data-title="Docker Repository on Quay.io">
@ -77,12 +77,12 @@
<td>
<div class="copy-box" hovering-message="true" value="getBadgeFormat('asciidoc', repo)"></div>
</td>
</tr>
</tr>
</table>
</div>
</div>
</div>
<!-- Permissions tab -->
<div id="permissions" class="tab-pane active">
<!-- User Access Permissions -->
@ -102,7 +102,7 @@
<td style="width: 95px;"></td>
</tr>
</thead>
<!-- Team Permissions -->
<tr ng-repeat="(name, permission) in permissions['team']">
<td class="team entity">
@ -117,7 +117,7 @@
<span class="delete-ui" delete-title="'Delete Permission'" perform-delete="deleteRole(name, 'team')"></span>
</td>
</tr>
<!-- User Permissions -->
<tr ng-repeat="(name, permission) in permissions['user']">
<td class="{{ 'user entity ' + (permission.is_org_member ? '' : 'outside') }}">
@ -164,10 +164,10 @@
<td></td>
</tr>
</thead>
<tr ng-repeat="(code, token) in tokens">
<td class="user token">
<i class="fa fa-key"></i>
<i class="fa fa-key"></i>
<a ng-click="showToken(token.code)">{{ token.friendlyName }}</a>
</td>
<td class="user-permissions">
@ -245,7 +245,7 @@
<td style="width: 104px;"></td>
</tr>
</thead>
<tbody>
<tr ng-repeat="trigger in triggers">
<td>
@ -279,7 +279,7 @@
</li>
</ul>
</div>
<div class="dropdown" style="display: inline-block">
<button class="btn btn-default dropdown-toggle" data-toggle="dropdown" data-title="Trigger Settings" bs-tooltip="tooltip.title" data-container="body">
<i class="fa fa-cog"></i>
@ -296,19 +296,20 @@
</tbody>
</table>
<!-- Right controls -->
<div class="right-controls">
<span ng-show="!Features.GITHUB_BUILD" class="pull-left">No build trigger types enabled.</span>
<div class="dropdown">
<button class="btn btn-primary dropdown-toggle" data-toggle="dropdown" ng-disabled="!Features.GITHUB_BUILD">
<button class="btn btn-primary dropdown-toggle" data-toggle="dropdown" ng-disabled="!Features.GITHUB_BUILD">
New Trigger
<b class="caret"></b>
</button>
<ul class="dropdown-menu dropdown-menu-right pull-right">
<li>
<a href="{{ TriggerService.getRedirectUrl('github', repo.namespace, repo.name) }}">
<i class="fa fa-github fa-lg"></i>GitHub - Repository Push
<i class="fa fa-github fa-lg"></i>
GitHub <span ng-if="KeyService.isEnterprise('github-trigger')">Enterprise</span> - Repository Push
</a>
</li>
</ul>
@ -321,7 +322,7 @@
</div>
<!-- Public/private tab -->
<div id="publicprivate" class="tab-pane">
<div id="publicprivate" class="tab-pane">
<!-- Public/Private -->
<div class="panel panel-default">
<div class="panel-body">