Add setup UI for the new trigger types (bitbucket and gitlab) and add validation
This commit is contained in:
parent
0b990677a0
commit
4f2a1b3734
4 changed files with 229 additions and 20 deletions
|
@ -12,7 +12,7 @@ angular.module("core-config-setup", ['angularFileUpload'])
|
|||
},
|
||||
controller: function($rootScope, $scope, $element, $timeout, ApiService) {
|
||||
$scope.HOSTNAME_REGEX = '^[a-zA-Z-0-9\.]+(:[0-9]+)?$';
|
||||
$scope.GITHUB_REGEX = '^https?://([a-zA-Z0-9]+\.?\/?)+$';
|
||||
$scope.GITHOST_REGEX = '^https?://([a-zA-Z0-9]+\.?\/?)+$';
|
||||
|
||||
$scope.SERVICES = [
|
||||
{'id': 'redis', 'title': 'Redis'},
|
||||
|
@ -39,8 +39,16 @@ angular.module("core-config-setup", ['angularFileUpload'])
|
|||
return config.FEATURE_GOOGLE_LOGIN;
|
||||
}},
|
||||
|
||||
{'id': 'github-trigger', 'title': 'Github (Enterprise) Build Triggers', 'condition': function(config) {
|
||||
{'id': 'github-trigger', 'title': 'GitHub (Enterprise) Build Triggers', 'condition': function(config) {
|
||||
return config.FEATURE_GITHUB_BUILD;
|
||||
}},
|
||||
|
||||
{'id': 'bitbucket-trigger', 'title': 'BitBucket Build Triggers', 'condition': function(config) {
|
||||
return config.FEATURE_BITBUCKET_BUILD;
|
||||
}},
|
||||
|
||||
{'id': 'gitlab-trigger', 'title': 'GitLab Build Triggers', 'condition': function(config) {
|
||||
return config.FEATURE_GITLAB_BUILD;
|
||||
}}
|
||||
];
|
||||
|
||||
|
@ -184,6 +192,24 @@ angular.module("core-config-setup", ['angularFileUpload'])
|
|||
}, ApiService.errorDisplay('Could not save configuration. Please report this error.'));
|
||||
};
|
||||
|
||||
var gitlabSelector = function(key) {
|
||||
return function(value) {
|
||||
if (!value || !$scope.config) { return; }
|
||||
|
||||
if (!$scope.config[key]) {
|
||||
$scope.config[key] = {};
|
||||
}
|
||||
|
||||
if (value == 'enterprise') {
|
||||
if ($scope.config[key]['GITLAB_ENDPOINT'] == 'https://gitlab.com/') {
|
||||
$scope.config[key]['GITLAB_ENDPOINT'] = '';
|
||||
}
|
||||
} else if (value == 'hosted') {
|
||||
$scope.config[key]['GITLAB_ENDPOINT'] = 'https://gitlab.com/';
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
var githubSelector = function(key) {
|
||||
return function(value) {
|
||||
if (!value || !$scope.config) { return; }
|
||||
|
@ -226,6 +252,9 @@ angular.module("core-config-setup", ['angularFileUpload'])
|
|||
$scope.mapped['GITHUB_LOGIN_KIND'] = gle == 'https://github.com/' ? 'hosted' : 'enterprise';
|
||||
$scope.mapped['GITHUB_TRIGGER_KIND'] = gte == 'https://github.com/' ? 'hosted' : 'enterprise';
|
||||
|
||||
var glabe = getKey(config, 'GITLAB_TRIGGER_KIND.GITHUB_ENDPOINT');
|
||||
$scope.mapped['GITLAB_TRIGGER_KIND'] = glabe == 'https://gitlab.com/' ? 'hosted' : 'enterprise';
|
||||
|
||||
$scope.mapped['redis'] = {};
|
||||
$scope.mapped['redis']['host'] = getKey(config, 'BUILDLOGS_REDIS.host') || getKey(config, 'USER_EVENTS_REDIS.host');
|
||||
$scope.mapped['redis']['port'] = getKey(config, 'BUILDLOGS_REDIS.port') || getKey(config, 'USER_EVENTS_REDIS.port');
|
||||
|
@ -258,6 +287,7 @@ angular.module("core-config-setup", ['angularFileUpload'])
|
|||
// Add mapped logic.
|
||||
$scope.$watch('mapped.GITHUB_LOGIN_KIND', githubSelector('GITHUB_LOGIN_CONFIG'));
|
||||
$scope.$watch('mapped.GITHUB_TRIGGER_KIND', githubSelector('GITHUB_TRIGGER_CONFIG'));
|
||||
$scope.$watch('mapped.GITLAB_TRIGGER_KIND', gitlabSelector('GITLAB_TRIGGER_KIND'));
|
||||
|
||||
$scope.$watch('mapped.redis.host', redisSetter('host'));
|
||||
$scope.$watch('mapped.redis.port', redisSetter('port'));
|
||||
|
|
Reference in a new issue