- Switch to new typeahead (based on our own branch of it until such time as it gets pulled into the mainline) and add an informative empty message on entity search
- Add better messaging around pushing to empty repos
This commit is contained in:
parent
536a91cbb8
commit
2a8669b2f4
8 changed files with 153 additions and 56 deletions
149
static/js/app.js
149
static/js/app.js
|
@ -2008,8 +2008,7 @@ quayApp.directive('repoSearch', function () {
|
|||
++searchToken;
|
||||
}, true);
|
||||
|
||||
var element = $($element[0].childNodes[0]);
|
||||
element.typeahead({
|
||||
var repoHound = new Bloodhound({
|
||||
name: 'repositories',
|
||||
remote: {
|
||||
url: '/api/find/repository?query=%QUERY',
|
||||
|
@ -2031,22 +2030,36 @@ quayApp.directive('repoSearch', function () {
|
|||
return datums;
|
||||
}
|
||||
},
|
||||
template: function (datum) {
|
||||
template = '<div class="repo-mini-listing">';
|
||||
template += '<i class="fa fa-hdd-o fa-lg"></i>'
|
||||
template += '<span class="name">' + datum.repo.namespace +'/' + datum.repo.name + '</span>'
|
||||
if (datum.repo.description) {
|
||||
template += '<span class="description">' + getFirstTextLine(datum.repo.description) + '</span>'
|
||||
}
|
||||
datumTokenizer: function(d) {
|
||||
return Bloodhound.tokenizers.whitespace(d.val);
|
||||
},
|
||||
queryTokenizer: Bloodhound.tokenizers.whitespace
|
||||
});
|
||||
repoHound.initialize();
|
||||
|
||||
template += '</div>'
|
||||
return template;
|
||||
var element = $($element[0].childNodes[0]);
|
||||
element.typeahead({ 'highlight': true }, {
|
||||
source: repoHound.ttAdapter(),
|
||||
templates: {
|
||||
'suggestion': function (datum) {
|
||||
template = '<div class="repo-mini-listing">';
|
||||
template += '<i class="fa fa-hdd-o fa-lg"></i>'
|
||||
template += '<span class="name">' + datum.repo.namespace +'/' + datum.repo.name + '</span>'
|
||||
if (datum.repo.description) {
|
||||
template += '<span class="description">' + getFirstTextLine(datum.repo.description) + '</span>'
|
||||
}
|
||||
|
||||
template += '</div>'
|
||||
return template;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
element.on('typeahead:selected', function (e, datum) {
|
||||
element.typeahead('setQuery', '');
|
||||
document.location = '/repository/' + datum.repo.namespace + '/' + datum.repo.name;
|
||||
element.typeahead('val', '');
|
||||
$scope.$apply(function() {
|
||||
$location.path('/repository/' + datum.repo.namespace + '/' + datum.repo.name);
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
@ -2213,7 +2226,7 @@ quayApp.directive('entitySearch', function () {
|
|||
};
|
||||
|
||||
$scope.setEntityInternal = function(entity) {
|
||||
$(input).typeahead('setQuery', $scope.isPersistent ? entity.name : '');
|
||||
$(input).typeahead('val', $scope.isPersistent ? entity.name : '');
|
||||
|
||||
if ($scope.isPersistent) {
|
||||
$scope.currentEntity = entity;
|
||||
|
@ -2226,8 +2239,7 @@ quayApp.directive('entitySearch', function () {
|
|||
|
||||
number++;
|
||||
|
||||
var input = $element[0].firstChild.firstChild;
|
||||
$(input).typeahead({
|
||||
var entitySearchB = new Bloodhound({
|
||||
name: 'entities' + number,
|
||||
remote: {
|
||||
url: '/api/entities/%QUERY',
|
||||
|
@ -2253,24 +2265,57 @@ quayApp.directive('entitySearch', function () {
|
|||
return datums;
|
||||
}
|
||||
},
|
||||
template: function (datum) {
|
||||
template = '<div class="entity-mini-listing">';
|
||||
if (datum.entity.kind == 'user' && !datum.entity.is_robot) {
|
||||
template += '<i class="fa fa-user fa-lg"></i>';
|
||||
} else if (datum.entity.kind == 'user' && datum.entity.is_robot) {
|
||||
template += '<i class="fa fa-wrench fa-lg"></i>';
|
||||
} else if (datum.entity.kind == 'team') {
|
||||
template += '<i class="fa fa-group fa-lg"></i>';
|
||||
}
|
||||
template += '<span class="name">' + datum.value + '</span>';
|
||||
|
||||
if (datum.entity.is_org_member === false && datum.entity.kind == 'user') {
|
||||
template += '<i class="fa fa-exclamation-triangle" title="User is outside the organization"></i>';
|
||||
}
|
||||
|
||||
template += '</div>';
|
||||
return template;
|
||||
datumTokenizer: function(d) {
|
||||
return Bloodhound.tokenizers.whitespace(d.val);
|
||||
},
|
||||
queryTokenizer: Bloodhound.tokenizers.whitespace
|
||||
});
|
||||
entitySearchB.initialize();
|
||||
|
||||
var counter = 0;
|
||||
var input = $element[0].firstChild.firstChild;
|
||||
$(input).typeahead({
|
||||
'highlight': true
|
||||
}, {
|
||||
source: entitySearchB.ttAdapter(),
|
||||
templates: {
|
||||
'empty': function(info) {
|
||||
// Only display the empty dialog if the server load has finished.
|
||||
if (info.resultKind == 'remote') {
|
||||
var val = $(input).val();
|
||||
if (!val) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (val.indexOf('@') > 0) {
|
||||
return '<div class="tt-empty">A Quay.io username (not an e-mail address) must be specified</div>';
|
||||
}
|
||||
|
||||
var robots = $scope.isOrganization ? ', robot accounts' : '';
|
||||
var teams = ($scope.includeTeams && $scope.isOrganization) ? ' or teams' : '';
|
||||
return '<div class="tt-empty">No matching Quay.io users' + robots + teams + ' found</div>';
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
'suggestion': function (datum) {
|
||||
template = '<div class="entity-mini-listing">';
|
||||
if (datum.entity.kind == 'user' && !datum.entity.is_robot) {
|
||||
template += '<i class="fa fa-user fa-lg"></i>';
|
||||
} else if (datum.entity.kind == 'user' && datum.entity.is_robot) {
|
||||
template += '<i class="fa fa-wrench fa-lg"></i>';
|
||||
} else if (datum.entity.kind == 'team') {
|
||||
template += '<i class="fa fa-group fa-lg"></i>';
|
||||
}
|
||||
template += '<span class="name">' + datum.value + '</span>';
|
||||
|
||||
if (datum.entity.is_org_member === false && datum.entity.kind == 'user') {
|
||||
template += '<i class="fa fa-exclamation-triangle" title="User is outside the organization"></i>';
|
||||
}
|
||||
|
||||
template += '</div>';
|
||||
return template;
|
||||
}}
|
||||
});
|
||||
|
||||
$(input).on('input', function(e) {
|
||||
|
@ -2288,7 +2333,7 @@ quayApp.directive('entitySearch', function () {
|
|||
});
|
||||
|
||||
$scope.$watch('clearNow', function() {
|
||||
$(input).typeahead('setQuery', '');
|
||||
$(input).typeahead('val', '');
|
||||
$scope.clearEntityInternal();
|
||||
});
|
||||
|
||||
|
@ -2722,12 +2767,34 @@ quayApp.directive('dropdownSelect', function ($compile) {
|
|||
return;
|
||||
}
|
||||
|
||||
$(input).typeahead({
|
||||
var formattedItems = [];
|
||||
for (var i = 0; i < items.length; ++i) {
|
||||
var formattedItem = items[i];
|
||||
if (typeof formattedItem == 'string') {
|
||||
formattedItem = {
|
||||
'value': formattedItem
|
||||
};
|
||||
}
|
||||
formattedItems.push(formattedItem);
|
||||
}
|
||||
|
||||
var dropdownHound = new Bloodhound({
|
||||
name: 'dropdown-items-' + $rootScope.__dropdownSelectCounter,
|
||||
local: items,
|
||||
template: function (datum) {
|
||||
template = datum['template'] ? datum['template'](datum) : datum['value'];
|
||||
return template;
|
||||
local: formattedItems,
|
||||
datumTokenizer: function(d) {
|
||||
return Bloodhound.tokenizers.whitespace(d.val || d.value || '');
|
||||
},
|
||||
queryTokenizer: Bloodhound.tokenizers.whitespace
|
||||
});
|
||||
dropdownHound.initialize();
|
||||
|
||||
$(input).typeahead({}, {
|
||||
source: dropdownHound.ttAdapter(),
|
||||
templates: {
|
||||
'suggestion': function (datum) {
|
||||
template = datum['template'] ? datum['template'](datum) : datum['value'];
|
||||
return template;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -2830,6 +2897,10 @@ quayApp.directive('triggerSetupGithub', function () {
|
|||
$scope.isInvalidLocation = $scope.locations.indexOf(location) < 0;
|
||||
};
|
||||
|
||||
$scope.handleLocationSelected = function(datum) {
|
||||
$scope.setLocation(datum['value']);
|
||||
};
|
||||
|
||||
$scope.setLocation = function(location) {
|
||||
$scope.currentLocation = location;
|
||||
$scope.trigger['config']['subdir'] = location || '';
|
||||
|
|
Reference in a new issue