diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2018-07-04 15:57:37 +0300 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2018-07-04 15:57:37 +0300 |
commit | 4d9a3f42f1fd3be21555e19872b7121cca65015e (patch) | |
tree | 9218831b49cb106165e01b41492981089a37de10 /lib/api | |
parent | ecf9c145f6e4d170cd059df88743393d9e63c489 (diff) | |
parent | 0d11c4a8c7f69278bdef812374e334ad11b1cd98 (diff) |
Merge branch 'ee-5481-epic-todos' into 'master'
Port of Todos for epics
See merge request gitlab-org/gitlab-ce!19908
Diffstat (limited to 'lib/api')
-rw-r--r-- | lib/api/entities.rb | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/api/entities.rb b/lib/api/entities.rb index d04f92885a3..930b5ef37a3 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -769,28 +769,33 @@ module API class Todo < Grape::Entity expose :id - expose :project, using: Entities::BasicProjectDetails + expose :project, using: Entities::ProjectIdentity, if: -> (todo, _) { todo.project_id } + expose :group, using: 'API::Entities::NamespaceBasic', if: -> (todo, _) { todo.group_id } expose :author, using: Entities::UserBasic expose :action_name expose :target_type expose :target do |todo, options| - Entities.const_get(todo.target_type).represent(todo.target, options) + todo_target_class(todo.target_type).represent(todo.target, options) end expose :target_url do |todo, options| target_type = todo.target_type.underscore - target_url = "namespace_project_#{target_type}_url" + target_url = "#{todo.parent.class.to_s.underscore}_#{target_type}_url" target_anchor = "note_#{todo.note_id}" if todo.note_id? Gitlab::Routing .url_helpers - .public_send(target_url, todo.project.namespace, todo.project, todo.target, anchor: target_anchor) # rubocop:disable GitlabSecurity/PublicSend + .public_send(target_url, todo.parent, todo.target, anchor: target_anchor) # rubocop:disable GitlabSecurity/PublicSend end expose :body expose :state expose :created_at + + def todo_target_class(target_type) + ::API::Entities.const_get(target_type) + end end class NamespaceBasic < Grape::Entity |