summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2019-02-26 19:13:09 +0000
committerStan Hu <stanhu@gmail.com>2019-02-26 19:13:09 +0000
commit3395eacb57285424b7b8d49bdf836f638af31e8c (patch)
treec602b75234cd3abdb50cb62a46d539bdb6cfa5b8 /app
parent9812006568061f0afd8dfb146920e526877d4d9b (diff)
parent25c10abb80799e24e616e2bb8c0081096b201c29 (diff)
downloadgitlab-ce-3395eacb57285424b7b8d49bdf836f638af31e8c.tar.gz
Merge branch 'add-name_without_type-to-environments-json' into 'master'
Add name_without_type to environments.json See merge request gitlab-org/gitlab-ce!25492
Diffstat (limited to 'app')
-rw-r--r--app/models/environment.rb4
-rw-r--r--app/serializers/environment_entity.rb1
2 files changed, 5 insertions, 0 deletions
diff --git a/app/models/environment.rb b/app/models/environment.rb
index 1fc088b12ae..87bdb52b58b 100644
--- a/app/models/environment.rb
+++ b/app/models/environment.rb
@@ -243,6 +243,10 @@ class Environment < ActiveRecord::Base
self.environment_type || self.name
end
+ def name_without_type
+ @name_without_type ||= name.delete_prefix("#{environment_type}/")
+ end
+
def deployment_platform
strong_memoize(:deployment_platform) do
project.deployment_platform(environment: self.name)
diff --git a/app/serializers/environment_entity.rb b/app/serializers/environment_entity.rb
index 4a7d13915dd..76248e6470e 100644
--- a/app/serializers/environment_entity.rb
+++ b/app/serializers/environment_entity.rb
@@ -8,6 +8,7 @@ class EnvironmentEntity < Grape::Entity
expose :state
expose :external_url
expose :environment_type
+ expose :name_without_type
expose :last_deployment, using: DeploymentEntity
expose :stop_action_available?, as: :has_stop_action