summaryrefslogtreecommitdiff
path: root/app/serializers
diff options
context:
space:
mode:
authorZeger-Jan van de Weg <zegerjan@gitlab.com>2017-05-06 16:45:46 +0000
committerKamil TrzciƄski <ayufan@ayufan.eu>2017-05-06 16:45:46 +0000
commitc17e6a6c68b0412b3433632802b852db474a7b30 (patch)
treea7e6b1ec2e0e5f691aa6fd7585f5b63a15131114 /app/serializers
parent1186dcabbfb8e885351c1ef05d4583fd474732e9 (diff)
downloadgitlab-ce-c17e6a6c68b0412b3433632802b852db474a7b30.tar.gz
Real time pipeline show action
Diffstat (limited to 'app/serializers')
-rw-r--r--app/serializers/job_group_entity.rb16
-rw-r--r--app/serializers/stage_entity.rb8
-rw-r--r--app/serializers/status_entity.rb7
3 files changed, 28 insertions, 3 deletions
diff --git a/app/serializers/job_group_entity.rb b/app/serializers/job_group_entity.rb
new file mode 100644
index 00000000000..a4d3737429c
--- /dev/null
+++ b/app/serializers/job_group_entity.rb
@@ -0,0 +1,16 @@
+class JobGroupEntity < Grape::Entity
+ include RequestAwareEntity
+
+ expose :name
+ expose :size
+ expose :detailed_status, as: :status, with: StatusEntity
+ expose :jobs, with: BuildEntity
+
+ private
+
+ alias_method :group, :object
+
+ def detailed_status
+ group.detailed_status(request.user)
+ end
+end
diff --git a/app/serializers/stage_entity.rb b/app/serializers/stage_entity.rb
index 7a047bdc712..97ced8730ed 100644
--- a/app/serializers/stage_entity.rb
+++ b/app/serializers/stage_entity.rb
@@ -7,9 +7,11 @@ class StageEntity < Grape::Entity
"#{stage.name}: #{detailed_status.label}"
end
- expose :detailed_status,
- as: :status,
- with: StatusEntity
+ expose :groups,
+ if: -> (_, opts) { opts[:grouped] },
+ with: JobGroupEntity
+
+ expose :detailed_status, as: :status, with: StatusEntity
expose :path do |stage|
namespace_project_pipeline_path(
diff --git a/app/serializers/status_entity.rb b/app/serializers/status_entity.rb
index 188c3747f18..3e40ecf1c1c 100644
--- a/app/serializers/status_entity.rb
+++ b/app/serializers/status_entity.rb
@@ -12,4 +12,11 @@ class StatusEntity < Grape::Entity
ActionController::Base.helpers.image_path(File.join(dir, "#{status.favicon}.ico"))
end
+
+ expose :action, if: -> (status, _) { status.has_action? } do
+ expose :action_icon, as: :icon
+ expose :action_title, as: :title
+ expose :action_path, as: :path
+ expose :action_method, as: :method
+ end
end