Commit 437d4c76 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Remove duplication in diff_helper.rb

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 5f239093
......@@ -132,25 +132,11 @@ module DiffHelper
end
def inline_diff_btn
params_copy = params.dup
params_copy[:view] = 'inline'
# Always use HTML to handle case where JSON diff rendered this button
params_copy.delete(:format)
link_to url_for(params_copy), id: "inline-diff-btn", class: (params[:view] != 'parallel' ? 'btn active' : 'btn') do
'Inline'
end
diff_btn('Inline', 'inline', params[:view] != 'parallel')
end
def parallel_diff_btn
params_copy = params.dup
params_copy[:view] = 'parallel'
# Always use HTML to handle case where JSON diff rendered this button
params_copy.delete(:format)
link_to url_for(params_copy), id: "parallel-diff-btn", class: (params[:view] == 'parallel' ? 'btn active' : 'btn') do
'Side-by-side'
end
diff_btn('Side-by-side', 'parallel', params[:view] == 'parallel')
end
def submodule_link(blob, ref, repository = @repository)
......@@ -187,4 +173,18 @@ module DiffHelper
def editable_diff?(diff)
!diff.deleted_file && @merge_request && @merge_request.source_project
end
private
def diff_btn(title, name, selected)
params_copy = params.dup
params_copy[:view] = name
# Always use HTML to handle case where JSON diff rendered this button
params_copy.delete(:format)
link_to url_for(params_copy), id: "#{name}-diff-btn", class: (selected ? 'btn active' : 'btn') do
title
end
end
end
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