Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2016-05-09 17:53:13 +0300
committerRémy Coutable <remy@rymai.me>2016-05-09 17:53:13 +0300
commit8dd2188b8367ad18bf005c855ef55f001a0b5fd1 (patch)
treea909599a09100b4f830f9560a3949a381a96ba47 /app
parentd4d34b161b41539567332d45527bb10c9f0665e3 (diff)
parentf5240f9703fea9902ac4304b8e12daed5c21820d (diff)
Merge branch '2954-api-expose-issue-user_notes_count' into 'master'
API: Expose Issue#user_notes_count and MergeRequest#user_notes_count _Originally opened at !2954 by @cnam812._ - - - Expose `Issue#user_notes_count` and `MergeRequest#user_notes_count` through the API. See merge request !3126
Diffstat (limited to 'app')
-rw-r--r--app/models/concerns/issuable.rb4
-rw-r--r--app/views/projects/issues/_issue.html.haml14
-rw-r--r--app/views/projects/merge_requests/_merge_request.html.haml14
3 files changed, 12 insertions, 20 deletions
diff --git a/app/models/concerns/issuable.rb b/app/models/concerns/issuable.rb
index 2e4efc4e8d8..7a3db742030 100644
--- a/app/models/concerns/issuable.rb
+++ b/app/models/concerns/issuable.rb
@@ -160,6 +160,10 @@ module Issuable
notes.awards.where(note: "thumbsup").count
end
+ def user_notes_count
+ notes.user.count
+ end
+
def subscribed_without_subscriptions?(user)
participants(user).include?(user)
end
diff --git a/app/views/projects/issues/_issue.html.haml b/app/views/projects/issues/_issue.html.haml
index 9ad86ed71c9..5cf70ea3bb7 100644
--- a/app/views/projects/issues/_issue.html.haml
+++ b/app/views/projects/issues/_issue.html.haml
@@ -28,16 +28,10 @@
= downvotes
- note_count = issue.notes.user.nonawards.count
- - if note_count > 0
- %li
- = link_to issue_path(issue) + "#notes" do
- = icon('comments')
- = note_count
- - else
- %li
- = link_to issue_path(issue) + "#notes", class: "issue-no-comments" do
- = icon('comments')
- = note_count
+ %li
+ = link_to issue_path(issue, anchor: 'notes'), class: ('issue-no-comments' if note_count.zero?) do
+ = icon('comments')
+ = note_count
.issue-info
#{issue.to_reference} &middot;
diff --git a/app/views/projects/merge_requests/_merge_request.html.haml b/app/views/projects/merge_requests/_merge_request.html.haml
index e740fe8c84d..73c6a95f5ca 100644
--- a/app/views/projects/merge_requests/_merge_request.html.haml
+++ b/app/views/projects/merge_requests/_merge_request.html.haml
@@ -36,16 +36,10 @@
= downvotes
- note_count = merge_request.mr_and_commit_notes.user.nonawards.count
- - if note_count > 0
- %li
- = link_to merge_request_path(merge_request) + "#notes" do
- = icon('comments')
- = note_count
- - else
- %li
- = link_to merge_request_path(merge_request) + "#notes", class: "merge-request-no-comments" do
- = icon('comments')
- = note_count
+ %li
+ = link_to merge_request_path(merge_request, anchor: 'notes'), class: ('merge-request-no-comments' if note_count.zero?) do
+ = icon('comments')
+ = note_count
.merge-request-info
#{merge_request.to_reference} &middot;