summaryrefslogtreecommitdiff
path: root/app/serializers/tree_entity.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/serializers/tree_entity.rb')
-rw-r--r--app/serializers/tree_entity.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/app/serializers/tree_entity.rb b/app/serializers/tree_entity.rb
new file mode 100644
index 00000000000..555e5cf83bd
--- /dev/null
+++ b/app/serializers/tree_entity.rb
@@ -0,0 +1,17 @@
+class TreeEntity < Grape::Entity
+ include RequestAwareEntity
+
+ expose :id, :path, :name, :mode
+
+ expose :last_commit do |tree|
+ request.project.repository.last_commit_for_path(tree.commit_id, tree.path)
+ end
+
+ expose :icon do |tree|
+ IconsHelper.file_type_icon_class('folder', tree.mode, tree.name)
+ end
+
+ expose :url do |tree|
+ project_tree_path(request.project, File.join(request.ref, tree.path))
+ end
+end