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
34c41863
Commit
34c41863
authored
Feb 12, 2020
by
Rajendra Kadam
Committed by
Stan Hu
Feb 12, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Separate entities into own class and module files
parent
5e532c2c
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
161 additions
and
124 deletions
+161
-124
changelogs/unreleased/refactoring-entities-file-19.yml
changelogs/unreleased/refactoring-entities-file-19.yml
+5
-0
lib/api/entities.rb
lib/api/entities.rb
+0
-124
lib/api/entities/appearance.rb
lib/api/entities/appearance.rb
+29
-0
lib/api/entities/application_setting.rb
lib/api/entities/application_setting.rb
+36
-0
lib/api/entities/application_statistics.rb
lib/api/entities/application_statistics.rb
+54
-0
lib/api/entities/releases/link.rb
lib/api/entities/releases/link.rb
+14
-0
lib/api/entities/releases/source.rb
lib/api/entities/releases/source.rb
+12
-0
lib/api/entities/tag_release.rb
lib/api/entities/tag_release.rb
+11
-0
No files found.
changelogs/unreleased/refactoring-entities-file-19.yml
0 → 100644
View file @
34c41863
---
title
:
Separate entities into own class files
merge_request
:
24941
author
:
Rajendra Kadam
type
:
added
lib/api/entities.rb
View file @
34c41863
...
@@ -314,130 +314,6 @@ module API
...
@@ -314,130 +314,6 @@ module API
expose
:message
,
:starts_at
,
:ends_at
,
:color
,
:font
,
:target_path
,
:broadcast_type
expose
:message
,
:starts_at
,
:ends_at
,
:color
,
:font
,
:target_path
,
:broadcast_type
end
end
class
ApplicationStatistics
<
Grape
::
Entity
include
ActionView
::
Helpers
::
NumberHelper
include
CountHelper
expose
:forks
do
|
counts
|
approximate_fork_count_with_delimiters
(
counts
)
end
expose
:issues
do
|
counts
|
approximate_count_with_delimiters
(
counts
,
::
Issue
)
end
expose
:merge_requests
do
|
counts
|
approximate_count_with_delimiters
(
counts
,
::
MergeRequest
)
end
expose
:notes
do
|
counts
|
approximate_count_with_delimiters
(
counts
,
::
Note
)
end
expose
:snippets
do
|
counts
|
approximate_count_with_delimiters
(
counts
,
::
Snippet
)
end
expose
:ssh_keys
do
|
counts
|
approximate_count_with_delimiters
(
counts
,
::
Key
)
end
expose
:milestones
do
|
counts
|
approximate_count_with_delimiters
(
counts
,
::
Milestone
)
end
expose
:users
do
|
counts
|
approximate_count_with_delimiters
(
counts
,
::
User
)
end
expose
:projects
do
|
counts
|
approximate_count_with_delimiters
(
counts
,
::
Project
)
end
expose
:groups
do
|
counts
|
approximate_count_with_delimiters
(
counts
,
::
Group
)
end
expose
:active_users
do
|
_
|
number_with_delimiter
(
::
User
.
active
.
count
)
end
end
class
ApplicationSetting
<
Grape
::
Entity
def
self
.
exposed_attributes
attributes
=
::
ApplicationSettingsHelper
.
visible_attributes
attributes
.
delete
(
:performance_bar_allowed_group_path
)
attributes
.
delete
(
:performance_bar_enabled
)
attributes
.
delete
(
:allow_local_requests_from_hooks_and_services
)
# let's not expose the secret key in a response
attributes
.
delete
(
:asset_proxy_secret_key
)
attributes
.
delete
(
:eks_secret_access_key
)
attributes
end
expose
:id
,
:performance_bar_allowed_group_id
expose
(
*
exposed_attributes
)
expose
(
:restricted_visibility_levels
)
do
|
setting
,
_options
|
setting
.
restricted_visibility_levels
.
map
{
|
level
|
Gitlab
::
VisibilityLevel
.
string_level
(
level
)
}
end
expose
(
:default_project_visibility
)
{
|
setting
,
_options
|
Gitlab
::
VisibilityLevel
.
string_level
(
setting
.
default_project_visibility
)
}
expose
(
:default_snippet_visibility
)
{
|
setting
,
_options
|
Gitlab
::
VisibilityLevel
.
string_level
(
setting
.
default_snippet_visibility
)
}
expose
(
:default_group_visibility
)
{
|
setting
,
_options
|
Gitlab
::
VisibilityLevel
.
string_level
(
setting
.
default_group_visibility
)
}
expose
(
*::
ApplicationSettingsHelper
.
external_authorization_service_attributes
)
# support legacy names, can be removed in v5
expose
:password_authentication_enabled_for_web
,
as: :password_authentication_enabled
expose
:password_authentication_enabled_for_web
,
as: :signin_enabled
expose
:allow_local_requests_from_web_hooks_and_services
,
as: :allow_local_requests_from_hooks_and_services
end
class
Appearance
<
Grape
::
Entity
expose
:title
expose
:description
expose
:logo
do
|
appearance
,
options
|
appearance
.
logo
.
url
end
expose
:header_logo
do
|
appearance
,
options
|
appearance
.
header_logo
.
url
end
expose
:favicon
do
|
appearance
,
options
|
appearance
.
favicon
.
url
end
expose
:new_project_guidelines
expose
:header_message
expose
:footer_message
expose
:message_background_color
expose
:message_font_color
expose
:email_header_and_footer_enabled
end
# deprecated old Release representation
class
TagRelease
<
Grape
::
Entity
expose
:tag
,
as: :tag_name
expose
:description
end
module
Releases
class
Link
<
Grape
::
Entity
expose
:id
expose
:name
expose
:url
expose
:external?
,
as: :external
end
class
Source
<
Grape
::
Entity
expose
:format
expose
:url
end
end
class
Release
<
Grape
::
Entity
class
Release
<
Grape
::
Entity
include
::
API
::
Helpers
::
Presentable
include
::
API
::
Helpers
::
Presentable
...
...
lib/api/entities/appearance.rb
0 → 100644
View file @
34c41863
# frozen_string_literal: true
module
API
module
Entities
class
Appearance
<
Grape
::
Entity
expose
:title
expose
:description
expose
:logo
do
|
appearance
,
options
|
appearance
.
logo
.
url
end
expose
:header_logo
do
|
appearance
,
options
|
appearance
.
header_logo
.
url
end
expose
:favicon
do
|
appearance
,
options
|
appearance
.
favicon
.
url
end
expose
:new_project_guidelines
expose
:header_message
expose
:footer_message
expose
:message_background_color
expose
:message_font_color
expose
:email_header_and_footer_enabled
end
end
end
lib/api/entities/application_setting.rb
0 → 100644
View file @
34c41863
# frozen_string_literal: true
module
API
module
Entities
class
ApplicationSetting
<
Grape
::
Entity
def
self
.
exposed_attributes
attributes
=
::
ApplicationSettingsHelper
.
visible_attributes
attributes
.
delete
(
:performance_bar_allowed_group_path
)
attributes
.
delete
(
:performance_bar_enabled
)
attributes
.
delete
(
:allow_local_requests_from_hooks_and_services
)
# let's not expose the secret key in a response
attributes
.
delete
(
:asset_proxy_secret_key
)
attributes
.
delete
(
:eks_secret_access_key
)
attributes
end
expose
:id
,
:performance_bar_allowed_group_id
expose
(
*
exposed_attributes
)
expose
(
:restricted_visibility_levels
)
do
|
setting
,
_options
|
setting
.
restricted_visibility_levels
.
map
{
|
level
|
Gitlab
::
VisibilityLevel
.
string_level
(
level
)
}
end
expose
(
:default_project_visibility
)
{
|
setting
,
_options
|
Gitlab
::
VisibilityLevel
.
string_level
(
setting
.
default_project_visibility
)
}
expose
(
:default_snippet_visibility
)
{
|
setting
,
_options
|
Gitlab
::
VisibilityLevel
.
string_level
(
setting
.
default_snippet_visibility
)
}
expose
(
:default_group_visibility
)
{
|
setting
,
_options
|
Gitlab
::
VisibilityLevel
.
string_level
(
setting
.
default_group_visibility
)
}
expose
(
*::
ApplicationSettingsHelper
.
external_authorization_service_attributes
)
# support legacy names, can be removed in v5
expose
:password_authentication_enabled_for_web
,
as: :password_authentication_enabled
expose
:password_authentication_enabled_for_web
,
as: :signin_enabled
expose
:allow_local_requests_from_web_hooks_and_services
,
as: :allow_local_requests_from_hooks_and_services
end
end
end
lib/api/entities/application_statistics.rb
0 → 100644
View file @
34c41863
# frozen_string_literal: true
module
API
module
Entities
class
ApplicationStatistics
<
Grape
::
Entity
include
ActionView
::
Helpers
::
NumberHelper
include
CountHelper
expose
:forks
do
|
counts
|
approximate_fork_count_with_delimiters
(
counts
)
end
expose
:issues
do
|
counts
|
approximate_count_with_delimiters
(
counts
,
::
Issue
)
end
expose
:merge_requests
do
|
counts
|
approximate_count_with_delimiters
(
counts
,
::
MergeRequest
)
end
expose
:notes
do
|
counts
|
approximate_count_with_delimiters
(
counts
,
::
Note
)
end
expose
:snippets
do
|
counts
|
approximate_count_with_delimiters
(
counts
,
::
Snippet
)
end
expose
:ssh_keys
do
|
counts
|
approximate_count_with_delimiters
(
counts
,
::
Key
)
end
expose
:milestones
do
|
counts
|
approximate_count_with_delimiters
(
counts
,
::
Milestone
)
end
expose
:users
do
|
counts
|
approximate_count_with_delimiters
(
counts
,
::
User
)
end
expose
:projects
do
|
counts
|
approximate_count_with_delimiters
(
counts
,
::
Project
)
end
expose
:groups
do
|
counts
|
approximate_count_with_delimiters
(
counts
,
::
Group
)
end
expose
:active_users
do
|
_
|
number_with_delimiter
(
::
User
.
active
.
count
)
end
end
end
end
lib/api/entities/releases/link.rb
0 → 100644
View file @
34c41863
# frozen_string_literal: true
module
API
module
Entities
module
Releases
class
Link
<
Grape
::
Entity
expose
:id
expose
:name
expose
:url
expose
:external?
,
as: :external
end
end
end
end
lib/api/entities/releases/source.rb
0 → 100644
View file @
34c41863
# frozen_string_literal: true
module
API
module
Entities
module
Releases
class
Source
<
Grape
::
Entity
expose
:format
expose
:url
end
end
end
end
lib/api/entities/tag_release.rb
0 → 100644
View file @
34c41863
# frozen_string_literal: true
module
API
module
Entities
# deprecated old Release representation
class
TagRelease
<
Grape
::
Entity
expose
:tag
,
as: :tag_name
expose
:description
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