From cfc792b9ca064990e6540cb742e80529ea669a81 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Tue, 10 Dec 2019 07:53:40 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- app/serializers/environment_entity.rb | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'app/serializers') diff --git a/app/serializers/environment_entity.rb b/app/serializers/environment_entity.rb index bffd9de4978..74d6806e83f 100644 --- a/app/serializers/environment_entity.rb +++ b/app/serializers/environment_entity.rb @@ -24,6 +24,10 @@ class EnvironmentEntity < Grape::Entity stop_project_environment_path(environment.project, environment) end + expose :cancel_auto_stop_path, if: -> (*) { can_update_environment? } do |environment| + cancel_auto_stop_project_environment_path(environment.project, environment) + end + expose :cluster_type, if: ->(environment, _) { cluster_platform_kubernetes? } do |environment| cluster.cluster_type end @@ -37,6 +41,7 @@ class EnvironmentEntity < Grape::Entity end expose :created_at, :updated_at + expose :auto_stop_at, expose_nil: false expose :can_stop do |environment| environment.available? && can?(current_user, :stop_environment, environment) @@ -54,6 +59,10 @@ class EnvironmentEntity < Grape::Entity can?(request.current_user, :create_environment_terminal, environment) end + def can_update_environment? + can?(current_user, :update_environment, environment) + end + def cluster_platform_kubernetes? deployment_platform && deployment_platform.is_a?(Clusters::Platforms::Kubernetes) end -- cgit v1.2.1