_versions.html.haml 4.49 KB
- if @merge_request_diffs.size > 1
  .mr-version-controls
    .mr-version-menus-container.content-block
      Changes between
      %span.dropdown.inline.mr-version-dropdown
        %a.dropdown-toggle.btn.btn-default{ data: {toggle: :dropdown} }
          %span
            - if @merge_request_diff.latest?
              latest version
            - else
              version #{version_index(@merge_request_diff)}
          = icon('caret-down')
        .dropdown-menu.dropdown-select.dropdown-menu-selectable
          .dropdown-title
            %span Version:
            %button.dropdown-title-button.dropdown-menu-close{ aria: { label: "Close" } }
              = icon('times', class: 'dropdown-menu-close-icon')
          .dropdown-content
            %ul
              - @merge_request_diffs.each do |merge_request_diff|
                %li
                  = link_to merge_request_version_path(@project, @merge_request, merge_request_diff, @start_sha), class: ('is-active' if merge_request_diff == @merge_request_diff) do
                    %div
                      %strong
                        - if merge_request_diff.latest?
                          latest version
                        - else
                          version #{version_index(merge_request_diff)}
                    %div
                      %small.commit-sha= short_sha(merge_request_diff.head_commit_sha)
                    %div
                      %small
                        #{number_with_delimiter(merge_request_diff.commits_count)} #{'commit'.pluralize(merge_request_diff.commits_count)},
                        = time_ago_with_tooltip(merge_request_diff.created_at)

      - if @merge_request_diff.base_commit_sha
        and
        %span.dropdown.inline.mr-version-compare-dropdown
          %a.btn.btn-default.dropdown-toggle{ data: {toggle: :dropdown} }
            - if @start_version
              version #{version_index(@start_version)}
            - else
              %span.ref-name= @merge_request.target_branch
            = icon('caret-down')
          .dropdown-menu.dropdown-select.dropdown-menu-selectable
            .dropdown-title
              %span Compared with:
              %button.dropdown-title-button.dropdown-menu-close{ aria: { label: "Close" } }
                = icon('times', class: 'dropdown-menu-close-icon')
            .dropdown-content
              %ul
                - @comparable_diffs.each do |merge_request_diff|
                  %li
                    = link_to merge_request_version_path(@project, @merge_request, @merge_request_diff, merge_request_diff.head_commit_sha), class: ('is-active' if merge_request_diff == @start_version) do
                      %div
                        %strong
                          - if merge_request_diff.latest?
                            latest version
                          - else
                            version #{version_index(merge_request_diff)}
                      %div
                        %small.commit-sha= short_sha(merge_request_diff.head_commit_sha)
                      %div
                        %small
                          = time_ago_with_tooltip(merge_request_diff.created_at)
                %li
                  = link_to merge_request_version_path(@project, @merge_request, @merge_request_diff), class: ('is-active' unless @start_version) do
                    %div
                      %strong
                        %span.ref-name= @merge_request.target_branch
                        (base)
                    %div
                      %strong.commit-sha= short_sha(@merge_request_diff.base_commit_sha)

    - if different_base?(@start_version, @merge_request_diff)
      .content-block
        = icon('info-circle')
        Selected versions have different base commits.
        Changes will include
        = link_to namespace_project_compare_path(@project.namespace, @project, from: @start_version.base_commit_sha, to: @merge_request_diff.base_commit_sha) do
          new commits
        from
        = succeed '.' do
          %code= @merge_request.target_branch

    - if @start_version || !@merge_request_diff.latest?
      .comments-disabled-notif.content-block
        = icon('info-circle')
        Not all comments are displayed because you're
        - if @start_version
          comparing two versions
        - else
          viewing an old version
        of the diff.

        .pull-right
          = link_to 'Show latest version', diffs_namespace_project_merge_request_path(@project.namespace, @project, @merge_request), class: 'btn btn-sm'