Commit 32b1ceb0 authored by Fatih Acet's avatar Fatih Acet

Merge branch '26155-merge-request-tabs-don-t-render-when-no-commits-available' into 'master'

Resolve "Merge request tabs don't render when no commits available"

Closes #26155 and #24556

See merge request !8347
parents 4a1a06f4 6e7e5052
...@@ -221,7 +221,7 @@ class MergeRequest < ActiveRecord::Base ...@@ -221,7 +221,7 @@ class MergeRequest < ActiveRecord::Base
# true base commit, so we can't simply have `#diff_base_commit` fall back on # true base commit, so we can't simply have `#diff_base_commit` fall back on
# this method. # this method.
def likely_diff_base_commit def likely_diff_base_commit
first_commit.parent || first_commit first_commit.try(:parent) || first_commit
end end
def diff_start_commit def diff_start_commit
......
...@@ -50,56 +50,55 @@ ...@@ -50,56 +50,55 @@
.content-block.content-block-small .content-block.content-block-small
= render 'award_emoji/awards_block', awardable: @merge_request, inline: true = render 'award_emoji/awards_block', awardable: @merge_request, inline: true
- if @commits_count.nonzero? .merge-request-tabs-holder{ class: ("js-tabs-affix" unless ENV['RAILS_ENV'] == 'test') }
.merge-request-tabs-holder{ class: ("js-tabs-affix" unless ENV['RAILS_ENV'] == 'test') } %div{ class: container_class }
%div{ class: container_class } %ul.merge-request-tabs.nav-links.no-top.no-bottom
%ul.merge-request-tabs.nav-links.no-top.no-bottom %li.notes-tab
%li.notes-tab = link_to namespace_project_merge_request_path(@project.namespace, @project, @merge_request), data: { target: 'div#notes', action: 'notes', toggle: 'tab' } do
= link_to namespace_project_merge_request_path(@project.namespace, @project, @merge_request), data: { target: 'div#notes', action: 'notes', toggle: 'tab' } do Discussion
Discussion %span.badge= @merge_request.related_notes.user.count
%span.badge= @merge_request.related_notes.user.count - if @merge_request.source_project
- if @merge_request.source_project %li.commits-tab
%li.commits-tab = link_to commits_namespace_project_merge_request_path(@project.namespace, @project, @merge_request), data: { target: 'div#commits', action: 'commits', toggle: 'tab' } do
= link_to commits_namespace_project_merge_request_path(@project.namespace, @project, @merge_request), data: { target: 'div#commits', action: 'commits', toggle: 'tab' } do Commits
Commits %span.badge= @commits_count
%span.badge= @commits_count - if @pipelines.any?
- if @pipelines.any? %li.pipelines-tab
%li.pipelines-tab = link_to pipelines_namespace_project_merge_request_path(@project.namespace, @project, @merge_request), data: { target: '#pipelines', action: 'pipelines', toggle: 'tab' } do
= link_to pipelines_namespace_project_merge_request_path(@project.namespace, @project, @merge_request), data: { target: '#pipelines', action: 'pipelines', toggle: 'tab' } do Pipelines
Pipelines %span.badge= @pipelines.size
%span.badge= @pipelines.size %li.diffs-tab
%li.diffs-tab = link_to diffs_namespace_project_merge_request_path(@project.namespace, @project, @merge_request), data: { target: 'div#diffs', action: 'diffs', toggle: 'tab' } do
= link_to diffs_namespace_project_merge_request_path(@project.namespace, @project, @merge_request), data: { target: 'div#diffs', action: 'diffs', toggle: 'tab' } do Changes
Changes %span.badge= @merge_request.diff_size
%span.badge= @merge_request.diff_size %li#resolve-count-app.line-resolve-all-container.pull-right.prepend-top-10.hidden-xs{ "v-cloak" => true }
%li#resolve-count-app.line-resolve-all-container.pull-right.prepend-top-10.hidden-xs{ "v-cloak" => true } %resolve-count{ "inline-template" => true, ":logged-out" => "#{current_user.nil?}" }
%resolve-count{ "inline-template" => true, ":logged-out" => "#{current_user.nil?}" } %div
%div .line-resolve-all{ "v-show" => "discussionCount > 0",
.line-resolve-all{ "v-show" => "discussionCount > 0", ":class" => "{ 'has-next-btn': !loggedOut && resolvedDiscussionCount !== discussionCount }" }
":class" => "{ 'has-next-btn': !loggedOut && resolvedDiscussionCount !== discussionCount }" } %span.line-resolve-btn.is-disabled{ type: "button",
%span.line-resolve-btn.is-disabled{ type: "button", ":class" => "{ 'is-active': resolvedDiscussionCount === discussionCount }" }
":class" => "{ 'is-active': resolvedDiscussionCount === discussionCount }" } = render "shared/icons/icon_status_success.svg"
= render "shared/icons/icon_status_success.svg" %span.line-resolve-text
%span.line-resolve-text {{ resolvedDiscussionCount }}/{{ discussionCount }} {{ resolvedCountText }} resolved
{{ resolvedDiscussionCount }}/{{ discussionCount }} {{ resolvedCountText }} resolved = render "discussions/jump_to_next"
= render "discussions/jump_to_next"
.tab-content#diff-notes-app .tab-content#diff-notes-app
#notes.notes.tab-pane.voting_notes #notes.notes.tab-pane.voting_notes
.row .row
%section.col-md-12 %section.col-md-12
.issuable-discussion .issuable-discussion
= render "projects/merge_requests/discussion" = render "projects/merge_requests/discussion"
#commits.commits.tab-pane #commits.commits.tab-pane
- # This tab is always loaded via AJAX - # This tab is always loaded via AJAX
#pipelines.pipelines.tab-pane #pipelines.pipelines.tab-pane
- # This tab is always loaded via AJAX - # This tab is always loaded via AJAX
#diffs.diffs.tab-pane #diffs.diffs.tab-pane
- # This tab is always loaded via AJAX - # This tab is always loaded via AJAX
.mr-loading-status .mr-loading-status
= spinner = spinner
= render 'shared/issuable/sidebar', issuable: @merge_request = render 'shared/issuable/sidebar', issuable: @merge_request
- if @merge_request.can_be_reverted?(current_user) - if @merge_request.can_be_reverted?(current_user)
......
%ol#commits-list.list-unstyled - if @commits.empty?
= render "projects/commits/commits", project: @merge_request.source_project, ref: @merge_request.source_branch .commits-empty
%h4
There are no commits yet.
= custom_icon ('illustration_no_commits')
- else
%ol#commits-list.list-unstyled
= render "projects/commits/commits", project: @merge_request.source_project, ref: @merge_request.source_branch
...@@ -23,4 +23,4 @@ ...@@ -23,4 +23,4 @@
to post a comment to post a comment
:javascript :javascript
var notes = new Notes("#{namespace_project_notes_path(namespace_id: @project.namespace, target_id: @noteable.id, target_type: @noteable.class.name.underscore)}", #{@notes.map(&:id).to_json}, #{Time.now.to_i}, "#{diff_view}") var notes = new Notes("#{namespace_project_notes_path(namespace_id: @project.namespace, project_id: @project, target_id: @noteable.id, target_type: @noteable.class.name.underscore)}", #{@notes.map(&:id).to_json}, #{Time.now.to_i}, "#{diff_view}")
---
title: display merge request discussion tab for empty branches
merge_request: 8347
author:
...@@ -4,6 +4,8 @@ require 'spec_helper' ...@@ -4,6 +4,8 @@ require 'spec_helper'
# message to be shown by JavaScript when the source branch was deleted. # message to be shown by JavaScript when the source branch was deleted.
# Please do not remove "js: true". # Please do not remove "js: true".
describe 'Deleted source branch', feature: true, js: true do describe 'Deleted source branch', feature: true, js: true do
include WaitForAjax
let(:user) { create(:user) } let(:user) { create(:user) }
let(:merge_request) { create(:merge_request) } let(:merge_request) { create(:merge_request) }
...@@ -13,7 +15,8 @@ describe 'Deleted source branch', feature: true, js: true do ...@@ -13,7 +15,8 @@ describe 'Deleted source branch', feature: true, js: true do
merge_request.update!(source_branch: 'this-branch-does-not-exist') merge_request.update!(source_branch: 'this-branch-does-not-exist')
visit namespace_project_merge_request_path( visit namespace_project_merge_request_path(
merge_request.project.namespace, merge_request.project.namespace,
merge_request.project, merge_request merge_request.project,
merge_request
) )
end end
...@@ -23,11 +26,17 @@ describe 'Deleted source branch', feature: true, js: true do ...@@ -23,11 +26,17 @@ describe 'Deleted source branch', feature: true, js: true do
) )
end end
it 'hides Discussion, Commits and Changes tabs' do it 'still contains Discussion, Commits and Changes tabs' do
within '.merge-request-details' do within '.merge-request-details' do
expect(page).to have_no_content('Discussion') expect(page).to have_content('Discussion')
expect(page).to have_no_content('Commits') expect(page).to have_content('Commits')
expect(page).to have_no_content('Changes') expect(page).to have_content('Changes')
end end
click_on 'Changes'
wait_for_ajax
expect(page).to have_selector('.diffs.tab-pane .nothing-here-block')
expect(page).to have_content('Nothing to merge from this-branch-does-not-exist into feature')
end end
end end
...@@ -7,6 +7,7 @@ describe 'projects/merge_requests/show.html.haml' do ...@@ -7,6 +7,7 @@ describe 'projects/merge_requests/show.html.haml' do
let(:project) { create(:project) } let(:project) { create(:project) }
let(:fork_project) { create(:project, forked_from_project: project) } let(:fork_project) { create(:project, forked_from_project: project) }
let(:unlink_project) { Projects::UnlinkForkService.new(fork_project, user) } let(:unlink_project) { Projects::UnlinkForkService.new(fork_project, user) }
let(:note) { create(:note_on_merge_request, project: project, noteable: closed_merge_request) }
let(:closed_merge_request) do let(:closed_merge_request) do
create(:closed_merge_request, create(:closed_merge_request,
...@@ -19,8 +20,12 @@ describe 'projects/merge_requests/show.html.haml' do ...@@ -19,8 +20,12 @@ describe 'projects/merge_requests/show.html.haml' do
assign(:project, project) assign(:project, project)
assign(:merge_request, closed_merge_request) assign(:merge_request, closed_merge_request)
assign(:commits_count, 0) assign(:commits_count, 0)
assign(:note, note)
assign(:noteable, closed_merge_request)
assign(:notes, [])
assign(:pipelines, Ci::Pipeline.none)
allow(view).to receive(:can?).and_return(true) allow(view).to receive_messages(current_user: user, can?: true)
end end
context 'when the merge request is closed' do context 'when the merge request is closed' do
......
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