diff options
author | Alfredo Sumaran <alfredo@gitlab.com> | 2016-03-23 11:10:17 -0500 |
---|---|---|
committer | Alfredo Sumaran <alfredo@gitlab.com> | 2016-04-26 14:01:40 -0500 |
commit | d8d00b5bc29f7b89f95c436cd6900d1548f111b7 (patch) | |
tree | 4c90ee8317fa575909519bea5ea648dd4f1abd2e /app | |
parent | 18e00e3ba316b464bd0a6a78ae0c2669afa15f5a (diff) | |
download | gitlab-ce-d8d00b5bc29f7b89f95c436cd6900d1548f111b7.tar.gz |
Add Hide/show whitespace changes button on diff and commit view
Diffstat (limited to 'app')
-rw-r--r-- | app/helpers/diff_helper.rb | 22 | ||||
-rw-r--r-- | app/views/projects/diffs/_diffs.html.haml | 4 |
2 files changed, 26 insertions, 0 deletions
diff --git a/app/helpers/diff_helper.rb b/app/helpers/diff_helper.rb index 97466d532f4..eca4ba695a1 100644 --- a/app/helpers/diff_helper.rb +++ b/app/helpers/diff_helper.rb @@ -128,4 +128,26 @@ module DiffHelper title end end + + def hide_whitespaces? + params[:w] == '1' + end + + def params_with_whitespace + hide_whitespaces? ? request.query_parameters.except(:w) : request.query_parameters.merge(w: 1) + end + + def toggle_whitespace_link(url) + link_to "#{hide_whitespaces? ? 'Show' : 'Hide'} whitespace changes", url, class: "btn btn-default" + end + + def commit_diff_whitespace_link(project, commit) + url = namespace_project_commit_path(project.namespace, project, commit.id, params_with_whitespace) + toggle_whitespace_link(url) + end + + def diff_merge_request_whitespace_link(project, merge_request) + url = diffs_namespace_project_merge_request_path(project.namespace, project, merge_request, params_with_whitespace) + toggle_whitespace_link(url) + end end diff --git a/app/views/projects/diffs/_diffs.html.haml b/app/views/projects/diffs/_diffs.html.haml index eaab99973a4..fbfff9bc895 100644 --- a/app/views/projects/diffs/_diffs.html.haml +++ b/app/views/projects/diffs/_diffs.html.haml @@ -5,6 +5,10 @@ .content-block.oneline-block.files-changed .inline-parallel-buttons + - if current_controller?(:commit) + = commit_diff_whitespace_link(@project, @commit) + - if current_controller?(:merge_requests) + = diff_merge_request_whitespace_link(@project, @merge_request) .btn-group = inline_diff_btn = parallel_diff_btn |