diff options
author | Vladimir Shushlin <vshushlin@gitlab.com> | 2019-02-26 19:13:09 +0000 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2019-02-26 19:13:09 +0000 |
commit | 25c10abb80799e24e616e2bb8c0081096b201c29 (patch) | |
tree | c602b75234cd3abdb50cb62a46d539bdb6cfa5b8 /app | |
parent | 9812006568061f0afd8dfb146920e526877d4d9b (diff) | |
download | gitlab-ce-25c10abb80799e24e616e2bb8c0081096b201c29.tar.gz |
Add name_without_type to environments.json
It's needed to show shorter names in environments "folders"
Diffstat (limited to 'app')
-rw-r--r-- | app/models/environment.rb | 4 | ||||
-rw-r--r-- | app/serializers/environment_entity.rb | 1 |
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 |