Commit 6e76fd0b authored by Yorick Peterse's avatar Yorick Peterse

Merge branch 'extract-ee-specific-lines-environment-entity' into 'master'

Extract EE specific files/lines for Release app/serializers

Closes #10130

See merge request gitlab-org/gitlab-ee!9992
parents 73b56490 0cde6bfe
......@@ -2,7 +2,6 @@
class EnvironmentEntity < Grape::Entity
include RequestAwareEntity
prepend ::EE::EnvironmentEntity # rubocop: disable Cop/InjectEnterpriseEditionModule
expose :id
expose :name
......@@ -12,7 +11,6 @@ class EnvironmentEntity < Grape::Entity
expose :name_without_type
expose :last_deployment, using: DeploymentEntity
expose :stop_action_available?, as: :has_stop_action
expose :rollout_status, if: -> (*) { can_read_deploy_board? }, using: RolloutStatusEntity
expose :metrics_path, if: -> (*) { environment.has_metrics? } do |environment|
metrics_project_environment_path(environment.project, environment)
......@@ -52,10 +50,6 @@ class EnvironmentEntity < Grape::Entity
request.current_user
end
def can_read_deploy_board?
can?(current_user, :read_deploy_board, environment.project)
end
def can_access_terminal?
can?(request.current_user, :create_environment_terminal, environment)
end
......@@ -72,3 +66,5 @@ class EnvironmentEntity < Grape::Entity
deployment_platform.cluster
end
end
EnvironmentEntity.prepend(::EE::EnvironmentEntity)
......@@ -6,6 +6,8 @@ module EE
extend ::Gitlab::Utils::Override
prepended do
expose :rollout_status, if: -> (*) { can_read_deploy_board? }, using: ::RolloutStatusEntity
expose :logs_path, if: -> (*) { can_read_pod_logs? } do |environment|
logs_project_environment_path(environment.project, environment)
end
......@@ -16,5 +18,9 @@ module EE
def can_read_pod_logs?
can?(current_user, :read_pod_logs, environment.project)
end
def can_read_deploy_board?
can?(current_user, :read_deploy_board, environment.project)
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment