Commit 0cde6bfe authored by Shinya Maeda's avatar Shinya Maeda

Extract EE specific files/lines for Release app/serializers

ok
parent 50b922ac
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
class EnvironmentEntity < Grape::Entity class EnvironmentEntity < Grape::Entity
include RequestAwareEntity include RequestAwareEntity
prepend ::EE::EnvironmentEntity # rubocop: disable Cop/InjectEnterpriseEditionModule
expose :id expose :id
expose :name expose :name
...@@ -12,7 +11,6 @@ class EnvironmentEntity < Grape::Entity ...@@ -12,7 +11,6 @@ class EnvironmentEntity < Grape::Entity
expose :name_without_type expose :name_without_type
expose :last_deployment, using: DeploymentEntity expose :last_deployment, using: DeploymentEntity
expose :stop_action_available?, as: :has_stop_action 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| expose :metrics_path, if: -> (*) { environment.has_metrics? } do |environment|
metrics_project_environment_path(environment.project, environment) metrics_project_environment_path(environment.project, environment)
...@@ -52,10 +50,6 @@ class EnvironmentEntity < Grape::Entity ...@@ -52,10 +50,6 @@ class EnvironmentEntity < Grape::Entity
request.current_user request.current_user
end end
def can_read_deploy_board?
can?(current_user, :read_deploy_board, environment.project)
end
def can_access_terminal? def can_access_terminal?
can?(request.current_user, :create_environment_terminal, environment) can?(request.current_user, :create_environment_terminal, environment)
end end
...@@ -72,3 +66,5 @@ class EnvironmentEntity < Grape::Entity ...@@ -72,3 +66,5 @@ class EnvironmentEntity < Grape::Entity
deployment_platform.cluster deployment_platform.cluster
end end
end end
EnvironmentEntity.prepend(::EE::EnvironmentEntity)
...@@ -6,6 +6,8 @@ module EE ...@@ -6,6 +6,8 @@ module EE
extend ::Gitlab::Utils::Override extend ::Gitlab::Utils::Override
prepended do prepended do
expose :rollout_status, if: -> (*) { can_read_deploy_board? }, using: ::RolloutStatusEntity
expose :logs_path, if: -> (*) { can_read_pod_logs? } do |environment| expose :logs_path, if: -> (*) { can_read_pod_logs? } do |environment|
logs_project_environment_path(environment.project, environment) logs_project_environment_path(environment.project, environment)
end end
...@@ -16,5 +18,9 @@ module EE ...@@ -16,5 +18,9 @@ module EE
def can_read_pod_logs? def can_read_pod_logs?
can?(current_user, :read_pod_logs, environment.project) can?(current_user, :read_pod_logs, environment.project)
end end
def can_read_deploy_board?
can?(current_user, :read_deploy_board, environment.project)
end
end 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