summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-09-14 23:14:11 -0300
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-09-16 10:56:48 -0300
commit2fea2405e69eff970cd3b8c6b0a9a55079dd0b64 (patch)
tree994ceba1148d00116a8caec1ec7489d6c86536c2
parent09c3395583f455928c21db8a6f5356d8daac98f3 (diff)
downloadgitlab-ce-2fea2405e69eff970cd3b8c6b0a9a55079dd0b64.tar.gz
List group labels on project labels page
-rw-r--r--app/controllers/projects/labels_controller.rb3
-rw-r--r--app/models/label.rb22
-rw-r--r--app/views/groups/labels/_label.html.haml2
-rw-r--r--app/views/groups/labels/index.html.haml5
-rw-r--r--app/views/projects/labels/index.html.haml8
5 files changed, 29 insertions, 11 deletions
diff --git a/app/controllers/projects/labels_controller.rb b/app/controllers/projects/labels_controller.rb
index 0d8c13abc41..126afb865a8 100644
--- a/app/controllers/projects/labels_controller.rb
+++ b/app/controllers/projects/labels_controller.rb
@@ -11,7 +11,8 @@ class Projects::LabelsController < Projects::ApplicationController
respond_to :js, :html
def index
- @labels = @project.labels.unprioritized.page(params[:page])
+ @group_labels = @project.labels.unprioritized.with_type(:group_label).page(params[:page])
+ @labels = @project.labels.unprioritized.with_type(:project_label).page(params[:page])
@prioritized_labels = @project.labels.prioritized
respond_to do |format|
diff --git a/app/models/label.rb b/app/models/label.rb
index a78fe16f762..87d94247acc 100644
--- a/app/models/label.rb
+++ b/app/models/label.rb
@@ -103,15 +103,20 @@ class Label < ActiveRecord::Base
end
def open_issues_count(user = nil)
- issues.visible_to_user(user).opened.count
+ issues_count(user, 'opened')
end
def closed_issues_count(user = nil)
- issues.visible_to_user(user).closed.count
+ issues_count(user, 'closed')
end
- def open_merge_requests_count
- merge_requests.opened.count
+ def open_merge_requests_count(user = nil)
+ params = { label_name: title, scope: 'all', state: 'opened' }
+
+ params[:group_id] = subject_id if subject.is_a?(Group)
+ params[:project_id] = subject_id if subject.is_a?(Project)
+
+ MergeRequestsFinder.new(user, params).execute.count
end
def template?
@@ -128,6 +133,15 @@ class Label < ActiveRecord::Base
private
+ def issues_count(user, state)
+ params = { label_name: title, scope: 'all', state: state }
+
+ params[:group_id] = subject_id if subject.is_a?(Group)
+ params[:project_id] = subject_id if subject.is_a?(Project)
+
+ IssuesFinder.new(user, params).execute.count
+ end
+
def cross_project_reference?(from_project)
if self.is_a?(Project)
self != from_project
diff --git a/app/views/groups/labels/_label.html.haml b/app/views/groups/labels/_label.html.haml
index 39d102a6acb..2395e2dade6 100644
--- a/app/views/groups/labels/_label.html.haml
+++ b/app/views/groups/labels/_label.html.haml
@@ -10,7 +10,7 @@
%ul
%li
= link_to_label(label, type: :merge_request) do
- = pluralize label.open_merge_requests_count, 'merge request'
+ = pluralize label.open_merge_requests_count(current_user), 'merge request'
%li
= link_to_label(label) do
= pluralize label.open_issues_count(current_user), 'open issue'
diff --git a/app/views/groups/labels/index.html.haml b/app/views/groups/labels/index.html.haml
index 848bf2da9b1..d8a6654673f 100644
--- a/app/views/groups/labels/index.html.haml
+++ b/app/views/groups/labels/index.html.haml
@@ -2,7 +2,7 @@
.top-area.adjust
.nav-text
- Labels can be applied to issues and merge requests. Star a label to make it a priority label. Order the prioritized labels to change their relative priority, by dragging.
+ Labels can be applied to issues and merge requests.
.nav-controls
- if can?(current_user, :admin_label, @group)
@@ -10,10 +10,7 @@
New label
.labels
- - hide = @group.labels.empty? || (params[:page].present? && params[:page] != '1')
.other-labels
- - if can?(current_user, :admin_label, @group)
- %h5{ class: ('hide' if hide) } Other Labels
- if @labels.present?
%ul.content-list.manage-labels-list.js-other-labels
= render @labels
diff --git a/app/views/projects/labels/index.html.haml b/app/views/projects/labels/index.html.haml
index db66a0edbd8..210964686e8 100644
--- a/app/views/projects/labels/index.html.haml
+++ b/app/views/projects/labels/index.html.haml
@@ -24,8 +24,14 @@
- if @prioritized_labels.present?
= render @prioritized_labels
.other-labels
+ %h5{ class: ('hide' if hide) } Group Labels
+ - if @group_labels.present?
+ %ul.content-list.manage-labels-list.js-other-labels
+ = render @group_labels
+ - else
+ %p.empty-message No group labels yet
- if can?(current_user, :admin_label, @project)
- %h5{ class: ('hide' if hide) } Other Labels
+ %h5{ class: ('hide' if hide) } Project Labels
- if @labels.present?
%ul.content-list.manage-labels-list.js-other-labels
= render @labels