Skip to content
Snippets Groups Projects
Verified Commit de6f2884 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

Sort projects by last activity for project switcher in header

parent c8224f0b
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -47,7 +47,7 @@
callback(namespaces)
 
# Return projects list. Filtered by query
projects: (query, callback) ->
projects: (query, order, callback) ->
url = Api.buildUrl(Api.projects_path)
 
$.ajax(
Loading
Loading
@@ -55,6 +55,7 @@
data:
private_token: gon.api_token
search: query
order_by: order
per_page: 20
dataType: "json"
).done (projects) ->
Loading
Loading
Loading
Loading
@@ -3,6 +3,7 @@ class @ProjectSelect
$('.ajax-project-select').each (i, select) ->
@groupId = $(select).data('group-id')
@includeGroups = $(select).data('include-groups')
@orderBy = $(select).data('order-by') || 'id'
 
placeholder = "Search for project"
placeholder += " or group" if @includeGroups
Loading
Loading
@@ -28,7 +29,7 @@ class @ProjectSelect
if @groupId
Api.groupProjects @groupId, query.term, projectsCallback
else
Api.projects query.term, projectsCallback
Api.projects query.term, @orderBy, projectsCallback
 
id: (project) ->
project.web_url
Loading
Loading
Loading
Loading
@@ -57,7 +57,10 @@ module ProjectsHelper
link_output = simple_sanitize(project.name)
link_output += content_tag :span, nil, { class: "fa fa-chevron-down dropdown-toggle-caret" } if current_user
 
link_output += project_select_tag :project_path, class: "project-item-select js-projects-dropdown", data: { include_groups: false } if current_user
if current_user
link_output += project_select_tag :project_path, class: "project-item-select js-projects-dropdown",
data: { include_groups: false, order_by: 'last_activity_at' }
end
 
link_output
end
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment