summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Eastwood <contact@ericeastwood.com>2017-04-19 23:11:33 -0500
committerEric Eastwood <contact@ericeastwood.com>2017-04-25 22:56:27 -0500
commitdbc24ff9613dbff3b1e789f12e2dd462cfd3170e (patch)
treed54f2d4c32e6141c384404dfecada865740b65d3
parent3c6fad64296738239582ad449bb202cfd99ba7ff (diff)
downloadgitlab-ce-2001-related-issues-initial-stab.tar.gz
Initial stab at related issues2001-related-issues-initial-stab
Fix https://gitlab.com/gitlab-org/gitlab-ee/issues/2001
-rw-r--r--app/assets/javascripts/issue.js13
-rw-r--r--app/controllers/projects/issues_controller.rb14
-rw-r--r--app/views/projects/issues/_related_issues.html.haml15
-rw-r--r--app/views/projects/issues/show.html.haml3
-rw-r--r--config/routes/project.rb1
5 files changed, 45 insertions, 1 deletions
diff --git a/app/assets/javascripts/issue.js b/app/assets/javascripts/issue.js
index 011043e992f..5f1f5209119 100644
--- a/app/assets/javascripts/issue.js
+++ b/app/assets/javascripts/issue.js
@@ -23,6 +23,7 @@ class Issue {
Issue.$btnNewBranch = $('#new-branch');
+ Issue.initRelatedIssues();
Issue.initMergeRequests();
Issue.initRelatedBranches();
Issue.initCanCreateBranch();
@@ -86,6 +87,18 @@ class Issue {
}
}
+ static initRelatedIssues() {
+ var $container;
+ $container = $('#related-issues');
+ return $.getJSON($container.data('url')).fail(function() {
+ return new Flash('Failed to load related issues');
+ }).done(function(data) {
+ if ('html' in data) {
+ return $container.html(data.html);
+ }
+ });
+ }
+
static initMergeRequests() {
var $container;
$container = $('#merge-requests');
diff --git a/app/controllers/projects/issues_controller.rb b/app/controllers/projects/issues_controller.rb
index cbf67137261..83a04ce0781 100644
--- a/app/controllers/projects/issues_controller.rb
+++ b/app/controllers/projects/issues_controller.rb
@@ -10,7 +10,7 @@ class Projects::IssuesController < Projects::ApplicationController
before_action :redirect_to_external_issue_tracker, only: [:index, :new]
before_action :module_enabled
- before_action :issue, only: [:edit, :update, :show, :referenced_merge_requests,
+ before_action :issue, only: [:edit, :update, :show, :related_issues, :referenced_merge_requests,
:related_branches, :can_create_branch, :rendered_title]
# Allow read any issue
@@ -159,6 +159,18 @@ class Projects::IssuesController < Projects::ApplicationController
render_conflict_response
end
+ def related_issues
+ @related_branches = @issue.related_branches(current_user)
+
+ respond_to do |format|
+ format.json do
+ render json: {
+ html: view_to_html_string('projects/issues/_related_issues')
+ }
+ end
+ end
+ end
+
def referenced_merge_requests
@merge_requests = @issue.referenced_merge_requests(current_user)
@closed_by_merge_requests = @issue.closed_by_merge_requests(current_user)
diff --git a/app/views/projects/issues/_related_issues.html.haml b/app/views/projects/issues/_related_issues.html.haml
new file mode 100644
index 00000000000..f46040352f9
--- /dev/null
+++ b/app/views/projects/issues/_related_issues.html.haml
@@ -0,0 +1,15 @@
+- if @related_branches.any?
+ %h2.related-branches-title
+ = pluralize(@related_branches.count, 'Related Issue')
+ %ul.unstyled-list.related-merge-requests
+ - @related_branches.each do |branch|
+ %li
+ - target = @project.repository.find_branch(branch).dereferenced_target
+ - pipeline = @project.pipeline_for(branch, target.sha) if target
+ - if pipeline
+ %span.related-branch-ci-status
+ = render_pipeline_status(pipeline)
+ %span.related-branch-info
+ %strong
+ = link_to namespace_project_compare_path(@project.namespace, @project, from: @project.default_branch, to: branch), class: "label-branch" do
+ = branch
diff --git a/app/views/projects/issues/show.html.haml b/app/views/projects/issues/show.html.haml
index 4d56aa214e2..232ef066fdc 100644
--- a/app/views/projects/issues/show.html.haml
+++ b/app/views/projects/issues/show.html.haml
@@ -64,6 +64,9 @@
= @issue.description
= edited_time_ago_with_tooltip(@issue, placement: 'bottom', html_class: 'issue_edited_ago')
+ #related-issues{ data: { url: related_issues_namespace_project_issue_url(@project.namespace, @project, @issue) } }
+ // This element is filled in using JavaScript.
+
#merge-requests{ data: { url: referenced_merge_requests_namespace_project_issue_url(@project.namespace, @project, @issue) } }
// This element is filled in using JavaScript.
diff --git a/config/routes/project.rb b/config/routes/project.rb
index fa92202c1ea..7e65538082b 100644
--- a/config/routes/project.rb
+++ b/config/routes/project.rb
@@ -225,6 +225,7 @@ constraints(ProjectUrlConstrainer.new) do
member do
post :toggle_subscription
post :mark_as_spam
+ get :related_issues
get :referenced_merge_requests
get :related_branches
get :can_create_branch