diff options
author | Ash McKenzie <amckenzie@gitlab.com> | 2019-08-15 08:58:41 +0000 |
---|---|---|
committer | Ash McKenzie <amckenzie@gitlab.com> | 2019-08-15 08:58:41 +0000 |
commit | 61635309b821c33bd5ec17c96484bf5cc0be51e7 (patch) | |
tree | 7a8f8420abdf51f65d739fb854c04b4db760f9f5 | |
parent | fe0ab065c4da9867683a013c1c22b1ff0a6d8273 (diff) | |
parent | 88746f5311a2624d99c3639daf2760c6715d5670 (diff) | |
download | gitlab-ce-61635309b821c33bd5ec17c96484bf5cc0be51e7.tar.gz |
Merge branch '13494-todo-s-not-rendering-when-there-is-a-design-management-related-todo-ce' into 'master'
CE backport of gitlab-org/gitlab-ee!15129 (Allow Todos to link to Designs)
See merge request gitlab-org/gitlab-ce!31789
-rw-r--r-- | app/helpers/todos_helper.rb | 21 | ||||
-rw-r--r-- | config/routes/project.rb | 2 | ||||
-rw-r--r-- | lib/api/todos.rb | 13 |
3 files changed, 26 insertions, 10 deletions
diff --git a/app/helpers/todos_helper.rb b/app/helpers/todos_helper.rb index 645160077f5..38142bc68cb 100644 --- a/app/helpers/todos_helper.rb +++ b/app/helpers/todos_helper.rb @@ -26,7 +26,7 @@ module TodosHelper end def todo_target_link(todo) - text = raw("#{todo.target_type.titleize.downcase} ") + + text = raw(todo_target_type_name(todo) + ' ') + if todo.for_commit? content_tag(:span, todo.target_reference, class: 'commit-sha') else @@ -36,23 +36,34 @@ module TodosHelper link_to text, todo_target_path(todo), class: 'has-tooltip', title: todo.target.title end + def todo_target_type_name(todo) + todo.target_type.titleize.downcase + end + def todo_target_path(todo) 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? - project_commit_path(todo.project, - todo.target, anchor: anchor) + project_commit_path(todo.project, todo.target, path_options) else path = [todo.parent, todo.target] path.unshift(:pipelines) if todo.build_failed? - polymorphic_path(path, anchor: anchor) + polymorphic_path(path, path_options) 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) return unless show_todo_state?(todo) diff --git a/config/routes/project.rb b/config/routes/project.rb index b9258a35f0c..a207ee44d47 100644 --- a/config/routes/project.rb +++ b/config/routes/project.rb @@ -505,7 +505,7 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do get :discussions, format: :json Gitlab.ee do - get 'designs(/*vueroute)', to: 'issues#show', format: false + get 'designs(/*vueroute)', to: 'issues#show', as: :designs, format: false end end diff --git a/lib/api/todos.rb b/lib/api/todos.rb index 7260ecfb5ee..404675bfaec 100644 --- a/lib/api/todos.rb +++ b/lib/api/todos.rb @@ -13,6 +13,13 @@ module API 'issues' => ->(iid) { find_project_issue(iid) } }.freeze + helpers do + # EE::API::Todos would override this method + def find_todos + TodosFinder.new(current_user, params).execute + end + end + params do requires :id, type: String, desc: 'The ID of a project' end @@ -41,10 +48,6 @@ module API resource :todos do helpers do - def find_todos - TodosFinder.new(current_user, params).execute - end - def issuable_and_awardable?(type) obj_type = Object.const_get(type) @@ -107,3 +110,5 @@ module API end end end + +API::Todos.prepend_if_ee('EE::API::Todos') |