diff options
author | Rémy Coutable <remy@rymai.me> | 2016-02-08 16:34:58 +0300 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2016-02-08 16:34:58 +0300 |
commit | 9fdd605fd2e4550170e5ef088bec7c6d2585c4a5 (patch) | |
tree | 3b44244170dae0c23611248055899f53ed3f1c39 /app | |
parent | 05519b554a49057f6551595a3bc3f01e140f3c0b (diff) | |
parent | 551ce0f245d92245c1365754d1a60818a5a6ca36 (diff) |
Merge branch 'kkm/gitlab-ce-user-diff-view-pref-cookie' into 'master'
Remember user's inline/tabular diff view preference in a cookie
_Originally opened at !1677 by @kkm._
---
As per #3071, some users (we have a local EE installation) prefer 2-column view in diff. In this MR I add an implementation for this feature, using a cookie.
Fixes #3071.
See merge request !2723
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/projects/application_controller.rb | 5 | ||||
-rw-r--r-- | app/controllers/projects/commit_controller.rb | 2 | ||||
-rw-r--r-- | app/controllers/projects/merge_requests_controller.rb | 2 |
3 files changed, 9 insertions, 0 deletions
diff --git a/app/controllers/projects/application_controller.rb b/app/controllers/projects/application_controller.rb index dd32d509191..a326bc58215 100644 --- a/app/controllers/projects/application_controller.rb +++ b/app/controllers/projects/application_controller.rb @@ -28,6 +28,11 @@ class Projects::ApplicationController < ApplicationController private + def apply_diff_view_cookie! + view = params[:view] || cookies[:diff_view] + cookies.permanent[:diff_view] = params[:view] = view if view + end + def builds_enabled return render_404 unless @project.builds_enabled? end diff --git a/app/controllers/projects/commit_controller.rb b/app/controllers/projects/commit_controller.rb index f5a169e5aa9..5a084e123a1 100644 --- a/app/controllers/projects/commit_controller.rb +++ b/app/controllers/projects/commit_controller.rb @@ -13,6 +13,8 @@ class Projects::CommitController < Projects::ApplicationController def show return git_not_found! unless @commit + apply_diff_view_cookie! + @line_notes = commit.notes.inline @note = @project.build_commit_note(commit) @notes = commit.notes.not_inline.fresh diff --git a/app/controllers/projects/merge_requests_controller.rb b/app/controllers/projects/merge_requests_controller.rb index ed3050d59aa..9d588c370aa 100644 --- a/app/controllers/projects/merge_requests_controller.rb +++ b/app/controllers/projects/merge_requests_controller.rb @@ -57,6 +57,8 @@ class Projects::MergeRequestsController < Projects::ApplicationController end def diffs + apply_diff_view_cookie! + @commit = @merge_request.last_commit @base_commit = @merge_request.diff_base_commit |