Commit 9194beb9 authored by Rajendra Kadam's avatar Rajendra Kadam Committed by Stan Hu

Add label entities into own class files

parent 653f5936
---
title: Separate label entities into own class files
merge_request: 24938
author: Rajendra Kadam
type: added
......@@ -163,42 +163,6 @@ module API
end
end
class LabelBasic < Grape::Entity
expose :id, :name, :color, :description, :description_html, :text_color
end
class Label < LabelBasic
with_options if: lambda { |_, options| options[:with_counts] } do
expose :open_issues_count do |label, options|
label.open_issues_count(options[:current_user])
end
expose :closed_issues_count do |label, options|
label.closed_issues_count(options[:current_user])
end
expose :open_merge_requests_count do |label, options|
label.open_merge_requests_count(options[:current_user])
end
end
expose :subscribed do |label, options|
label.subscribed?(options[:current_user], options[:parent])
end
end
class GroupLabel < Label
end
class ProjectLabel < Label
expose :priority do |label, options|
label.priority(options[:parent])
end
expose :is_project_label do |label, options|
label.is_a?(::ProjectLabel)
end
end
class List < Grape::Entity
expose :id
expose :label, using: Entities::LabelBasic
......
# frozen_string_literal: true
module API
module Entities
class GroupLabel < Entities::Label
end
end
end
# frozen_string_literal: true
module API
module Entities
class Label < Entities::LabelBasic
with_options if: lambda { |_, options| options[:with_counts] } do
expose :open_issues_count do |label, options|
label.open_issues_count(options[:current_user])
end
expose :closed_issues_count do |label, options|
label.closed_issues_count(options[:current_user])
end
expose :open_merge_requests_count do |label, options|
label.open_merge_requests_count(options[:current_user])
end
end
expose :subscribed do |label, options|
label.subscribed?(options[:current_user], options[:parent])
end
end
end
end
# frozen_string_literal: true
module API
module Entities
class LabelBasic < Grape::Entity
expose :id, :name, :color, :description, :description_html, :text_color
end
end
end
# frozen_string_literal: true
module API
module Entities
class ProjectLabel < Entities::Label
expose :priority do |label, options|
label.priority(options[:parent])
end
expose :is_project_label do |label, options|
label.is_a?(::ProjectLabel)
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment