diff options
author | Camil Staps <info@camilstaps.nl> | 2019-01-28 20:27:30 +0100 |
---|---|---|
committer | Camil Staps <info@camilstaps.nl> | 2019-08-07 20:49:15 +0200 |
commit | afc2f6a0316ec79b2fd818e292a8aa191b6a47eb (patch) | |
tree | 78624ace86c9aed14bf01e86967d6baa51c4a31f | |
parent | e7c34c37c83d877a887173d833ba4103772d1566 (diff) | |
download | gitlab-ce-afc2f6a0316ec79b2fd818e292a8aa191b6a47eb.tar.gz |
Refactor UsersController to present personal, contributed and starred projects in the same way
-rw-r--r-- | app/controllers/users_controller.rb | 26 |
1 files changed, 7 insertions, 19 deletions
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index dc180de1507..2e142a9ecf4 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -57,34 +57,22 @@ class UsersController < ApplicationController def projects load_projects - skip_pagination = Gitlab::Utils.to_boolean(params[:skip_pagination]) - 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 + present_projects(@projects) end def contributed load_contributed_projects - respond_to do |format| - format.html { render 'show' } - format.json do - render json: { - html: view_to_html_string("shared/projects/_list", projects: @contributed_projects) - } - end - end + present_projects(@contributed_projects) end def starred load_starred_projects + present_projects(@starred_projects) + end + + def present_projects(projects) skip_pagination = Gitlab::Utils.to_boolean(params[:skip_pagination]) skip_namespace = Gitlab::Utils.to_boolean(params[:skip_namespace]) compact_mode = Gitlab::Utils.to_boolean(params[:compact_mode]) @@ -92,7 +80,7 @@ class UsersController < ApplicationController respond_to do |format| format.html { render 'show' } 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 |