Commit d8d00b5b authored by Alfredo Sumaran's avatar Alfredo Sumaran

Add Hide/show whitespace changes button on diff and commit view

parent 18e00e3b
...@@ -128,4 +128,26 @@ module DiffHelper ...@@ -128,4 +128,26 @@ module DiffHelper
title title
end end
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 end
...@@ -5,6 +5,10 @@ ...@@ -5,6 +5,10 @@
.content-block.oneline-block.files-changed .content-block.oneline-block.files-changed
.inline-parallel-buttons .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 .btn-group
= inline_diff_btn = inline_diff_btn
= parallel_diff_btn = parallel_diff_btn
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment