Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
9194beb9
Commit
9194beb9
authored
Feb 12, 2020
by
Rajendra Kadam
Committed by
Stan Hu
Feb 12, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add label entities into own class files
parent
653f5936
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
61 additions
and
36 deletions
+61
-36
changelogs/unreleased/refactoring-entities-file-17.yml
changelogs/unreleased/refactoring-entities-file-17.yml
+5
-0
lib/api/entities.rb
lib/api/entities.rb
+0
-36
lib/api/entities/group_label.rb
lib/api/entities/group_label.rb
+8
-0
lib/api/entities/label.rb
lib/api/entities/label.rb
+25
-0
lib/api/entities/label_basic.rb
lib/api/entities/label_basic.rb
+9
-0
lib/api/entities/project_label.rb
lib/api/entities/project_label.rb
+14
-0
No files found.
changelogs/unreleased/refactoring-entities-file-17.yml
0 → 100644
View file @
9194beb9
---
title
:
Separate label entities into own class files
merge_request
:
24938
author
:
Rajendra Kadam
type
:
added
lib/api/entities.rb
View file @
9194beb9
...
...
@@ -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
...
...
lib/api/entities/group_label.rb
0 → 100644
View file @
9194beb9
# frozen_string_literal: true
module
API
module
Entities
class
GroupLabel
<
Entities
::
Label
end
end
end
lib/api/entities/label.rb
0 → 100644
View file @
9194beb9
# 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
lib/api/entities/label_basic.rb
0 → 100644
View file @
9194beb9
# frozen_string_literal: true
module
API
module
Entities
class
LabelBasic
<
Grape
::
Entity
expose
:id
,
:name
,
:color
,
:description
,
:description_html
,
:text_color
end
end
end
lib/api/entities/project_label.rb
0 → 100644
View file @
9194beb9
# 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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment