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
01f8766c
Commit
01f8766c
authored
Feb 13, 2020
by
Rajendra Kadam
Committed by
Stan Hu
Feb 13, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Separate access classes into own class files
parent
db800a16
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
64 additions
and
34 deletions
+64
-34
changelogs/unreleased/refactoring-entities-file-15.yml
changelogs/unreleased/refactoring-entities-file-15.yml
+5
-0
lib/api/entities.rb
lib/api/entities.rb
+0
-34
lib/api/entities/group_access.rb
lib/api/entities/group_access.rb
+8
-0
lib/api/entities/member_access.rb
lib/api/entities/member_access.rb
+14
-0
lib/api/entities/namespace.rb
lib/api/entities/namespace.rb
+15
-0
lib/api/entities/notification_setting.rb
lib/api/entities/notification_setting.rb
+14
-0
lib/api/entities/project_access.rb
lib/api/entities/project_access.rb
+8
-0
No files found.
changelogs/unreleased/refactoring-entities-file-15.yml
0 → 100644
View file @
01f8766c
---
title
:
Separate access entities into own class files
merge_request
:
24845
author
:
Rajendra Kadam
type
:
added
lib/api/entities.rb
View file @
01f8766c
...
...
@@ -129,40 +129,6 @@ module API
end
end
class
Namespace
<
NamespaceBasic
expose
:members_count_with_descendants
,
if:
->
(
namespace
,
opts
)
{
expose_members_count_with_descendants?
(
namespace
,
opts
)
}
do
|
namespace
,
_
|
namespace
.
users_with_descendants
.
count
end
def
expose_members_count_with_descendants?
(
namespace
,
opts
)
namespace
.
kind
==
'group'
&&
Ability
.
allowed?
(
opts
[
:current_user
],
:admin_group
,
namespace
)
end
end
class
MemberAccess
<
Grape
::
Entity
expose
:access_level
expose
:notification_level
do
|
member
,
options
|
if
member
.
notification_setting
::
NotificationSetting
.
levels
[
member
.
notification_setting
.
level
]
end
end
end
class
ProjectAccess
<
MemberAccess
end
class
GroupAccess
<
MemberAccess
end
class
NotificationSetting
<
Grape
::
Entity
expose
:level
expose
:events
,
if:
->
(
notification_setting
,
_
)
{
notification_setting
.
custom?
}
do
::
NotificationSetting
.
email_events
.
each
do
|
event
|
expose
event
end
end
end
class
Trigger
<
Grape
::
Entity
include
::
API
::
Helpers
::
Presentable
...
...
lib/api/entities/group_access.rb
0 → 100644
View file @
01f8766c
# frozen_string_literal: true
module
API
module
Entities
class
GroupAccess
<
MemberAccess
end
end
end
lib/api/entities/member_access.rb
0 → 100644
View file @
01f8766c
# frozen_string_literal: true
module
API
module
Entities
class
MemberAccess
<
Grape
::
Entity
expose
:access_level
expose
:notification_level
do
|
member
,
options
|
if
member
.
notification_setting
::
NotificationSetting
.
levels
[
member
.
notification_setting
.
level
]
end
end
end
end
end
lib/api/entities/namespace.rb
0 → 100644
View file @
01f8766c
# frozen_string_literal: true
module
API
module
Entities
class
Namespace
<
Entities
::
NamespaceBasic
expose
:members_count_with_descendants
,
if:
->
(
namespace
,
opts
)
{
expose_members_count_with_descendants?
(
namespace
,
opts
)
}
do
|
namespace
,
_
|
namespace
.
users_with_descendants
.
count
end
def
expose_members_count_with_descendants?
(
namespace
,
opts
)
namespace
.
kind
==
'group'
&&
Ability
.
allowed?
(
opts
[
:current_user
],
:admin_group
,
namespace
)
end
end
end
end
lib/api/entities/notification_setting.rb
0 → 100644
View file @
01f8766c
# frozen_string_literal: true
module
API
module
Entities
class
NotificationSetting
<
Grape
::
Entity
expose
:level
expose
:events
,
if:
->
(
notification_setting
,
_
)
{
notification_setting
.
custom?
}
do
::
NotificationSetting
.
email_events
.
each
do
|
event
|
expose
event
end
end
end
end
end
lib/api/entities/project_access.rb
0 → 100644
View file @
01f8766c
# frozen_string_literal: true
module
API
module
Entities
class
ProjectAccess
<
Entities
::
MemberAccess
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