CE-specific changes to allow design Todos

CE-specific changes for:
https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/15129

Co-Authored-By:    Alex Kalderimis <akalderimis@gitlab.com>
Co-Authored-By:    Luke Duncalfe <lduncalfe@eml.cc>
This commit is contained in:
Luke Duncalfe 2019-08-14 13:34:42 +12:00
parent 7c9fb3c617
commit 88746f5311
3 changed files with 26 additions and 10 deletions

View File

@ -26,7 +26,7 @@ module TodosHelper
end end
def todo_target_link(todo) def todo_target_link(todo)
text = raw("#{todo.target_type.titleize.downcase} ") + text = raw(todo_target_type_name(todo) + ' ') +
if todo.for_commit? if todo.for_commit?
content_tag(:span, todo.target_reference, class: 'commit-sha') content_tag(:span, todo.target_reference, class: 'commit-sha')
else else
@ -36,23 +36,34 @@ module TodosHelper
link_to text, todo_target_path(todo), class: 'has-tooltip', title: todo.target.title link_to text, todo_target_path(todo), class: 'has-tooltip', title: todo.target.title
end end
def todo_target_type_name(todo)
todo.target_type.titleize.downcase
end
def todo_target_path(todo) def todo_target_path(todo)
return unless todo.target.present? return unless todo.target.present?
anchor = dom_id(todo.note) if todo.note.present? path_options = todo_target_path_options(todo)
if todo.for_commit? if todo.for_commit?
project_commit_path(todo.project, project_commit_path(todo.project, todo.target, path_options)
todo.target, anchor: anchor)
else else
path = [todo.parent, todo.target] path = [todo.parent, todo.target]
path.unshift(:pipelines) if todo.build_failed? path.unshift(:pipelines) if todo.build_failed?
polymorphic_path(path, anchor: anchor) polymorphic_path(path, path_options)
end end
end end
def todo_target_path_options(todo)
{ anchor: todo_target_path_anchor(todo) }
end
def todo_target_path_anchor(todo)
dom_id(todo.note) if todo.note.present?
end
def todo_target_state_pill(todo) def todo_target_state_pill(todo)
return unless show_todo_state?(todo) return unless show_todo_state?(todo)

View File

@ -505,7 +505,7 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
get :discussions, format: :json get :discussions, format: :json
Gitlab.ee do Gitlab.ee do
get 'designs(/*vueroute)', to: 'issues#show', format: false get 'designs(/*vueroute)', to: 'issues#show', as: :designs, format: false
end end
end end

View File

@ -13,6 +13,13 @@ module API
'issues' => ->(iid) { find_project_issue(iid) } 'issues' => ->(iid) { find_project_issue(iid) }
}.freeze }.freeze
helpers do
# EE::API::Todos would override this method
def find_todos
TodosFinder.new(current_user, params).execute
end
end
params do params do
requires :id, type: String, desc: 'The ID of a project' requires :id, type: String, desc: 'The ID of a project'
end end
@ -41,10 +48,6 @@ module API
resource :todos do resource :todos do
helpers do helpers do
def find_todos
TodosFinder.new(current_user, params).execute
end
def issuable_and_awardable?(type) def issuable_and_awardable?(type)
obj_type = Object.const_get(type) obj_type = Object.const_get(type)
@ -107,3 +110,5 @@ module API
end end
end end
end end
API::Todos.prepend_if_ee('EE::API::Todos')