diff options
author | Jarka Kadlecova <jarka@gitlab.com> | 2017-05-03 10:48:01 +0200 |
---|---|---|
committer | Jarka Kadlecova <jarka@gitlab.com> | 2017-05-05 15:45:49 +0200 |
commit | e4f7b87ddb4ba83456871eb83b841192b1b56799 (patch) | |
tree | cf79d159784d2c5573acf8a56a8ea09bccaf2d81 /app/helpers | |
parent | 729c006ff82fcb87afe8eb3e6a21254892f43afd (diff) | |
download | gitlab-ce-e4f7b87ddb4ba83456871eb83b841192b1b56799.tar.gz |
Support comments for personal snippets
Diffstat (limited to 'app/helpers')
-rw-r--r-- | app/helpers/gitlab_routing_helper.rb | 6 | ||||
-rw-r--r-- | app/helpers/notes_helper.rb | 43 |
2 files changed, 48 insertions, 1 deletions
diff --git a/app/helpers/gitlab_routing_helper.rb b/app/helpers/gitlab_routing_helper.rb index 88f9a691a17..3769830de2a 100644 --- a/app/helpers/gitlab_routing_helper.rb +++ b/app/helpers/gitlab_routing_helper.rb @@ -123,7 +123,11 @@ module GitlabRoutingHelper end def preview_markdown_path(project, *args) - preview_markdown_namespace_project_path(project.namespace, project, *args) + if @snippet.is_a?(PersonalSnippet) + preview_markdown_snippet_path(@snippet) + else + preview_markdown_namespace_project_path(project.namespace, project, *args) + end end def toggle_subscription_path(entity, *args) diff --git a/app/helpers/notes_helper.rb b/app/helpers/notes_helper.rb index 08180883eb9..52403640c05 100644 --- a/app/helpers/notes_helper.rb +++ b/app/helpers/notes_helper.rb @@ -76,4 +76,47 @@ module NotesHelper namespace_project_commit_path(discussion.project.namespace, discussion.project, discussion.noteable, anchor: anchor) end end + + def notes_url + if @snippet.is_a?(PersonalSnippet) + snippet_notes_path(@snippet) + else + namespace_project_noteable_notes_path( + namespace_id: @project.namespace, + project_id: @project, + target_id: @noteable.id, + target_type: @noteable.class.name.underscore + ) + end + end + + def note_url(note) + if note.noteable.is_a?(PersonalSnippet) + snippet_note_path(note.noteable, note) + else + namespace_project_note_path(@project.namespace, @project, note) + end + end + + def form_resources + if @snippet.is_a?(PersonalSnippet) + [@note] + else + [@project.namespace.becomes(Namespace), @project, @note] + end + end + + def new_form_url + return nil unless @snippet.is_a?(PersonalSnippet) + + snippet_notes_path(@snippet) + end + + def can_create_note? + if @snippet.is_a?(PersonalSnippet) + can?(current_user, :comment_personal_snippet, @snippet) + else + can?(current_user, :create_note, @project) + end + end end |