diff options
author | Zeger-Jan van de Weg <zegerjan@gitlab.com> | 2016-02-22 11:20:04 +0300 |
---|---|---|
committer | Zeger-Jan van de Weg <zegerjan@gitlab.com> | 2016-03-15 22:21:11 +0300 |
commit | 2b97c921196a7be904bfe4f0a31347c3583c9e88 (patch) | |
tree | e650acbaa92c45882f0a4681e67b5e07d5cf7d46 /app | |
parent | e831a3b869cbb82e9a4294a5f9309ba56df46589 (diff) |
Incorporate review
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/stylesheets/pages/issues.scss | 7 | ||||
-rw-r--r-- | app/controllers/projects/branches_controller.rb | 7 | ||||
-rw-r--r-- | app/models/issue.rb | 19 | ||||
-rw-r--r-- | app/services/system_note_service.rb | 2 | ||||
-rw-r--r-- | app/views/projects/issues/_new_branch.html.haml | 2 | ||||
-rw-r--r-- | app/views/projects/issues/_related_branches.html.haml | 2 |
6 files changed, 19 insertions, 20 deletions
diff --git a/app/assets/stylesheets/pages/issues.scss b/app/assets/stylesheets/pages/issues.scss index 5f1810cbaf6..0f2e14d1a20 100644 --- a/app/assets/stylesheets/pages/issues.scss +++ b/app/assets/stylesheets/pages/issues.scss @@ -49,12 +49,7 @@ form.edit-issue { margin: 0; } -.related-branches-title { - font-size: 16px; - font-weight: 600; -} - -.merge-requests-title { +.merge-requests-title, .related-branches-title { font-size: 16px; font-weight: 600; } diff --git a/app/controllers/projects/branches_controller.rb b/app/controllers/projects/branches_controller.rb index bcbd3aa5d9b..43ea717cbd2 100644 --- a/app/controllers/projects/branches_controller.rb +++ b/app/controllers/projects/branches_controller.rb @@ -27,10 +27,9 @@ class Projects::BranchesController < Projects::ApplicationController result = CreateBranchService.new(project, current_user). execute(branch_name, ref) - if params[:issue_id] - issue = Issue.where(id: params[:issue_id], project: @project).limit(1).first - - SystemNoteService.new_issue_branch(issue, @project, current_user, branch_name) + if params[:issue_iid] + issue = @project.issues.find_by(iid: params[:issue_iid]) + SystemNoteService.new_issue_branch(issue, @project, current_user, branch_name) if issue end if result[:status] == :success diff --git a/app/models/issue.rb b/app/models/issue.rb index 3b6bff6c577..ec275d5f5b5 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -87,11 +87,16 @@ class Issue < ActiveRecord::Base end def referenced_merge_requests(current_user = nil) - Gitlab::ReferenceExtractor.lazily do - [self, *notes].flat_map do |note| - note.all_references(current_user).merge_requests - end - end.sort_by(&:iid) + if defined?(@referenced_merge_requests) + @referenced_merge_requests[current_user] ||= Gitlab::ReferenceExtractor.lazily do + [self, *notes].flat_map do |note| + note.all_references(current_user).merge_requests + end + end.sort_by(&:iid).uniq + else + @referenced_merge_requests = {} + referenced_merge_requests(current_user) + end end def related_branches @@ -132,7 +137,7 @@ class Issue < ActiveRecord::Base def can_be_worked_on?(current_user) !self.closed? && !self.project.forked? && - referenced_merge_requests(current_user).none? { |mr| mr.closes_issue?(self) } && - related_branches.empty? + self.related_branches.empty? && + self.referenced_merge_requests(current_user).empty? end end diff --git a/app/services/system_note_service.rb b/app/services/system_note_service.rb index b65ac47bce3..5ea7d405e4d 100644 --- a/app/services/system_note_service.rb +++ b/app/services/system_note_service.rb @@ -213,7 +213,7 @@ class SystemNoteService # "Started branch `201-issue-branch-button`" def self.new_issue_branch(issue, project, author, branch) h = Gitlab::Application.routes.url_helpers - link = "#{Gitlab.config.gitlab.url}#{h.namespace_project_compare_path(project.namespace, project, from: project.default_branch, to: branch)}" + link = "#{h.namespace_project_compare_url(project.namespace, project, from: project.default_branch, to: branch)}" body = "Started branch [#{branch}](#{link})" create_note(noteable: issue, project: project, author: author, note: body) diff --git a/app/views/projects/issues/_new_branch.html.haml b/app/views/projects/issues/_new_branch.html.haml index a6b97b90e64..e66e4669d48 100644 --- a/app/views/projects/issues/_new_branch.html.haml +++ b/app/views/projects/issues/_new_branch.html.haml @@ -1,5 +1,5 @@ - if current_user && can?(current_user, :push_code, @project) && @issue.can_be_worked_on?(current_user) .pull-right - = link_to namespace_project_branches_path(@project.namespace, @project, branch_name: @issue.to_branch_name, issue_id: @issue.id), method: :post, class: 'btn', title: @issue.to_branch_name do + = link_to namespace_project_branches_path(@project.namespace, @project, branch_name: @issue.to_branch_name, issue_iid: @issue.iid), method: :post, class: 'btn', title: @issue.to_branch_name do = icon('code-fork') New Branch diff --git a/app/views/projects/issues/_related_branches.html.haml b/app/views/projects/issues/_related_branches.html.haml index 56387661989..b10cd03515f 100644 --- a/app/views/projects/issues/_related_branches.html.haml +++ b/app/views/projects/issues/_related_branches.html.haml @@ -11,5 +11,5 @@ = render_ci_status(ci_commit) %span.related-branch-info %strong - = link_to namespace_project_compare_path(@project.namespace, @project, from: @project.default_branch, to: branch) do + = link_to namespace_project_compare_path(@project.namespace, @project, from: @project.default_branch, to: branch), class: "label-branch" do = branch |