summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Kalderimis <alex.kalderimis@gmail.com>2019-08-13 18:43:23 +0100
committerAlex Kalderimis <alex.kalderimis@gmail.com>2019-08-14 12:26:20 +0100
commitd7e3b018fc7fb77da15e682448d5fd15b28bd149 (patch)
tree812eb64476e7bbb26751c66422665af9897665f1
parentfc99e540f19c8a18b5d11ae527a8c5486387c604 (diff)
downloadgitlab-ce-ce-13494-todo-s-not-rendering-when-there-is-a-design-management-related-todo.tar.gz
CE-specific changes for: https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/15129 This adds the incorrectly missed ee todos-helper to its correct position. Stage two is removing notes_helper prepend when we are sure it isn't needed. Also, allow EE models to configure their target type Also, allows public url to be model specific. Co-Authored-By: Alex Kalderimis <akalderimis@gitlab.com> Co-Authored-By: Luke Duncalfe <lduncalfe@eml.cc>
-rw-r--r--app/helpers/todos_helper.rb21
-rw-r--r--config/routes/project.rb2
-rw-r--r--lib/api/entities.rb16
3 files changed, 27 insertions, 12 deletions
diff --git a/app/helpers/todos_helper.rb b/app/helpers/todos_helper.rb
index 645160077f5..84579da9f94 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,28 @@ 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?
-
if todo.for_commit?
- project_commit_path(todo.project,
- todo.target, anchor: anchor)
+ project_commit_path(todo.project, todo.target, anchor: todo_target_path_anchor(todo))
else
path = [todo.parent, todo.target]
path.unshift(:pipelines) if todo.build_failed?
- polymorphic_path(path, anchor: anchor)
+ polymorphic_path(path, anchor: todo_target_path_anchor(todo))
end
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)
@@ -177,3 +182,7 @@ module TodosHelper
groups.unshift({ id: '', text: 'Any Group' }).to_json
end
end
+
+# For some reason the wrong module was prepended here.
+TodosHelper.prepend_if_ee('EE::NotesHelper') # rubocop: disable Cop/InjectEnterpriseEditionModule
+TodosHelper.prepend_if_ee('EE::TodosHelper')
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/entities.rb b/lib/api/entities.rb
index 09253ab6b0e..0af2870cb42 100644
--- a/lib/api/entities.rb
+++ b/lib/api/entities.rb
@@ -961,13 +961,19 @@ module API
end
expose :target_url do |todo, options|
- target_type = todo.target_type.underscore
- target_url = "#{todo.parent.class.to_s.underscore}_#{target_type}_url"
target_anchor = "note_#{todo.note_id}" if todo.note_id?
+ if !todo.target.present?
+ nil
+ elsif todo.target.respond_to?(:public_url) # TODO: extract to TodoTarget concern
+ todo.target.public_url(anchor: target_anchor)
+ else
+ target_type = todo.target_type.underscore
+ target_url = "#{todo.parent.class.to_s.underscore}_#{target_type}_url"
- Gitlab::Routing
- .url_helpers
- .public_send(target_url, todo.parent, todo.target, anchor: target_anchor) # rubocop:disable GitlabSecurity/PublicSend
+ Gitlab::Routing
+ .url_helpers
+ .public_send(target_url, todo.parent, todo.target, anchor: target_anchor) # rubocop:disable GitlabSecurity/PublicSend
+ end
end
expose :body