diff options
author | Fatih Acet <acetfatih@gmail.com> | 2016-12-15 00:59:04 +0000 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2016-12-19 21:27:08 +0000 |
commit | 3db5b7033b13c21b904a21f751bc0f19156ea155 (patch) | |
tree | 0f5cfa65887744bb352dded9960217ae6df86ff5 /app/serializers | |
parent | c3d972f4e861059312c2708dacb57999416fcc70 (diff) | |
download | gitlab-ce-3db5b7033b13c21b904a21f751bc0f19156ea155.tar.gz |
Add terminal UI and controller actions
Diffstat (limited to 'app/serializers')
-rw-r--r-- | app/serializers/environment_entity.rb | 10 | ||||
-rw-r--r-- | app/serializers/request_aware_entity.rb | 4 |
2 files changed, 9 insertions, 5 deletions
diff --git a/app/serializers/environment_entity.rb b/app/serializers/environment_entity.rb index e7ef01258ef..5d15eb8d3d3 100644 --- a/app/serializers/environment_entity.rb +++ b/app/serializers/environment_entity.rb @@ -8,7 +8,6 @@ class EnvironmentEntity < Grape::Entity expose :environment_type expose :last_deployment, using: DeploymentEntity expose :stoppable? - expose :has_terminals?, as: :has_terminals expose :environment_path do |environment| namespace_project_environment_path( @@ -25,10 +24,11 @@ class EnvironmentEntity < Grape::Entity end expose :terminal_path, if: ->(environment, _) { environment.has_terminals? } do |environment| - terminal_namespace_project_environment_path( - environment.project.namespace, - environment.project, - environment) + can?(request.user, :admin_environment, environment.project) && + terminal_namespace_project_environment_path( + environment.project.namespace, + environment.project, + environment) end expose :created_at, :updated_at diff --git a/app/serializers/request_aware_entity.rb b/app/serializers/request_aware_entity.rb index ff8c1142abc..e159d750cb7 100644 --- a/app/serializers/request_aware_entity.rb +++ b/app/serializers/request_aware_entity.rb @@ -8,4 +8,8 @@ module RequestAwareEntity def request @options.fetch(:request) end + + def can?(object, action, subject) + Ability.allowed?(object, action, subject) + end end |