Refactor UsersController to present personal, contributed and starred projects in the same way

This commit is contained in:
Camil Staps 2019-01-28 20:27:30 +01:00
parent e7c34c37c8
commit afc2f6a031
No known key found for this signature in database
GPG key ID: 4A9BFD4F6A415F83

View file

@ -57,34 +57,22 @@ class UsersController < ApplicationController
def projects def projects
load_projects load_projects
skip_pagination = Gitlab::Utils.to_boolean(params[:skip_pagination]) present_projects(@projects)
skip_namespace = Gitlab::Utils.to_boolean(params[:skip_namespace])
compact_mode = Gitlab::Utils.to_boolean(params[:compact_mode])
respond_to do |format|
format.html { render 'show' }
format.json do
pager_json("shared/projects/_list", @projects.count, projects: @projects, skip_pagination: skip_pagination, skip_namespace: skip_namespace, compact_mode: compact_mode)
end
end
end end
def contributed def contributed
load_contributed_projects load_contributed_projects
respond_to do |format| present_projects(@contributed_projects)
format.html { render 'show' }
format.json do
render json: {
html: view_to_html_string("shared/projects/_list", projects: @contributed_projects)
}
end
end
end end
def starred def starred
load_starred_projects load_starred_projects
present_projects(@starred_projects)
end
def present_projects(projects)
skip_pagination = Gitlab::Utils.to_boolean(params[:skip_pagination]) skip_pagination = Gitlab::Utils.to_boolean(params[:skip_pagination])
skip_namespace = Gitlab::Utils.to_boolean(params[:skip_namespace]) skip_namespace = Gitlab::Utils.to_boolean(params[:skip_namespace])
compact_mode = Gitlab::Utils.to_boolean(params[:compact_mode]) compact_mode = Gitlab::Utils.to_boolean(params[:compact_mode])
@ -92,7 +80,7 @@ class UsersController < ApplicationController
respond_to do |format| respond_to do |format|
format.html { render 'show' } format.html { render 'show' }
format.json do format.json do
pager_json("shared/projects/_list", @starred_projects.count, projects: @starred_projects, skip_pagination: skip_pagination, skip_namespace: skip_namespace, compact_mode: compact_mode) pager_json("shared/projects/_list", projects.count, projects: projects, skip_pagination: skip_pagination, skip_namespace: skip_namespace, compact_mode: compact_mode)
end end
end end
end end