diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-11-17 10:49:23 +0100 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-11-17 10:49:23 +0100 |
commit | 437d4c76ece4bdf89e3702b05d13027a9a6f63a1 (patch) | |
tree | ab3a4c367ea495a5fa6d1cd146007cc8c534d692 | |
parent | 5f239093623afcbb0cbc32c385fb2a5733f7eccb (diff) | |
download | gitlab-ce-437d4c76ece4bdf89e3702b05d13027a9a6f63a1.tar.gz |
Remove duplication in diff_helper.rb
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
-rw-r--r-- | app/helpers/diff_helper.rb | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/app/helpers/diff_helper.rb b/app/helpers/diff_helper.rb index b889fb28973..30e829cdd4e 100644 --- a/app/helpers/diff_helper.rb +++ b/app/helpers/diff_helper.rb @@ -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 |