Extract EE specific files/lines for Release app/serializers
We have the following files containing EE specific code. We should move them to ee/
app/serializers/environment_entity.rb
diff --git a/app/serializers/environment_entity.rb b/home/yorickpeterse/Projects/gitlab/gdk-ee/gitlab/app/serializers/environment_entity.rb
index 4a7d13915dd..f2bceb4d5bf 100644
--- a/app/serializers/environment_entity.rb
+++ b/home/yorickpeterse/Projects/gitlab/gdk-ee/gitlab/app/serializers/environment_entity.rb
@@ -2,6 +2,7 @@
class EnvironmentEntity < Grape::Entity
include RequestAwareEntity
+ prepend ::EE::EnvironmentEntity # rubocop: disable Cop/InjectEnterpriseEditionModule
expose :id
expose :name
@@ -10,8 +11,9 @@ class EnvironmentEntity < Grape::Entity
expose :environment_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, _) { environment.has_metrics? } do |environment|
+ expose :metrics_path, if: -> (*) { environment.has_metrics? } do |environment|
metrics_project_environment_path(environment.project, environment)
end
@@ -49,6 +51,10 @@ 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