Commit 2ed90c45 authored by Alfredo Sumaran's avatar Alfredo Sumaran

Merge branch '18786-go-to-a-project-order' into 'master'

Go to a project order

Closes #18786

See merge request !7737
parents ae51027d 75060b93
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
}, },
data: function(term, callback) { data: function(term, callback) {
var finalCallback, projectsCallback; var finalCallback, projectsCallback;
var orderBy = $dropdown.data('order-by');
finalCallback = function(projects) { finalCallback = function(projects) {
return callback(projects); return callback(projects);
}; };
...@@ -34,7 +35,7 @@ ...@@ -34,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, this.orderBy, projectsCallback); return Api.projects(term, orderBy, projectsCallback);
} }
}, },
url: function(project) { url: function(project) {
......
...@@ -61,7 +61,7 @@ module ProjectsHelper ...@@ -61,7 +61,7 @@ module ProjectsHelper
project_link = link_to simple_sanitize(project.name), project_path(project), { class: "project-item-select-holder" } project_link = link_to simple_sanitize(project.name), project_path(project), { class: "project-item-select-holder" }
if current_user if current_user
project_link << button_tag(type: 'button', class: "dropdown-toggle-caret js-projects-dropdown-toggle", aria: { label: "Toggle switch project dropdown" }, data: { target: ".js-dropdown-menu-projects", toggle: "dropdown" }) do project_link << button_tag(type: 'button', class: 'dropdown-toggle-caret js-projects-dropdown-toggle', aria: { label: 'Toggle switch project dropdown' }, data: { target: '.js-dropdown-menu-projects', toggle: 'dropdown', order_by: 'last_activity_at' }) do
icon("chevron-down") icon("chevron-down")
end end
end end
......
---
title: Go to a project order
merge_request: 7737
author: Jacopo Beschi @jacopo-beschi
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
GitLab Org GitLab Org
%a.project-item-select-holder{href: "/gitlab-org/gitlab-test"} %a.project-item-select-holder{href: "/gitlab-org/gitlab-test"}
GitLab Test GitLab Test
%i.fa.chevron-down.dropdown-toggle-caret.js-projects-dropdown-toggle{ "data-toggle" => "dropdown", "data-target" => ".header-content" } %i.fa.chevron-down.dropdown-toggle-caret.js-projects-dropdown-toggle{ "data-toggle" => "dropdown", "data-target" => ".header-content", "data-order-by" => "last_activity_at" }
.js-dropdown-menu-projects .js-dropdown-menu-projects
.dropdown-menu.dropdown-select.dropdown-menu-projects .dropdown-menu.dropdown-select.dropdown-menu-projects
.dropdown-title .dropdown-title
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
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 });
d = $.Deferred(); d = $.Deferred();
d.resolve(this.projects_data); d.resolve(this.projects_data);
return d.promise(); return d.promise();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment