Work In Progress!

Get the full activation and deactivation cycle working for bitbucket.
This commit is contained in:
Joseph Schorr 2015-04-28 18:15:12 -04:00
parent 5cc91ed202
commit 6479f8ddc9
8 changed files with 204 additions and 65 deletions

View file

@ -13,6 +13,7 @@ angular.module('quay').directive('dropdownSelect', function ($compile) {
'selectedItem': '=selectedItem',
'placeholder': '=placeholder',
'lookaheadItems': '=lookaheadItems',
'hideDropdown': '=hideDropdown',
'allowCustomInput': '@allowCustomInput',

View file

@ -18,7 +18,7 @@ angular.module('quay').directive('triggerSetupGithost', function () {
'analyze': '&analyze'
},
controller: function($scope, $element, ApiService) {
controller: function($scope, $element, ApiService, TriggerService) {
$scope.analyzeCounter = 0;
$scope.setupReady = false;
$scope.refs = null;
@ -33,6 +33,12 @@ angular.module('quay').directive('triggerSetupGithost', function () {
'currentLocation': null
};
var checkLocation = function() {
var location = $scope.state.currentLocation || '';
$scope.state.isInvalidLocation = $scope.supportsFullListing &&
$scope.locations.indexOf(location) < 0;
};
$scope.isMatching = function(kind, name, filter) {
try {
var patt = new RegExp(filter);
@ -122,8 +128,8 @@ angular.module('quay').directive('triggerSetupGithost', function () {
$scope.setLocation($scope.locations[0]);
} else {
$scope.state.currentLocation = null;
$scope.state.isInvalidLocation = resp['subdir'].indexOf('') < 0;
$scope.trigger.$ready = true;
checkLocation();
}
callback();
@ -131,9 +137,9 @@ angular.module('quay').directive('triggerSetupGithost', function () {
}
$scope.handleLocationInput = function(location) {
$scope.state.isInvalidLocation = $scope.locations.indexOf(location) < 0;
$scope.trigger['config']['subdir'] = location || '';
$scope.trigger.$ready = true;
checkLocation();
};
$scope.handleLocationSelected = function(datum) {
@ -142,9 +148,9 @@ angular.module('quay').directive('triggerSetupGithost', function () {
$scope.setLocation = function(location) {
$scope.state.currentLocation = location;
$scope.state.isInvalidLocation = false;
$scope.trigger['config']['subdir'] = location || '';
$scope.trigger.$ready = true;
checkLocation();
};
$scope.selectRepo = function(repo, org) {
@ -199,6 +205,11 @@ angular.module('quay').directive('triggerSetupGithost', function () {
$scope.repoLookahead = repos;
};
$scope.$watch('trigger', function(trigger) {
if (!trigger) { return; }
$scope.supportsFullListing = TriggerService.supportsFullListing(trigger.service)
});
$scope.$watch('state.currentRepo', function(repo) {
if (repo) {
$scope.selectRepoInternal(repo);

View file

@ -49,7 +49,8 @@ angular.module('quay').factory('TriggerService', ['UtilService', '$sanitize', 'K
}
return 'GitHub Repository Push';
}
},
'supports_full_directory_listing': true
},
'bitbucket': {
@ -75,7 +76,8 @@ angular.module('quay').factory('TriggerService', ['UtilService', '$sanitize', 'K
return Features.BITBUCKET_BUILD;
},
'icon': 'fa-bitbucket',
'title': function() { return 'Bitbucket Repository Push'; }
'title': function() { return 'Bitbucket Repository Push'; },
'supports_full_directory_listing': false
},
'custom-git': {
@ -104,6 +106,15 @@ angular.module('quay').factory('TriggerService', ['UtilService', '$sanitize', 'K
}
}
triggerService.supportsFullListing = function(name) {
var type = triggerTypes[name];
if (!type) {
return false;
}
return !!type['supports_full_directory_listing'];
};
triggerService.getTypes = function() {
var types = [];
for (var key in triggerTypes) {