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
b703e122
Commit
b703e122
authored
Mar 23, 2020
by
Rajendra Kadam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Separate user, entity and project modules into own files
parent
c236c0c0
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
78 additions
and
50 deletions
+78
-50
ee/lib/ee/api/entities.rb
ee/lib/ee/api/entities.rb
+0
-50
ee/lib/ee/api/entities/entity_helpers.rb
ee/lib/ee/api/entities/entity_helpers.rb
+21
-0
ee/lib/ee/api/entities/project.rb
ee/lib/ee/api/entities/project.rb
+26
-0
ee/lib/ee/api/entities/user_public.rb
ee/lib/ee/api/entities/user_public.rb
+16
-0
ee/lib/ee/api/entities/user_with_admin.rb
ee/lib/ee/api/entities/user_with_admin.rb
+15
-0
No files found.
ee/lib/ee/api/entities.rb
View file @
b703e122
...
@@ -3,56 +3,6 @@
...
@@ -3,56 +3,6 @@
module
EE
module
EE
module
API
module
API
module
Entities
module
Entities
module
EntityHelpers
def
can_read
(
attr
,
&
block
)
->
(
obj
,
opts
)
{
Ability
.
allowed?
(
opts
[
:user
],
"read_
#{
attr
}
"
.
to_sym
,
yield
(
obj
))
}
end
def
can_destroy
(
attr
,
&
block
)
->
(
obj
,
opts
)
{
Ability
.
allowed?
(
opts
[
:user
],
"destroy_
#{
attr
}
"
.
to_sym
,
yield
(
obj
))
}
end
def
expose_restricted
(
attr
,
&
block
)
expose
attr
,
if:
can_read
(
attr
,
&
block
)
end
end
module
UserPublic
extend
ActiveSupport
::
Concern
prepended
do
expose
:shared_runners_minutes_limit
expose
:extra_shared_runners_minutes_limit
end
end
module
UserWithAdmin
extend
ActiveSupport
::
Concern
prepended
do
expose
:note
end
end
module
Project
extend
ActiveSupport
::
Concern
prepended
do
expose
:approvals_before_merge
,
if:
->
(
project
,
_
)
{
project
.
feature_available?
(
:merge_request_approvers
)
}
expose
:mirror
,
if:
->
(
project
,
_
)
{
project
.
feature_available?
(
:repository_mirrors
)
}
expose
:mirror_user_id
,
if:
->
(
project
,
_
)
{
project
.
mirror?
}
expose
:mirror_trigger_builds
,
if:
->
(
project
,
_
)
{
project
.
mirror?
}
expose
:only_mirror_protected_branches
,
if:
->
(
project
,
_
)
{
project
.
mirror?
}
expose
:mirror_overwrites_diverged_branches
,
if:
->
(
project
,
_
)
{
project
.
mirror?
}
expose
:external_authorization_classification_label
,
if:
->
(
_
,
_
)
{
License
.
feature_available?
(
:external_authorization_service_api_management
)
}
expose
:packages_enabled
,
if:
->
(
project
,
_
)
{
project
.
feature_available?
(
:packages
)
}
expose
:service_desk_enabled
,
if:
->
(
project
,
_
)
{
project
.
feature_available?
(
:service_desk
)
}
expose
:service_desk_address
,
if:
->
(
project
,
_
)
{
project
.
feature_available?
(
:service_desk
)
}
expose
:marked_for_deletion_at
,
if:
->
(
project
,
_
)
{
project
.
feature_available?
(
:adjourned_deletion_for_projects_and_groups
)
}
end
end
module
Group
module
Group
extend
ActiveSupport
::
Concern
extend
ActiveSupport
::
Concern
...
...
ee/lib/ee/api/entities/entity_helpers.rb
0 → 100644
View file @
b703e122
# frozen_string_literal: true
module
EE
module
API
module
Entities
module
EntityHelpers
def
can_read
(
attr
,
&
block
)
->
(
obj
,
opts
)
{
Ability
.
allowed?
(
opts
[
:user
],
"read_
#{
attr
}
"
.
to_sym
,
yield
(
obj
))
}
end
def
can_destroy
(
attr
,
&
block
)
->
(
obj
,
opts
)
{
Ability
.
allowed?
(
opts
[
:user
],
"destroy_
#{
attr
}
"
.
to_sym
,
yield
(
obj
))
}
end
def
expose_restricted
(
attr
,
&
block
)
expose
attr
,
if:
can_read
(
attr
,
&
block
)
end
end
end
end
end
ee/lib/ee/api/entities/project.rb
0 → 100644
View file @
b703e122
# frozen_string_literal: true
module
EE
module
API
module
Entities
module
Project
extend
ActiveSupport
::
Concern
prepended
do
expose
:approvals_before_merge
,
if:
->
(
project
,
_
)
{
project
.
feature_available?
(
:merge_request_approvers
)
}
expose
:mirror
,
if:
->
(
project
,
_
)
{
project
.
feature_available?
(
:repository_mirrors
)
}
expose
:mirror_user_id
,
if:
->
(
project
,
_
)
{
project
.
mirror?
}
expose
:mirror_trigger_builds
,
if:
->
(
project
,
_
)
{
project
.
mirror?
}
expose
:only_mirror_protected_branches
,
if:
->
(
project
,
_
)
{
project
.
mirror?
}
expose
:mirror_overwrites_diverged_branches
,
if:
->
(
project
,
_
)
{
project
.
mirror?
}
expose
:external_authorization_classification_label
,
if:
->
(
_
,
_
)
{
License
.
feature_available?
(
:external_authorization_service_api_management
)
}
expose
:packages_enabled
,
if:
->
(
project
,
_
)
{
project
.
feature_available?
(
:packages
)
}
expose
:service_desk_enabled
,
if:
->
(
project
,
_
)
{
project
.
feature_available?
(
:service_desk
)
}
expose
:service_desk_address
,
if:
->
(
project
,
_
)
{
project
.
feature_available?
(
:service_desk
)
}
expose
:marked_for_deletion_at
,
if:
->
(
project
,
_
)
{
project
.
feature_available?
(
:adjourned_deletion_for_projects_and_groups
)
}
end
end
end
end
end
ee/lib/ee/api/entities/user_public.rb
0 → 100644
View file @
b703e122
# frozen_string_literal: true
module
EE
module
API
module
Entities
module
UserPublic
extend
ActiveSupport
::
Concern
prepended
do
expose
:shared_runners_minutes_limit
expose
:extra_shared_runners_minutes_limit
end
end
end
end
end
ee/lib/ee/api/entities/user_with_admin.rb
0 → 100644
View file @
b703e122
# frozen_string_literal: true
module
EE
module
API
module
Entities
module
UserWithAdmin
extend
ActiveSupport
::
Concern
prepended
do
expose
:note
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