display referenced merge requests in issue description with CI status
This commit is contained in:
parent
a2a68858c8
commit
0272f27401
6 changed files with 59 additions and 1 deletions
|
@ -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:
|
||||
|
|
25
app/views/projects/issues/_merge_requests.html.haml
Normal file
25
app/views/projects/issues/_merge_requests.html.haml
Normal file
|
@ -0,0 +1,25 @@
|
|||
-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
|
||||
|
|
Loading…
Reference in a new issue