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
559f0c06
Commit
559f0c06
authored
Jan 26, 2020
by
Rajendra Kadam
Committed by
Stan Hu
Jan 26, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Separate user related entities in own class files
parent
2ecc399e
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
104 additions
and
59 deletions
+104
-59
changelogs/unreleased/refactoring-entities-file-2.yml
changelogs/unreleased/refactoring-entities-file-2.yml
+5
-0
lib/api/entities.rb
lib/api/entities.rb
+0
-59
lib/api/entities/user.rb
lib/api/entities/user.rb
+10
-0
lib/api/entities/user_activity.rb
lib/api/entities/user_activity.rb
+11
-0
lib/api/entities/user_basic.rb
lib/api/entities/user_basic.rb
+20
-0
lib/api/entities/user_details_with_admin.rb
lib/api/entities/user_details_with_admin.rb
+11
-0
lib/api/entities/user_public.rb
lib/api/entities/user_public.rb
+19
-0
lib/api/entities/user_safe.rb
lib/api/entities/user_safe.rb
+9
-0
lib/api/entities/user_stars_project.rb
lib/api/entities/user_stars_project.rb
+10
-0
lib/api/entities/user_with_admin.rb
lib/api/entities/user_with_admin.rb
+9
-0
No files found.
changelogs/unreleased/refactoring-entities-file-2.yml
0 → 100644
View file @
559f0c06
---
title
:
Refactor user entities into own class files
merge_request
:
23730
author
:
Rajendra Kadam
type
:
added
lib/api/entities.rb
View file @
559f0c06
...
@@ -11,69 +11,10 @@ module API
...
@@ -11,69 +11,10 @@ module API
expose
:access_level
expose
:access_level
end
end
class
UserSafe
<
Grape
::
Entity
expose
:id
,
:name
,
:username
end
class
UserBasic
<
UserSafe
expose
:state
expose
:avatar_url
do
|
user
,
options
|
user
.
avatar_url
(
only_path:
false
)
end
expose
:avatar_path
,
if:
->
(
user
,
options
)
{
options
.
fetch
(
:only_path
,
false
)
&&
user
.
avatar_path
}
expose
:custom_attributes
,
using:
'API::Entities::CustomAttribute'
,
if: :with_custom_attributes
expose
:web_url
do
|
user
,
options
|
Gitlab
::
Routing
.
url_helpers
.
user_url
(
user
)
end
end
class
User
<
UserBasic
expose
:created_at
,
if:
->
(
user
,
opts
)
{
Ability
.
allowed?
(
opts
[
:current_user
],
:read_user_profile
,
user
)
}
expose
:bio
,
:location
,
:public_email
,
:skype
,
:linkedin
,
:twitter
,
:website_url
,
:organization
end
class
UserActivity
<
Grape
::
Entity
expose
:username
expose
:last_activity_on
expose
:last_activity_on
,
as: :last_activity_at
# Back-compat
end
class
UserStarsProject
<
Grape
::
Entity
expose
:starred_since
expose
:user
,
using:
Entities
::
UserBasic
end
class
Identity
<
Grape
::
Entity
class
Identity
<
Grape
::
Entity
expose
:provider
,
:extern_uid
expose
:provider
,
:extern_uid
end
end
class
UserPublic
<
User
expose
:last_sign_in_at
expose
:confirmed_at
expose
:last_activity_on
expose
:email
expose
:theme_id
,
:color_scheme_id
,
:projects_limit
,
:current_sign_in_at
expose
:identities
,
using:
Entities
::
Identity
expose
:can_create_group?
,
as: :can_create_group
expose
:can_create_project?
,
as: :can_create_project
expose
:two_factor_enabled?
,
as: :two_factor_enabled
expose
:external
expose
:private_profile
end
class
UserWithAdmin
<
UserPublic
expose
:admin?
,
as: :is_admin
end
class
UserDetailsWithAdmin
<
UserWithAdmin
expose
:highest_role
expose
:current_sign_in_ip
expose
:last_sign_in_ip
end
class
UserStatus
<
Grape
::
Entity
class
UserStatus
<
Grape
::
Entity
expose
:emoji
expose
:emoji
expose
:message
expose
:message
...
...
lib/api/entities/user.rb
0 → 100644
View file @
559f0c06
# frozen_string_literal: true
module
API
module
Entities
class
User
<
UserBasic
expose
:created_at
,
if:
->
(
user
,
opts
)
{
Ability
.
allowed?
(
opts
[
:current_user
],
:read_user_profile
,
user
)
}
expose
:bio
,
:location
,
:public_email
,
:skype
,
:linkedin
,
:twitter
,
:website_url
,
:organization
end
end
end
lib/api/entities/user_activity.rb
0 → 100644
View file @
559f0c06
# frozen_string_literal: true
module
API
module
Entities
class
UserActivity
<
Grape
::
Entity
expose
:username
expose
:last_activity_on
expose
:last_activity_on
,
as: :last_activity_at
# Back-compat
end
end
end
lib/api/entities/user_basic.rb
0 → 100644
View file @
559f0c06
# frozen_string_literal: true
module
API
module
Entities
class
UserBasic
<
UserSafe
expose
:state
expose
:avatar_url
do
|
user
,
options
|
user
.
avatar_url
(
only_path:
false
)
end
expose
:avatar_path
,
if:
->
(
user
,
options
)
{
options
.
fetch
(
:only_path
,
false
)
&&
user
.
avatar_path
}
expose
:custom_attributes
,
using:
'API::Entities::CustomAttribute'
,
if: :with_custom_attributes
expose
:web_url
do
|
user
,
options
|
Gitlab
::
Routing
.
url_helpers
.
user_url
(
user
)
end
end
end
end
lib/api/entities/user_details_with_admin.rb
0 → 100644
View file @
559f0c06
# frozen_string_literal: true
module
API
module
Entities
class
UserDetailsWithAdmin
<
UserWithAdmin
expose
:highest_role
expose
:current_sign_in_ip
expose
:last_sign_in_ip
end
end
end
lib/api/entities/user_public.rb
0 → 100644
View file @
559f0c06
# frozen_string_literal: true
module
API
module
Entities
class
UserPublic
<
Entities
::
User
expose
:last_sign_in_at
expose
:confirmed_at
expose
:last_activity_on
expose
:email
expose
:theme_id
,
:color_scheme_id
,
:projects_limit
,
:current_sign_in_at
expose
:identities
,
using:
Entities
::
Identity
expose
:can_create_group?
,
as: :can_create_group
expose
:can_create_project?
,
as: :can_create_project
expose
:two_factor_enabled?
,
as: :two_factor_enabled
expose
:external
expose
:private_profile
end
end
end
lib/api/entities/user_safe.rb
0 → 100644
View file @
559f0c06
# frozen_string_literal: true
module
API
module
Entities
class
UserSafe
<
Grape
::
Entity
expose
:id
,
:name
,
:username
end
end
end
lib/api/entities/user_stars_project.rb
0 → 100644
View file @
559f0c06
# frozen_string_literal: true
module
API
module
Entities
class
UserStarsProject
<
Grape
::
Entity
expose
:starred_since
expose
:user
,
using:
Entities
::
UserBasic
end
end
end
lib/api/entities/user_with_admin.rb
0 → 100644
View file @
559f0c06
# frozen_string_literal: true
module
API
module
Entities
class
UserWithAdmin
<
UserPublic
expose
:admin?
,
as: :is_admin
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