Merge branch '28864-use-the-v4-api-from-the-frontend' into 'master'
Resolve "Use the v4 API from the frontend" Closes #28864 See merge request !9714
This commit is contained in:
commit
ffcddb2959
6 changed files with 11 additions and 11 deletions
|
@ -51,15 +51,15 @@ var Api = {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
// Return projects list. Filtered by query
|
// Return projects list. Filtered by query
|
||||||
projects: function(query, order, callback) {
|
projects: function(query, options, callback) {
|
||||||
var url = Api.buildUrl(Api.projectsPath);
|
var url = Api.buildUrl(Api.projectsPath);
|
||||||
return $.ajax({
|
return $.ajax({
|
||||||
url: url,
|
url: url,
|
||||||
data: {
|
data: $.extend({
|
||||||
search: query,
|
search: query,
|
||||||
order_by: order,
|
per_page: 20,
|
||||||
per_page: 20
|
membership: true
|
||||||
},
|
}, options),
|
||||||
dataType: "json"
|
dataType: "json"
|
||||||
}).done(function(projects) {
|
}).done(function(projects) {
|
||||||
return callback(projects);
|
return callback(projects);
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
if (this.groupId) {
|
if (this.groupId) {
|
||||||
return Api.groupProjects(this.groupId, term, projectsCallback);
|
return Api.groupProjects(this.groupId, term, projectsCallback);
|
||||||
} else {
|
} else {
|
||||||
return Api.projects(term, orderBy, projectsCallback);
|
return Api.projects(term, { order_by: orderBy }, projectsCallback);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
url: function(project) {
|
url: function(project) {
|
||||||
|
@ -84,7 +84,7 @@
|
||||||
if (_this.groupId) {
|
if (_this.groupId) {
|
||||||
return Api.groupProjects(_this.groupId, query.term, projectsCallback);
|
return Api.groupProjects(_this.groupId, query.term, projectsCallback);
|
||||||
} else {
|
} else {
|
||||||
return Api.projects(query.term, _this.orderBy, projectsCallback);
|
return Api.projects(query.term, { order_by: _this.orderBy }, projectsCallback);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
})(this),
|
})(this),
|
||||||
|
|
|
@ -47,7 +47,7 @@
|
||||||
fields: ['name']
|
fields: ['name']
|
||||||
},
|
},
|
||||||
data: function(term, callback) {
|
data: function(term, callback) {
|
||||||
return Api.projects(term, 'id', function(data) {
|
return Api.projects(term, { order_by: 'id' }, function(data) {
|
||||||
data.unshift({
|
data.unshift({
|
||||||
name_with_namespace: 'Any'
|
name_with_namespace: 'Any'
|
||||||
});
|
});
|
||||||
|
|
|
@ -410,7 +410,7 @@
|
||||||
:javascript
|
:javascript
|
||||||
$('#js-project-dropdown').glDropdown({
|
$('#js-project-dropdown').glDropdown({
|
||||||
data: function (term, callback) {
|
data: function (term, callback) {
|
||||||
Api.projects(term, "last_activity_at", function (data) {
|
Api.projects(term, { order_by: 'last_activity_at' }, function (data) {
|
||||||
callback(data);
|
callback(data);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
module Gitlab
|
module Gitlab
|
||||||
module GonHelper
|
module GonHelper
|
||||||
def add_gon_variables
|
def add_gon_variables
|
||||||
gon.api_version = 'v3' # v4 Is not officially released yet, therefore can't be considered as "frozen"
|
gon.api_version = 'v4'
|
||||||
gon.default_avatar_url = URI.join(Gitlab.config.gitlab.url, ActionController::Base.helpers.image_path('no_avatar.png')).to_s
|
gon.default_avatar_url = URI.join(Gitlab.config.gitlab.url, ActionController::Base.helpers.image_path('no_avatar.png')).to_s
|
||||||
gon.max_file_size = current_application_settings.max_attachment_size
|
gon.max_file_size = current_application_settings.max_attachment_size
|
||||||
gon.asset_host = ActionController::Base.asset_host
|
gon.asset_host = ActionController::Base.asset_host
|
||||||
|
|
|
@ -26,7 +26,7 @@ require('~/project');
|
||||||
var fakeAjaxResponse = function fakeAjaxResponse(req) {
|
var fakeAjaxResponse = function fakeAjaxResponse(req) {
|
||||||
var d;
|
var d;
|
||||||
expect(req.url).toBe('/api/v3/projects.json?simple=true');
|
expect(req.url).toBe('/api/v3/projects.json?simple=true');
|
||||||
expect(req.data).toEqual({ search: '', order_by: 'last_activity_at', per_page: 20 });
|
expect(req.data).toEqual({ search: '', order_by: 'last_activity_at', per_page: 20, membership: true });
|
||||||
d = $.Deferred();
|
d = $.Deferred();
|
||||||
d.resolve(this.projects_data);
|
d.resolve(this.projects_data);
|
||||||
return d.promise();
|
return d.promise();
|
||||||
|
|
Loading…
Reference in a new issue