diff options
author | Winnie Hellmann <winnie@gitlab.com> | 2018-07-10 08:11:04 +0000 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2018-07-10 08:11:04 +0000 |
commit | d79cef3a9a5577765d975326fbf4bc1b8c5634de (patch) | |
tree | fad8dce6f89102fda75f511dee80b7fae7675994 /app/serializers | |
parent | ca1deb9e5ec1429a65d73b3352d1207301f9fc6f (diff) | |
download | gitlab-ce-d79cef3a9a5577765d975326fbf4bc1b8c5634de.tar.gz |
Support manually stopping any environment from the UI
Diffstat (limited to 'app/serializers')
-rw-r--r-- | app/serializers/environment_entity.rb | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/app/serializers/environment_entity.rb b/app/serializers/environment_entity.rb index ba0ae6ba8a0..0fc3f92b151 100644 --- a/app/serializers/environment_entity.rb +++ b/app/serializers/environment_entity.rb @@ -7,7 +7,7 @@ class EnvironmentEntity < Grape::Entity expose :external_url expose :environment_type expose :last_deployment, using: DeploymentEntity - expose :stop_action? + expose :stop_action?, as: :has_stop_action expose :metrics_path, if: -> (environment, _) { environment.has_metrics? } do |environment| metrics_project_environment_path(environment.project, environment) @@ -31,4 +31,14 @@ class EnvironmentEntity < Grape::Entity end expose :created_at, :updated_at + + expose :can_stop do |environment| + environment.available? && can?(current_user, :stop_environment, environment) + end + + private + + def current_user + request.current_user + end end |