summaryrefslogtreecommitdiff
path: root/lib/api/entities.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/api/entities.rb')
-rw-r--r--lib/api/entities.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/api/entities.rb b/lib/api/entities.rb
index 4e2a43e45e2..171a5da6420 100644
--- a/lib/api/entities.rb
+++ b/lib/api/entities.rb
@@ -56,6 +56,10 @@ module API
expose :id
expose :name, :name_with_namespace
expose :path, :path_with_namespace
+
+ expose :web_url do |project, options|
+ Gitlab::Application.routes.url_helpers.namespace_project_url(project.namespace, project)
+ end
end
class Project < Grape::Entity
@@ -272,6 +276,31 @@ module API
expose :id, :project_id, :group_id, :group_access
end
+ class Todo < Grape::Entity
+ expose :id
+ expose :project, using: Entities::BasicProjectDetails
+ expose :author, using: Entities::UserBasic
+ expose :action_name
+ expose :target_id
+ expose :target_type
+ expose :target_reference do |todo, options|
+ todo.target.to_reference
+ end
+
+ expose :target_url do |todo, options|
+ target_type = todo.target_type.underscore
+ target_url = "namespace_project_#{target_type}_url"
+ target_anchor = "note_#{todo.note_id}" if todo.note.present?
+
+ Gitlab::Application.routes.url_helpers.public_send(target_url,
+ todo.project.namespace, todo.project, todo.target, anchor: target_anchor)
+ end
+
+ expose :body
+ expose :state
+ expose :created_at
+ end
+
class Namespace < Grape::Entity
expose :id, :path, :kind
end