Commit 75060b93 authored by Jacopo's avatar Jacopo

Go to a project order

The order of "Go to a project" dropdown is based on last_activity_at
parent 9a3c53fd
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,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);
}; };
...@@ -32,7 +33,7 @@ ...@@ -32,7 +33,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
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,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