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
098210aa
Commit
098210aa
authored
Feb 20, 2020
by
Rajendra Kadam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Separate audit, epic, epic issue and linked epic into own class files
parent
4c8ee18c
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
140 additions
and
112 deletions
+140
-112
ee/lib/ee/api/entities.rb
ee/lib/ee/api/entities.rb
+0
-112
ee/lib/ee/api/entities/audit_event.rb
ee/lib/ee/api/entities/audit_event.rb
+18
-0
ee/lib/ee/api/entities/epic.rb
ee/lib/ee/api/entities/epic.rb
+82
-0
ee/lib/ee/api/entities/epic_issue.rb
ee/lib/ee/api/entities/epic_issue.rb
+12
-0
ee/lib/ee/api/entities/linked_epic.rb
ee/lib/ee/api/entities/linked_epic.rb
+28
-0
No files found.
ee/lib/ee/api/entities.rb
View file @
098210aa
...
@@ -264,118 +264,6 @@ module EE
...
@@ -264,118 +264,6 @@ module EE
end
end
end
end
class
LinkedEpic
<
Grape
::
Entity
expose
:id
expose
:iid
expose
:title
expose
:group_id
expose
:parent_id
expose
:has_children?
,
as: :has_children
expose
:has_issues?
,
as: :has_issues
expose
:reference
do
|
epic
|
epic
.
to_reference
(
epic
.
parent
.
group
)
end
expose
:url
do
|
epic
|
::
Gitlab
::
Routing
.
url_helpers
.
group_epic_url
(
epic
.
group
,
epic
)
end
expose
:relation_url
do
|
epic
|
::
Gitlab
::
Routing
.
url_helpers
.
group_epic_link_url
(
epic
.
parent
.
group
,
epic
.
parent
.
iid
,
epic
.
id
)
end
end
class
AuditEvent
<
Grape
::
Entity
expose
:id
expose
:author_id
expose
:entity_id
expose
:entity_type
expose
:details
do
|
audit_event
|
audit_event
.
formatted_details
end
expose
:created_at
end
class
Epic
<
Grape
::
Entity
can_admin_epic
=
->
(
epic
,
opts
)
{
Ability
.
allowed?
(
opts
[
:user
],
:admin_epic
,
epic
)
}
expose
:id
expose
:iid
expose
:group_id
expose
:parent_id
expose
:title
expose
:description
expose
:author
,
using:
::
API
::
Entities
::
UserBasic
expose
:start_date
expose
:start_date_is_fixed?
,
as: :start_date_is_fixed
,
if:
can_admin_epic
expose
:start_date_fixed
,
:start_date_from_inherited_source
,
if:
can_admin_epic
expose
:start_date_from_milestones
,
if:
can_admin_epic
# @deprecated in favor of start_date_from_inherited_source
expose
:end_date
# @deprecated in favor of due_date
expose
:end_date
,
as: :due_date
expose
:due_date_is_fixed?
,
as: :due_date_is_fixed
,
if:
can_admin_epic
expose
:due_date_fixed
,
:due_date_from_inherited_source
,
if:
can_admin_epic
expose
:due_date_from_milestones
,
if:
can_admin_epic
# @deprecated in favor of due_date_from_inherited_source
expose
:state
expose
:web_edit_url
,
if:
can_admin_epic
# @deprecated
expose
:web_url
expose
:references
,
with:
::
API
::
Entities
::
IssuableReferences
do
|
epic
|
epic
end
# reference is deprecated in favour of references
# Introduced [Gitlab 12.6](https://gitlab.com/gitlab-org/gitlab/merge_requests/20354)
expose
:reference
,
if:
{
with_reference:
true
}
do
|
epic
|
epic
.
to_reference
(
full:
true
)
end
expose
:created_at
expose
:updated_at
expose
:closed_at
expose
:labels
do
|
epic
,
options
|
if
options
[
:with_labels_details
]
::
API
::
Entities
::
LabelBasic
.
represent
(
epic
.
labels
.
sort_by
(
&
:title
))
else
epic
.
labels
.
map
(
&
:title
).
sort
end
end
expose
:upvotes
do
|
epic
,
options
|
if
options
[
:issuable_metadata
]
# Avoids an N+1 query when metadata is included
options
[
:issuable_metadata
][
epic
.
id
].
upvotes
else
epic
.
upvotes
end
end
expose
:downvotes
do
|
epic
,
options
|
if
options
[
:issuable_metadata
]
# Avoids an N+1 query when metadata is included
options
[
:issuable_metadata
][
epic
.
id
].
downvotes
else
epic
.
downvotes
end
end
# Calculating the value of subscribed field triggers Markdown
# processing. We can't do that for multiple epics
# requests in a single API request.
expose
:subscribed
,
if:
->
(
_
,
options
)
{
options
.
fetch
(
:include_subscribed
,
false
)
}
do
|
epic
,
options
|
user
=
options
[
:user
]
user
.
present?
?
epic
.
subscribed?
(
user
)
:
false
end
def
web_url
::
Gitlab
::
Routing
.
url_helpers
.
group_epic_url
(
object
.
group
,
object
)
end
def
web_edit_url
::
Gitlab
::
Routing
.
url_helpers
.
group_epic_path
(
object
.
group
,
object
)
end
end
class
EpicIssue
<
::
API
::
Entities
::
Issue
expose
:epic_issue_id
expose
:relative_position
end
class
EpicIssueLink
<
Grape
::
Entity
class
EpicIssueLink
<
Grape
::
Entity
expose
:id
expose
:id
expose
:relative_position
expose
:relative_position
...
...
ee/lib/ee/api/entities/audit_event.rb
0 → 100644
View file @
098210aa
# frozen_string_literal: true
module
EE
module
API
module
Entities
class
AuditEvent
<
Grape
::
Entity
expose
:id
expose
:author_id
expose
:entity_id
expose
:entity_type
expose
:details
do
|
audit_event
|
audit_event
.
formatted_details
end
expose
:created_at
end
end
end
end
ee/lib/ee/api/entities/epic.rb
0 → 100644
View file @
098210aa
# frozen_string_literal: true
module
EE
module
API
module
Entities
class
Epic
<
Grape
::
Entity
can_admin_epic
=
->
(
epic
,
opts
)
{
Ability
.
allowed?
(
opts
[
:user
],
:admin_epic
,
epic
)
}
expose
:id
expose
:iid
expose
:group_id
expose
:parent_id
expose
:title
expose
:description
expose
:author
,
using:
::
API
::
Entities
::
UserBasic
expose
:start_date
expose
:start_date_is_fixed?
,
as: :start_date_is_fixed
,
if:
can_admin_epic
expose
:start_date_fixed
,
:start_date_from_inherited_source
,
if:
can_admin_epic
expose
:start_date_from_milestones
,
if:
can_admin_epic
# @deprecated in favor of start_date_from_inherited_source
expose
:end_date
# @deprecated in favor of due_date
expose
:end_date
,
as: :due_date
expose
:due_date_is_fixed?
,
as: :due_date_is_fixed
,
if:
can_admin_epic
expose
:due_date_fixed
,
:due_date_from_inherited_source
,
if:
can_admin_epic
expose
:due_date_from_milestones
,
if:
can_admin_epic
# @deprecated in favor of due_date_from_inherited_source
expose
:state
expose
:web_edit_url
,
if:
can_admin_epic
# @deprecated
expose
:web_url
expose
:references
,
with:
::
API
::
Entities
::
IssuableReferences
do
|
epic
|
epic
end
# reference is deprecated in favour of references
# Introduced [Gitlab 12.6](https://gitlab.com/gitlab-org/gitlab/merge_requests/20354)
expose
:reference
,
if:
{
with_reference:
true
}
do
|
epic
|
epic
.
to_reference
(
full:
true
)
end
expose
:created_at
expose
:updated_at
expose
:closed_at
expose
:labels
do
|
epic
,
options
|
if
options
[
:with_labels_details
]
::
API
::
Entities
::
LabelBasic
.
represent
(
epic
.
labels
.
sort_by
(
&
:title
))
else
epic
.
labels
.
map
(
&
:title
).
sort
end
end
expose
:upvotes
do
|
epic
,
options
|
if
options
[
:issuable_metadata
]
# Avoids an N+1 query when metadata is included
options
[
:issuable_metadata
][
epic
.
id
].
upvotes
else
epic
.
upvotes
end
end
expose
:downvotes
do
|
epic
,
options
|
if
options
[
:issuable_metadata
]
# Avoids an N+1 query when metadata is included
options
[
:issuable_metadata
][
epic
.
id
].
downvotes
else
epic
.
downvotes
end
end
# Calculating the value of subscribed field triggers Markdown
# processing. We can't do that for multiple epics
# requests in a single API request.
expose
:subscribed
,
if:
->
(
_
,
options
)
{
options
.
fetch
(
:include_subscribed
,
false
)
}
do
|
epic
,
options
|
user
=
options
[
:user
]
user
.
present?
?
epic
.
subscribed?
(
user
)
:
false
end
def
web_url
::
Gitlab
::
Routing
.
url_helpers
.
group_epic_url
(
object
.
group
,
object
)
end
def
web_edit_url
::
Gitlab
::
Routing
.
url_helpers
.
group_epic_path
(
object
.
group
,
object
)
end
end
end
end
end
ee/lib/ee/api/entities/epic_issue.rb
0 → 100644
View file @
098210aa
# frozen_string_literal: true
module
EE
module
API
module
Entities
class
EpicIssue
<
::
API
::
Entities
::
Issue
expose
:epic_issue_id
expose
:relative_position
end
end
end
end
ee/lib/ee/api/entities/linked_epic.rb
0 → 100644
View file @
098210aa
# frozen_string_literal: true
module
EE
module
API
module
Entities
class
LinkedEpic
<
Grape
::
Entity
expose
:id
expose
:iid
expose
:title
expose
:group_id
expose
:parent_id
expose
:has_children?
,
as: :has_children
expose
:has_issues?
,
as: :has_issues
expose
:reference
do
|
epic
|
epic
.
to_reference
(
epic
.
parent
.
group
)
end
expose
:url
do
|
epic
|
::
Gitlab
::
Routing
.
url_helpers
.
group_epic_url
(
epic
.
group
,
epic
)
end
expose
:relation_url
do
|
epic
|
::
Gitlab
::
Routing
.
url_helpers
.
group_epic_link_url
(
epic
.
parent
.
group
,
epic
.
parent
.
iid
,
epic
.
id
)
end
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