summaryrefslogtreecommitdiff
path: root/app/serializers
diff options
context:
space:
mode:
authorFilipa Lacerda <filipa@gitlab.com>2017-04-03 17:22:18 +0100
committerFilipa Lacerda <filipa@gitlab.com>2017-04-03 17:22:18 +0100
commit1b85c5a73fb4e7b466d3d871be7d7eb4b889b3ce (patch)
tree7fd8628974752a279cbe27c61983f8755d92cc51 /app/serializers
parent16cca3a0ea7f4b95e99d7b3e8d4953334fa7bec7 (diff)
parentb2700e64cce7c9b258e117a995eda8de00a8a988 (diff)
downloadgitlab-ce-1b85c5a73fb4e7b466d3d871be7d7eb4b889b3ce.tar.gz
Merge branch 'master' into tc-fix-unplayable-build-action-404
* master: (525 commits) Introduce "polling_interval_multiplier" as application setting fix spelling CI_REPOSITORY_URL (line:355) gitab-ci-token to gitlab-ci-token. Pass Gitaly Repository messages to workhorse Use gitaly 0.5.0 Fix specs Improve specs examples Minor refactor Fix BrachFormatter for removed users Changelog Fix specs One more change to the branch names to preserve metadata Prefixes source branch name with short SHA to avoid collision Fix GitHub importer for PRs of deleted forked repositories Change order of specs Clean history after every test that changes history Clean history state after each test Fixes method not replacing URL parameters correctly Fix a transient failure caused by FFaker Remove unnecessary ORDER BY clause when updating todos Add a wait_for_ajax call to ensure Todos page cleans up properly ...
Diffstat (limited to 'app/serializers')
-rw-r--r--app/serializers/build_entity.rb7
-rw-r--r--app/serializers/build_serializer.rb8
-rw-r--r--app/serializers/environment_entity.rb7
-rw-r--r--app/serializers/pipeline_entity.rb11
-rw-r--r--app/serializers/pipeline_serializer.rb7
-rw-r--r--app/serializers/status_entity.rb2
6 files changed, 35 insertions, 7 deletions
diff --git a/app/serializers/build_entity.rb b/app/serializers/build_entity.rb
index 2c116102888..b804d6d0e8a 100644
--- a/app/serializers/build_entity.rb
+++ b/app/serializers/build_entity.rb
@@ -19,10 +19,17 @@ class BuildEntity < Grape::Entity
expose :playable?, as: :playable
expose :created_at
expose :updated_at
+ expose :detailed_status, as: :status, with: StatusEntity
private
+ alias_method :build, :object
+
def path_to(route, build)
send("#{route}_path", build.project.namespace, build.project, build)
end
+
+ def detailed_status
+ build.detailed_status(request.user)
+ end
end
diff --git a/app/serializers/build_serializer.rb b/app/serializers/build_serializer.rb
new file mode 100644
index 00000000000..79b67001199
--- /dev/null
+++ b/app/serializers/build_serializer.rb
@@ -0,0 +1,8 @@
+class BuildSerializer < BaseSerializer
+ entity BuildEntity
+
+ def represent_status(resource)
+ data = represent(resource, { only: [:status] })
+ data.fetch(:status, {})
+ end
+end
diff --git a/app/serializers/environment_entity.rb b/app/serializers/environment_entity.rb
index 4c017960628..4ff15a78115 100644
--- a/app/serializers/environment_entity.rb
+++ b/app/serializers/environment_entity.rb
@@ -9,6 +9,13 @@ class EnvironmentEntity < Grape::Entity
expose :last_deployment, using: DeploymentEntity
expose :stop_action?
+ expose :metrics_path, if: -> (environment, _) { environment.has_metrics? } do |environment|
+ metrics_namespace_project_environment_path(
+ environment.project.namespace,
+ environment.project,
+ environment)
+ end
+
expose :environment_path do |environment|
namespace_project_environment_path(
environment.project.namespace,
diff --git a/app/serializers/pipeline_entity.rb b/app/serializers/pipeline_entity.rb
index 61f0f11d7d2..3f16dd66d54 100644
--- a/app/serializers/pipeline_entity.rb
+++ b/app/serializers/pipeline_entity.rb
@@ -12,12 +12,7 @@ class PipelineEntity < Grape::Entity
end
expose :details do
- expose :status do |pipeline, options|
- StatusEntity.represent(
- pipeline.detailed_status(request.user),
- options)
- end
-
+ expose :detailed_status, as: :status, with: StatusEntity
expose :duration
expose :finished_at
expose :stages, using: StageEntity
@@ -82,4 +77,8 @@ class PipelineEntity < Grape::Entity
pipeline.cancelable? &&
can?(request.user, :update_pipeline, pipeline)
end
+
+ def detailed_status
+ pipeline.detailed_status(request.user)
+ end
end
diff --git a/app/serializers/pipeline_serializer.rb b/app/serializers/pipeline_serializer.rb
index ab2d3d5a3ec..7829df9fada 100644
--- a/app/serializers/pipeline_serializer.rb
+++ b/app/serializers/pipeline_serializer.rb
@@ -22,4 +22,11 @@ class PipelineSerializer < BaseSerializer
super(resource, opts)
end
end
+
+ def represent_status(resource)
+ return {} unless resource.present?
+
+ data = represent(resource, { only: [{ details: [:status] }] })
+ data.dig(:details, :status) || {}
+ end
end
diff --git a/app/serializers/status_entity.rb b/app/serializers/status_entity.rb
index 47066bebfb1..dfd9d1584a1 100644
--- a/app/serializers/status_entity.rb
+++ b/app/serializers/status_entity.rb
@@ -1,7 +1,7 @@
class StatusEntity < Grape::Entity
include RequestAwareEntity
- expose :icon, :text, :label, :group
+ expose :icon, :favicon, :text, :label, :group
expose :has_details?, as: :has_details
expose :details_path