summaryrefslogtreecommitdiff
path: root/app/views/projects/diffs/_diffs.html.haml
blob: ac35a0a25c739e72228296c979bffe3cf9b77ddc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
- environment = local_assigns.fetch(:environment, nil)
- show_whitespace_toggle = local_assigns.fetch(:show_whitespace_toggle, true)
- can_create_note = !@diff_notes_disabled && can?(current_user, :create_note, diffs.project)
- diff_page_context = local_assigns.fetch(:diff_page_context, nil)
- load_diff_files_async = Feature.enabled?(:async_commit_diff_files, @project) && diff_page_context == "is-commit"
- paginate_diffs = local_assigns.fetch(:paginate_diffs, false) && !load_diff_files_async
- paginate_diffs_per_page = local_assigns.fetch(:paginate_diffs_per_page, nil)
- diff_files = conditionally_paginate_diff_files(diffs, paginate: paginate_diffs, per: paginate_diffs_per_page)

.content-block.oneline-block.files-changed.diff-files-changed.js-diff-files-changed
  .files-changed-inner
    .inline-parallel-buttons.gl-display-none.gl-md-display-flex
      - if !diffs_expanded? && diff_files.any? { |diff_file| diff_file.collapsed? }
        = link_to _('Expand all'), url_for(safe_params.merge(expanded: 1, format: nil)), class: 'gl-button btn btn-default'
      - if show_whitespace_toggle
        - if current_controller?(:commit)
          = commit_diff_whitespace_link(diffs.project, @commit, class: 'd-none d-sm-inline-block')
        - elsif current_controller?('projects/merge_requests/diffs')
          = diff_merge_request_whitespace_link(diffs.project, @merge_request, class: 'd-none d-sm-inline-block')
        - elsif current_controller?(:compare)
          = diff_compare_whitespace_link(diffs.project, params[:from], params[:to], class: 'd-none d-sm-inline-block')
        - elsif current_controller?(:wikis)
          = toggle_whitespace_link(url_for(params_with_whitespace), class: 'd-none d-sm-inline-block')
      .btn-group.gl-ml-3
        = inline_diff_btn
        = parallel_diff_btn
    = render 'projects/diffs/stats', diff_files: diff_files

- if render_overflow_warning?(diffs)
  = render 'projects/diffs/warning', diff_files: diffs

.files{ data: { can_create_note: can_create_note } }
  - if load_diff_files_async
    - url = url_for(safe_params.merge(action: 'diff_files'))
    .js-diffs-batch{ data: { diff_files_path: url } }
      .text-center
        %span.spinner.spinner-md
  - else
    = render partial: 'projects/diffs/file', collection: diff_files, as: :diff_file, locals: { project: diffs.project, environment: environment, diff_page_context: diff_page_context }

    - if paginate_diffs
      = paginate(diff_files, theme: "gitlab")