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
3033fe53
Commit
3033fe53
authored
Mar 20, 2020
by
Rajendra Kadam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Separate module only entities into own class files
parent
f76119fa
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
195 additions
and
139 deletions
+195
-139
ee/lib/ee/api/entities.rb
ee/lib/ee/api/entities.rb
+0
-139
ee/lib/ee/api/entities/application_setting.rb
ee/lib/ee/api/entities/application_setting.rb
+26
-0
ee/lib/ee/api/entities/board.rb
ee/lib/ee/api/entities/board.rb
+30
-0
ee/lib/ee/api/entities/issue.rb
ee/lib/ee/api/entities/issue.rb
+21
-0
ee/lib/ee/api/entities/list.rb
ee/lib/ee/api/entities/list.rb
+18
-0
ee/lib/ee/api/entities/merge_request_basic.rb
ee/lib/ee/api/entities/merge_request_basic.rb
+15
-0
ee/lib/ee/api/entities/namespace.rb
ee/lib/ee/api/entities/namespace.rb
+30
-0
ee/lib/ee/api/entities/todo.rb
ee/lib/ee/api/entities/todo.rb
+34
-0
ee/lib/ee/api/entities/user_details_with_admin.rb
ee/lib/ee/api/entities/user_details_with_admin.rb
+21
-0
No files found.
ee/lib/ee/api/entities.rb
View file @
3033fe53
...
@@ -123,131 +123,6 @@ module EE
...
@@ -123,131 +123,6 @@ module EE
end
end
end
end
module
Issue
extend
ActiveSupport
::
Concern
prepended
do
with_options
if:
->
(
issue
,
options
)
{
::
Ability
.
allowed?
(
options
[
:current_user
],
:read_epic
,
issue
.
project
&
.
group
)
}
do
expose
:epic_iid
do
|
issue
|
issue
.
epic
&
.
iid
end
expose
:epic
,
using:
EpicBaseEntity
end
end
end
module
MergeRequestBasic
extend
ActiveSupport
::
Concern
prepended
do
expose
:approvals_before_merge
end
end
module
Namespace
extend
ActiveSupport
::
Concern
prepended
do
can_admin_namespace
=
->
(
namespace
,
opts
)
{
::
Ability
.
allowed?
(
opts
[
:current_user
],
:admin_namespace
,
namespace
)
}
expose
:shared_runners_minutes_limit
,
if:
->
(
_
,
options
)
{
options
[
:current_user
]
&
.
admin?
}
expose
:extra_shared_runners_minutes_limit
,
if:
->
(
_
,
options
)
{
options
[
:current_user
]
&
.
admin?
}
expose
:billable_members_count
do
|
namespace
,
options
|
namespace
.
billable_members_count
(
options
[
:requested_hosted_plan
])
end
expose
:plan
,
if:
can_admin_namespace
do
|
namespace
,
_
|
namespace
.
actual_plan_name
end
expose
:trial_ends_on
,
if:
can_admin_namespace
do
|
namespace
,
_
|
namespace
.
trial_ends_on
end
expose
:trial
,
if:
can_admin_namespace
do
|
namespace
,
_
|
namespace
.
trial?
end
end
end
module
Board
extend
ActiveSupport
::
Concern
prepended
do
# Default filtering configuration
expose
:name
expose
:group
,
using:
::
API
::
Entities
::
BasicGroupDetails
with_options
if:
->
(
board
,
_
)
{
board
.
resource_parent
.
feature_available?
(
:scoped_issue_board
)
}
do
expose
:milestone
do
|
board
|
if
board
.
milestone
.
is_a?
(
Milestone
)
::
API
::
Entities
::
Milestone
.
represent
(
board
.
milestone
)
else
SpecialBoardFilter
.
represent
(
board
.
milestone
)
end
end
expose
:assignee
,
using:
::
API
::
Entities
::
UserBasic
expose
:labels
,
using:
::
API
::
Entities
::
LabelBasic
expose
:weight
end
end
end
module
List
extend
ActiveSupport
::
Concern
prepended
do
expose
:milestone
,
using:
::
API
::
Entities
::
Milestone
,
if:
->
(
entity
,
_
)
{
entity
.
milestone?
}
expose
:user
,
as: :assignee
,
using:
::
API
::
Entities
::
UserSafe
,
if:
->
(
entity
,
_
)
{
entity
.
assignee?
}
expose
:max_issue_count
,
if:
->
(
list
,
_
)
{
list
.
wip_limits_available?
}
expose
:max_issue_weight
,
if:
->
(
list
,
_
)
{
list
.
wip_limits_available?
}
end
end
module
ApplicationSetting
extend
ActiveSupport
::
Concern
prepended
do
expose
(
*
EE
::
ApplicationSettingsHelper
.
repository_mirror_attributes
,
if:
->
(
_instance
,
_options
)
do
::
License
.
feature_available?
(
:repository_mirrors
)
end
)
expose
(
*
EE
::
ApplicationSettingsHelper
.
merge_request_appovers_rules_attributes
,
if:
->
(
_instance
,
_options
)
do
::
License
.
feature_available?
(
:admin_merge_request_approvers_rules
)
end
)
expose
:email_additional_text
,
if:
->
(
_instance
,
_opts
)
{
::
License
.
feature_available?
(
:email_additional_text
)
}
expose
:file_template_project_id
,
if:
->
(
_instance
,
_opts
)
{
::
License
.
feature_available?
(
:custom_file_templates
)
}
expose
:default_project_deletion_protection
,
if:
->
(
_instance
,
_opts
)
{
::
License
.
feature_available?
(
:default_project_deletion_protection
)
}
expose
:deletion_adjourned_period
,
if:
->
(
_instance
,
_opts
)
{
::
License
.
feature_available?
(
:adjourned_deletion_for_projects_and_groups
)
}
expose
:updating_name_disabled_for_users
,
if:
->
(
_instance
,
_opts
)
{
::
License
.
feature_available?
(
:disable_name_update_for_users
)
}
expose
:npm_package_requests_forwarding
,
if:
->
(
_instance
,
_opts
)
{
::
License
.
feature_available?
(
:packages
)
}
end
end
module
Todo
extend
::
Gitlab
::
Utils
::
Override
extend
ActiveSupport
::
Concern
override
:todo_target_class
def
todo_target_class
(
target_type
)
super
rescue
NameError
# false as second argument prevents looking up in module hierarchy
# see also https://gitlab.com/gitlab-org/gitlab-foss/issues/59719
::
EE
::
API
::
Entities
.
const_get
(
target_type
,
false
)
end
override
:todo_target_url
def
todo_target_url
(
todo
)
return
super
unless
todo
.
target_type
==
::
DesignManagement
::
Design
.
name
design
=
todo
.
target
path_options
=
{
anchor:
todo_target_anchor
(
todo
),
vueroute:
design
.
filename
}
::
Gitlab
::
Routing
.
url_helpers
.
designs_project_issue_url
(
design
.
project
,
design
.
issue
,
path_options
)
end
end
########################
########################
# EE-specific entities #
# EE-specific entities #
########################
########################
...
@@ -374,20 +249,6 @@ module EE
...
@@ -374,20 +249,6 @@ module EE
end
end
end
end
end
end
module
UserDetailsWithAdmin
extend
ActiveSupport
::
Concern
prepended
do
expose
:plan
do
|
user
|
user
.
namespace
.
try
(
:gitlab_subscription
)
&
.
plan_name
end
expose
:trial
do
|
user
|
user
.
namespace
.
try
(
:trial?
)
end
end
end
end
end
end
end
end
end
ee/lib/ee/api/entities/application_setting.rb
0 → 100644
View file @
3033fe53
# frozen_string_literal: true
module
EE
module
API
module
Entities
module
ApplicationSetting
extend
ActiveSupport
::
Concern
prepended
do
expose
(
*
EE
::
ApplicationSettingsHelper
.
repository_mirror_attributes
,
if:
->
(
_instance
,
_options
)
do
::
License
.
feature_available?
(
:repository_mirrors
)
end
)
expose
(
*
EE
::
ApplicationSettingsHelper
.
merge_request_appovers_rules_attributes
,
if:
->
(
_instance
,
_options
)
do
::
License
.
feature_available?
(
:admin_merge_request_approvers_rules
)
end
)
expose
:email_additional_text
,
if:
->
(
_instance
,
_opts
)
{
::
License
.
feature_available?
(
:email_additional_text
)
}
expose
:file_template_project_id
,
if:
->
(
_instance
,
_opts
)
{
::
License
.
feature_available?
(
:custom_file_templates
)
}
expose
:default_project_deletion_protection
,
if:
->
(
_instance
,
_opts
)
{
::
License
.
feature_available?
(
:default_project_deletion_protection
)
}
expose
:deletion_adjourned_period
,
if:
->
(
_instance
,
_opts
)
{
::
License
.
feature_available?
(
:adjourned_deletion_for_projects_and_groups
)
}
expose
:updating_name_disabled_for_users
,
if:
->
(
_instance
,
_opts
)
{
::
License
.
feature_available?
(
:disable_name_update_for_users
)
}
expose
:npm_package_requests_forwarding
,
if:
->
(
_instance
,
_opts
)
{
::
License
.
feature_available?
(
:packages
)
}
end
end
end
end
end
ee/lib/ee/api/entities/board.rb
0 → 100644
View file @
3033fe53
# frozen_string_literal: true
module
EE
module
API
module
Entities
module
Board
extend
ActiveSupport
::
Concern
prepended
do
# Default filtering configuration
expose
:name
expose
:group
,
using:
::
API
::
Entities
::
BasicGroupDetails
with_options
if:
->
(
board
,
_
)
{
board
.
resource_parent
.
feature_available?
(
:scoped_issue_board
)
}
do
expose
:milestone
do
|
board
|
if
board
.
milestone
.
is_a?
(
Milestone
)
::
API
::
Entities
::
Milestone
.
represent
(
board
.
milestone
)
else
SpecialBoardFilter
.
represent
(
board
.
milestone
)
end
end
expose
:assignee
,
using:
::
API
::
Entities
::
UserBasic
expose
:labels
,
using:
::
API
::
Entities
::
LabelBasic
expose
:weight
end
end
end
end
end
end
ee/lib/ee/api/entities/issue.rb
0 → 100644
View file @
3033fe53
# frozen_string_literal: true
module
EE
module
API
module
Entities
module
Issue
extend
ActiveSupport
::
Concern
prepended
do
with_options
if:
->
(
issue
,
options
)
{
::
Ability
.
allowed?
(
options
[
:current_user
],
:read_epic
,
issue
.
project
&
.
group
)
}
do
expose
:epic_iid
do
|
issue
|
issue
.
epic
&
.
iid
end
expose
:epic
,
using:
EpicBaseEntity
end
end
end
end
end
end
ee/lib/ee/api/entities/list.rb
0 → 100644
View file @
3033fe53
# frozen_string_literal: true
module
EE
module
API
module
Entities
module
List
extend
ActiveSupport
::
Concern
prepended
do
expose
:milestone
,
using:
::
API
::
Entities
::
Milestone
,
if:
->
(
entity
,
_
)
{
entity
.
milestone?
}
expose
:user
,
as: :assignee
,
using:
::
API
::
Entities
::
UserSafe
,
if:
->
(
entity
,
_
)
{
entity
.
assignee?
}
expose
:max_issue_count
,
if:
->
(
list
,
_
)
{
list
.
wip_limits_available?
}
expose
:max_issue_weight
,
if:
->
(
list
,
_
)
{
list
.
wip_limits_available?
}
end
end
end
end
end
ee/lib/ee/api/entities/merge_request_basic.rb
0 → 100644
View file @
3033fe53
# frozen_string_literal: true
module
EE
module
API
module
Entities
module
MergeRequestBasic
extend
ActiveSupport
::
Concern
prepended
do
expose
:approvals_before_merge
end
end
end
end
end
ee/lib/ee/api/entities/namespace.rb
0 → 100644
View file @
3033fe53
# frozen_string_literal: true
module
EE
module
API
module
Entities
module
Namespace
extend
ActiveSupport
::
Concern
prepended
do
can_admin_namespace
=
->
(
namespace
,
opts
)
{
::
Ability
.
allowed?
(
opts
[
:current_user
],
:admin_namespace
,
namespace
)
}
expose
:shared_runners_minutes_limit
,
if:
->
(
_
,
options
)
{
options
[
:current_user
]
&
.
admin?
}
expose
:extra_shared_runners_minutes_limit
,
if:
->
(
_
,
options
)
{
options
[
:current_user
]
&
.
admin?
}
expose
:billable_members_count
do
|
namespace
,
options
|
namespace
.
billable_members_count
(
options
[
:requested_hosted_plan
])
end
expose
:plan
,
if:
can_admin_namespace
do
|
namespace
,
_
|
namespace
.
actual_plan_name
end
expose
:trial_ends_on
,
if:
can_admin_namespace
do
|
namespace
,
_
|
namespace
.
trial_ends_on
end
expose
:trial
,
if:
can_admin_namespace
do
|
namespace
,
_
|
namespace
.
trial?
end
end
end
end
end
end
ee/lib/ee/api/entities/todo.rb
0 → 100644
View file @
3033fe53
# frozen_string_literal: true
module
EE
module
API
module
Entities
module
Todo
extend
::
Gitlab
::
Utils
::
Override
extend
ActiveSupport
::
Concern
override
:todo_target_class
def
todo_target_class
(
target_type
)
super
rescue
NameError
# false as second argument prevents looking up in module hierarchy
# see also https://gitlab.com/gitlab-org/gitlab-foss/issues/59719
::
EE
::
API
::
Entities
.
const_get
(
target_type
,
false
)
end
override
:todo_target_url
def
todo_target_url
(
todo
)
return
super
unless
todo
.
target_type
==
::
DesignManagement
::
Design
.
name
design
=
todo
.
target
path_options
=
{
anchor:
todo_target_anchor
(
todo
),
vueroute:
design
.
filename
}
::
Gitlab
::
Routing
.
url_helpers
.
designs_project_issue_url
(
design
.
project
,
design
.
issue
,
path_options
)
end
end
end
end
end
ee/lib/ee/api/entities/user_details_with_admin.rb
0 → 100644
View file @
3033fe53
# frozen_string_literal: true
module
EE
module
API
module
Entities
module
UserDetailsWithAdmin
extend
ActiveSupport
::
Concern
prepended
do
expose
:plan
do
|
user
|
user
.
namespace
.
try
(
:gitlab_subscription
)
&
.
plan_name
end
expose
:trial
do
|
user
|
user
.
namespace
.
try
(
:trial?
)
end
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