Commit 2bc82130 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'mr-statuses' into 'master'

Display referenced merge request statuses in the issue description

See gitlab-org/gitlab-ce#3180 for original issue.
Previously discussed in !1941 and in !1771 before that.

* [x] Show a "Related Merge Requests" list on the issue page under the Description as given by the UI mockup
* [x] Display `all_references.merge_requests` and `note.all_references.merge_requests` 
* [x] Consider displaying the merge request status in addition to the CI status to enable complete merge request status understanding.

See merge request !1991
parents 29181c04 0272f274
......@@ -60,6 +60,26 @@ form.edit-issue {
margin: 0;
}
.merge-requests-title {
font-size: 16px;
font-weight: 600;
}
.merge-request-id {
display: inline-block;
width: 3em;
}
.merge-request-info {
padding-left: 5px;
}
.merge-request-status {
color: $gl-gray;
font-size: 15px;
font-weight: bold;
}
.merge-request,
.issue {
&.today {
......
......@@ -62,6 +62,7 @@ class Projects::IssuesController < Projects::ApplicationController
@note = @project.notes.new(noteable: @issue)
@notes = @issue.notes.nonawards.with_associations.fresh
@noteable = @issue
@merge_requests = @issue.referenced_merge_requests
respond_with(@issue)
end
......
......@@ -52,7 +52,7 @@ module CiStatusHelper
'circle'
end
icon(icon_name)
icon(icon_name + ' fw')
end
def render_ci_status(ci_commit)
......
......@@ -83,6 +83,14 @@ class Issue < ActiveRecord::Base
reference
end
def referenced_merge_requests
references = [self, *notes].flat_map do |note|
note.all_references(load_lazy_references: false).merge_requests
end.uniq
Gitlab::Markdown::ReferenceFilter::LazyReference.load(references).uniq.sort_by(&:iid)
end
# Reset issue events cache
#
# Since we do cache @event we need to reset cache in special cases:
......
-if @merge_requests.any?
%h2.merge-requests-title
= pluralize(@merge_requests.count, 'Related Merge Request')
%ul.bordered-list
- has_any_ci = @merge_requests.any?(&:ci_commit)
- @merge_requests.each do |merge_request|
%li
%span.merge-request-ci-status
- if merge_request.ci_commit
= render_ci_status(merge_request.ci_commit)
- elsif has_any_ci
= icon('blank fw')
%span.merge-request-id
\##{merge_request.iid}
%span.merge-request-info
%strong
= link_to_gfm merge_request.title, merge_request_path(merge_request), class: "row_title"
in
- project = merge_request.target_project
= link_to project.name_with_namespace, namespace_project_path(project.namespace, project)
%span.merge-request-status.prepend-left-10
- if merge_request.merged?
MERGED
- elsif merge_request.closed?
CLOSED
......@@ -47,6 +47,10 @@
= markdown(@issue.description, cache_key: [@issue, "description"])
%textarea.hidden.js-task-list-field
= @issue.description
.merge-requests
= render 'merge_requests'
- if @closed_by_merge_requests.present?
= render 'projects/issues/closed_by_box'
.issue-discussion
......
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