diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-09-08 23:12:54 +0400 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-09-08 23:12:54 +0400 |
commit | 02e87d9223b8398f6d2f06b2ba57313c2ad384be (patch) | |
tree | 5ed86c61b709f6381774f5ceac563947275543c6 /app | |
parent | 218219abbdfdc3bc0bc1a9c95cfc0e0ddb5861dd (diff) |
optimize show_diff_size_warning?
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app')
-rw-r--r-- | app/helpers/diff_helper.rb | 14 | ||||
-rw-r--r-- | app/views/projects/diffs/_diffs.html.haml | 1 | ||||
-rw-r--r-- | app/views/projects/diffs/_warning.html.haml | 2 |
3 files changed, 11 insertions, 6 deletions
diff --git a/app/helpers/diff_helper.rb b/app/helpers/diff_helper.rb index c2a19e4ac10..6307790d4e7 100644 --- a/app/helpers/diff_helper.rb +++ b/app/helpers/diff_helper.rb @@ -1,16 +1,20 @@ module DiffHelper - def safe_diff_files(diffs) + def allowed_diff_size if diff_hard_limit_enabled? - diffs.first(Commit::DIFF_HARD_LIMIT_FILES) + Commit::DIFF_HARD_LIMIT_FILES else - diffs.first(Commit::DIFF_SAFE_FILES) - end.map do |diff| + Commit::DIFF_SAFE_FILES + end + end + + def safe_diff_files(diffs) + diffs.first(allowed_diff_size).map do |diff| Gitlab::Diff::File.new(diff) end end def show_diff_size_warninig?(diffs) - safe_diff_files(diffs).size < diffs.size + diffs.size > allowed_diff_size end def diff_hard_limit_enabled? diff --git a/app/views/projects/diffs/_diffs.html.haml b/app/views/projects/diffs/_diffs.html.haml index c4eb7815866..49b3dc6941a 100644 --- a/app/views/projects/diffs/_diffs.html.haml +++ b/app/views/projects/diffs/_diffs.html.haml @@ -11,6 +11,7 @@ - params_copy[:view] = 'inline' = link_to "Inline Diff", url_for(params_copy), {id: "commit-diff-viewtype"} + - if show_diff_size_warninig?(diffs) = render 'projects/diffs/warning', diffs: diffs diff --git a/app/views/projects/diffs/_warning.html.haml b/app/views/projects/diffs/_warning.html.haml index ee85956d876..86ed6bbeaa2 100644 --- a/app/views/projects/diffs/_warning.html.haml +++ b/app/views/projects/diffs/_warning.html.haml @@ -14,6 +14,6 @@ = link_to "Email patch", project_merge_request_path(@project, @merge_request, format: :patch), class: "btn btn-warning btn-small" %p To preserve performance only - %strong #{safe_diff_files(@project, diffs).size} of #{diffs.size} + %strong #{allowed_diff_size} of #{diffs.size} files displayed. |