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
68e9d9f0
Commit
68e9d9f0
authored
Mar 16, 2020
by
Rajendra Kadam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor approver classess into own class file for EE entities
parent
45e3f2e5
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
127 additions
and
92 deletions
+127
-92
ee/lib/ee/api/entities.rb
ee/lib/ee/api/entities.rb
+0
-92
ee/lib/ee/api/entities/approval_settings.rb
ee/lib/ee/api/entities/approval_settings.rb
+18
-0
ee/lib/ee/api/entities/approval_state.rb
ee/lib/ee/api/entities/approval_state.rb
+74
-0
ee/lib/ee/api/entities/approvals.rb
ee/lib/ee/api/entities/approvals.rb
+11
-0
ee/lib/ee/api/entities/approver.rb
ee/lib/ee/api/entities/approver.rb
+12
-0
ee/lib/ee/api/entities/approver_group.rb
ee/lib/ee/api/entities/approver_group.rb
+12
-0
No files found.
ee/lib/ee/api/entities.rb
View file @
68e9d9f0
...
@@ -297,98 +297,6 @@ module EE
...
@@ -297,98 +297,6 @@ module EE
expose
:wrapped_approval_rules
,
as: :rules
,
using:
MergeRequestApprovalSettingRule
,
override:
true
expose
:wrapped_approval_rules
,
as: :rules
,
using:
MergeRequestApprovalSettingRule
,
override:
true
end
end
# @deprecated
class
Approver
<
Grape
::
Entity
expose
:user
,
using:
::
API
::
Entities
::
UserBasic
end
# @deprecated
class
ApproverGroup
<
Grape
::
Entity
expose
:group
,
using:
::
API
::
Entities
::
Group
end
class
ApprovalSettings
<
Grape
::
Entity
expose
:approvers
,
using:
EE
::
API
::
Entities
::
Approver
expose
:approver_groups
,
using:
EE
::
API
::
Entities
::
ApproverGroup
expose
:approvals_before_merge
expose
:reset_approvals_on_push
expose
:disable_overriding_approvers_per_merge_request
expose
:merge_requests_author_approval
expose
:merge_requests_disable_committers_approval
expose
:require_password_to_approve
end
class
Approvals
<
Grape
::
Entity
expose
:user
,
using:
::
API
::
Entities
::
UserBasic
end
class
ApprovalState
<
Grape
::
Entity
expose
:merge_request
,
merge:
true
,
using:
::
API
::
Entities
::
IssuableEntity
expose
(
:merge_status
)
{
|
approval_state
|
approval_state
.
merge_request
.
merge_status
}
expose
:approved?
,
as: :approved
expose
:approvals_required
expose
:approvals_left
expose
:require_password_to_approve
do
|
approval_state
|
approval_state
.
project
.
require_password_to_approve?
end
expose
:approved_by
,
using:
EE
::
API
::
Entities
::
Approvals
do
|
approval_state
|
approval_state
.
merge_request
.
approvals
end
expose
:suggested_approvers
,
using:
::
API
::
Entities
::
UserBasic
do
|
approval_state
,
options
|
approval_state
.
suggested_approvers
(
current_user:
options
[
:current_user
])
end
# @deprecated, reads from first regular rule instead
expose
:approvers
do
|
approval_state
|
if
rule
=
approval_state
.
first_regular_rule
rule
.
users
.
map
do
|
user
|
{
user:
::
API
::
Entities
::
UserBasic
.
represent
(
user
)
}
end
else
[]
end
end
# @deprecated, reads from first regular rule instead
expose
:approver_groups
do
|
approval_state
|
if
rule
=
approval_state
.
first_regular_rule
presenter
=
::
ApprovalRulePresenter
.
new
(
rule
,
current_user:
options
[
:current_user
])
presenter
.
groups
.
map
do
|
group
|
{
group:
::
API
::
Entities
::
Group
.
represent
(
group
)
}
end
else
[]
end
end
expose
:user_has_approved
do
|
approval_state
,
options
|
approval_state
.
has_approved?
(
options
[
:current_user
])
end
expose
:user_can_approve
do
|
approval_state
,
options
|
approval_state
.
can_approve?
(
options
[
:current_user
])
end
expose
:approval_rules_left
,
using:
ApprovalRuleShort
expose
:has_approval_rules
do
|
approval_state
|
approval_state
.
user_defined_rules
.
present?
end
expose
:merge_request_approvers_available
do
|
approval_state
|
approval_state
.
project
.
feature_available?
(
:merge_request_approvers
)
end
expose
:multiple_approval_rules_available
do
|
approval_state
|
approval_state
.
project
.
multiple_approval_rules_available?
end
end
module
ConanPackage
module
ConanPackage
class
ConanPackageManifest
<
Grape
::
Entity
class
ConanPackageManifest
<
Grape
::
Entity
expose
:package_urls
,
merge:
true
expose
:package_urls
,
merge:
true
...
...
ee/lib/ee/api/entities/approval_settings.rb
0 → 100644
View file @
68e9d9f0
# frozen_string_literal: true
module
EE
module
API
module
Entities
class
ApprovalSettings
<
Grape
::
Entity
expose
:approvers
,
using:
EE
::
API
::
Entities
::
Approver
expose
:approver_groups
,
using:
EE
::
API
::
Entities
::
ApproverGroup
expose
:approvals_before_merge
expose
:reset_approvals_on_push
expose
:disable_overriding_approvers_per_merge_request
expose
:merge_requests_author_approval
expose
:merge_requests_disable_committers_approval
expose
:require_password_to_approve
end
end
end
end
ee/lib/ee/api/entities/approval_state.rb
0 → 100644
View file @
68e9d9f0
# frozen_string_literal: true
module
EE
module
API
module
Entities
class
ApprovalState
<
Grape
::
Entity
expose
:merge_request
,
merge:
true
,
using:
::
API
::
Entities
::
IssuableEntity
expose
(
:merge_status
)
{
|
approval_state
|
approval_state
.
merge_request
.
merge_status
}
expose
:approved?
,
as: :approved
expose
:approvals_required
expose
:approvals_left
expose
:require_password_to_approve
do
|
approval_state
|
approval_state
.
project
.
require_password_to_approve?
end
expose
:approved_by
,
using:
EE
::
API
::
Entities
::
Approvals
do
|
approval_state
|
approval_state
.
merge_request
.
approvals
end
expose
:suggested_approvers
,
using:
::
API
::
Entities
::
UserBasic
do
|
approval_state
,
options
|
approval_state
.
suggested_approvers
(
current_user:
options
[
:current_user
])
end
# @deprecated, reads from first regular rule instead
expose
:approvers
do
|
approval_state
|
if
rule
=
approval_state
.
first_regular_rule
rule
.
users
.
map
do
|
user
|
{
user:
::
API
::
Entities
::
UserBasic
.
represent
(
user
)
}
end
else
[]
end
end
# @deprecated, reads from first regular rule instead
expose
:approver_groups
do
|
approval_state
|
if
rule
=
approval_state
.
first_regular_rule
presenter
=
::
ApprovalRulePresenter
.
new
(
rule
,
current_user:
options
[
:current_user
])
presenter
.
groups
.
map
do
|
group
|
{
group:
::
API
::
Entities
::
Group
.
represent
(
group
)
}
end
else
[]
end
end
expose
:user_has_approved
do
|
approval_state
,
options
|
approval_state
.
has_approved?
(
options
[
:current_user
])
end
expose
:user_can_approve
do
|
approval_state
,
options
|
approval_state
.
can_approve?
(
options
[
:current_user
])
end
expose
:approval_rules_left
,
using:
ApprovalRuleShort
expose
:has_approval_rules
do
|
approval_state
|
approval_state
.
user_defined_rules
.
present?
end
expose
:merge_request_approvers_available
do
|
approval_state
|
approval_state
.
project
.
feature_available?
(
:merge_request_approvers
)
end
expose
:multiple_approval_rules_available
do
|
approval_state
|
approval_state
.
project
.
multiple_approval_rules_available?
end
end
end
end
end
ee/lib/ee/api/entities/approvals.rb
0 → 100644
View file @
68e9d9f0
# frozen_string_literal: true
module
EE
module
API
module
Entities
class
Approvals
<
Grape
::
Entity
expose
:user
,
using:
::
API
::
Entities
::
UserBasic
end
end
end
end
ee/lib/ee/api/entities/approver.rb
0 → 100644
View file @
68e9d9f0
# frozen_string_literal: true
module
EE
module
API
module
Entities
# @deprecated
class
Approver
<
Grape
::
Entity
expose
:user
,
using:
::
API
::
Entities
::
UserBasic
end
end
end
end
ee/lib/ee/api/entities/approver_group.rb
0 → 100644
View file @
68e9d9f0
# frozen_string_literal: true
module
EE
module
API
module
Entities
# @deprecated
class
ApproverGroup
<
Grape
::
Entity
expose
:group
,
using:
::
API
::
Entities
::
Group
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