summaryrefslogtreecommitdiff
path: root/app/serializers/tree_entity.rb
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2017-05-26 13:51:24 -0500
committerDouwe Maan <douwe@selenight.nl>2017-05-26 13:51:24 -0500
commit2ae9c890e7037ec13b1882fda9ab90fc73f04fcc (patch)
tree1cb909e5ed6d9e3450d2d0e214d02a97981c97d2 /app/serializers/tree_entity.rb
parent33b622e353ba244ac62e61b6db0e382275ca905c (diff)
downloadgitlab-ce-2ae9c890e7037ec13b1882fda9ab90fc73f04fcc.tar.gz
Add experimental JSON format for tree controller
Diffstat (limited to 'app/serializers/tree_entity.rb')
-rw-r--r--app/serializers/tree_entity.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/app/serializers/tree_entity.rb b/app/serializers/tree_entity.rb
new file mode 100644
index 00000000000..e7d3dc38571
--- /dev/null
+++ b/app/serializers/tree_entity.rb
@@ -0,0 +1,13 @@
+class TreeEntity < Grape::Entity
+ include RequestAwareEntity
+
+ expose :id, :path, :name, :mode
+
+ expose :icon do |tree|
+ IconsHelper.file_type_icon_class('folder', tree.mode, tree.name)
+ end
+
+ expose :url do |tree|
+ namespace_project_tree_path(request.project.namespace, request.project, File.join(request.ref, tree.path))
+ end
+end