diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2017-05-05 18:12:00 +0300 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2017-05-05 18:12:00 +0300 |
commit | d4733aa025099ba275f6be2ddddd49ececfbf301 (patch) | |
tree | ab04d008a02381a17bcbed78aaa361c5ec56d616 /app/views/shared/notes | |
parent | 672278ba0fd9b74ba649bd54cfba967c3b13eb46 (diff) | |
parent | e4f7b87ddb4ba83456871eb83b841192b1b56799 (diff) |
Merge branch '12910-personal-snippets-notes' into 'master'
Support comments for personal snippets
Closes #12910
See merge request !11090
Diffstat (limited to 'app/views/shared/notes')
-rw-r--r-- | app/views/shared/notes/_comment_button.html.haml | 30 | ||||
-rw-r--r-- | app/views/shared/notes/_edit.html.haml | 3 | ||||
-rw-r--r-- | app/views/shared/notes/_edit_form.html.haml | 14 | ||||
-rw-r--r-- | app/views/shared/notes/_form.html.haml | 40 | ||||
-rw-r--r-- | app/views/shared/notes/_hints.html.haml | 14 | ||||
-rw-r--r-- | app/views/shared/notes/_note.html.haml | 5 | ||||
-rw-r--r-- | app/views/shared/notes/_notes_with_form.html.haml | 26 |
7 files changed, 128 insertions, 4 deletions
diff --git a/app/views/shared/notes/_comment_button.html.haml b/app/views/shared/notes/_comment_button.html.haml new file mode 100644 index 00000000000..29cf5825292 --- /dev/null +++ b/app/views/shared/notes/_comment_button.html.haml @@ -0,0 +1,30 @@ +- noteable_name = @note.noteable.human_class_name + +.pull-left.btn-group.append-right-10.comment-type-dropdown.js-comment-type-dropdown + %input.btn.btn-nr.btn-create.comment-btn.js-comment-button.js-comment-submit-button{ type: 'submit', value: 'Comment' } + + - if @note.can_be_discussion_note? + = button_tag type: 'button', class: 'btn btn-nr dropdown-toggle comment-btn js-note-new-discussion js-disable-on-submit', data: { 'dropdown-trigger' => '#resolvable-comment-menu' }, 'aria-label' => 'Open comment type dropdown' do + = icon('caret-down', class: 'toggle-icon') + + %ul#resolvable-comment-menu.dropdown-menu{ data: { dropdown: true } } + %li#comment.droplab-item-selected{ data: { value: '', 'submit-text' => 'Comment', 'close-text' => "Comment & close #{noteable_name}", 'reopen-text' => "Comment & reopen #{noteable_name}" } } + %a{ href: '#' } + = icon('check') + .description + %strong Comment + %p + Add a general comment to this #{noteable_name}. + + %li.divider.droplab-item-ignore + + %li#discussion{ data: { value: 'DiscussionNote', 'submit-text' => 'Start discussion', 'close-text' => "Start discussion & close #{noteable_name}", 'reopen-text' => "Start discussion & reopen #{noteable_name}" } } + %a{ href: '#' } + = icon('check') + .description + %strong Start discussion + %p + = succeed '.' do + Discuss a specific suggestion or question + - if @note.noteable.supports_resolvable_notes? + that needs to be resolved diff --git a/app/views/shared/notes/_edit.html.haml b/app/views/shared/notes/_edit.html.haml new file mode 100644 index 00000000000..4a020865828 --- /dev/null +++ b/app/views/shared/notes/_edit.html.haml @@ -0,0 +1,3 @@ +.original-note-content.hidden{ data: { post_url: note_url(note), target_id: note.noteable.id, target_type: note.noteable.class.name.underscore } } + #{note.note} +%textarea.hidden.js-task-list-field.original-task-list{ data: {update_url: note_url(note) } }= note.note diff --git a/app/views/shared/notes/_edit_form.html.haml b/app/views/shared/notes/_edit_form.html.haml new file mode 100644 index 00000000000..8923e5602a4 --- /dev/null +++ b/app/views/shared/notes/_edit_form.html.haml @@ -0,0 +1,14 @@ +.note-edit-form + = form_tag '#', method: :put, class: 'edit-note common-note-form js-quick-submit' do + = hidden_field_tag :target_id, '', class: 'js-form-target-id' + = hidden_field_tag :target_type, '', class: 'js-form-target-type' + = render layout: 'projects/md_preview', locals: { url: preview_markdown_path(project), referenced_users: true } do + = render 'projects/zen', attr: 'note[note]', classes: 'note-textarea js-note-text js-task-list-field', placeholder: "Write a comment or drag your files here..." + = render 'shared/notes/hints' + + .note-form-actions.clearfix + .settings-message.note-edit-warning.js-finish-edit-warning + Finish editing this message first! + = submit_tag 'Save comment', class: 'btn btn-nr btn-save js-comment-save-button' + %button.btn.btn-nr.btn-cancel.note-edit-cancel{ type: 'button' } + Cancel diff --git a/app/views/shared/notes/_form.html.haml b/app/views/shared/notes/_form.html.haml new file mode 100644 index 00000000000..eaf50bc2115 --- /dev/null +++ b/app/views/shared/notes/_form.html.haml @@ -0,0 +1,40 @@ +- supports_slash_commands = note_supports_slash_commands?(@note) +- if supports_slash_commands + - preview_url = preview_markdown_path(@project, slash_commands_target_type: @note.noteable_type, slash_commands_target_id: @note.noteable_id) +- else + - preview_url = preview_markdown_path(@project) + += form_for form_resources, url: new_form_url, remote: true, html: { :'data-type' => 'json', multipart: true, id: nil, class: "new-note js-new-note-form js-quick-submit common-note-form", "data-noteable-iid" => @note.noteable.try(:iid), }, authenticity_token: true do |f| + = hidden_field_tag :view, diff_view + = hidden_field_tag :line_type + = hidden_field_tag :merge_request_diff_head_sha, @note.noteable.try(:diff_head_sha) + = hidden_field_tag :in_reply_to_discussion_id + + = note_target_fields(@note) + = f.hidden_field :noteable_type + = f.hidden_field :noteable_id + = f.hidden_field :commit_id + = f.hidden_field :type + + -# LegacyDiffNote + = f.hidden_field :line_code + + -# DiffNote + = f.hidden_field :position + + = render layout: 'projects/md_preview', locals: { url: preview_url, referenced_users: true } do + = render 'projects/zen', f: f, + attr: :note, + classes: 'note-textarea js-note-text', + placeholder: "Write a comment or drag your files here...", + supports_slash_commands: supports_slash_commands + = render 'shared/notes/hints', supports_slash_commands: supports_slash_commands + .error-alert + + .note-form-actions.clearfix + = render partial: 'shared/notes/comment_button' + + = yield(:note_actions) + + %a.btn.btn-cancel.js-note-discard{ role: "button", data: {cancel_text: "Cancel" } } + Discard draft diff --git a/app/views/shared/notes/_hints.html.haml b/app/views/shared/notes/_hints.html.haml new file mode 100644 index 00000000000..81d97eabe65 --- /dev/null +++ b/app/views/shared/notes/_hints.html.haml @@ -0,0 +1,14 @@ +- supports_slash_commands = local_assigns.fetch(:supports_slash_commands, false) +.comment-toolbar.clearfix + .toolbar-text + = link_to 'Markdown', help_page_path('user/markdown'), target: '_blank', tabindex: -1 + - if supports_slash_commands + and + = link_to 'slash commands', help_page_path('user/project/slash_commands'), target: '_blank', tabindex: -1 + are + - else + is + supported + %button.toolbar-button.markdown-selector{ type: 'button', tabindex: '-1' } + = icon('file-image-o', class: 'toolbar-button-icon') + Attach a file diff --git a/app/views/shared/notes/_note.html.haml b/app/views/shared/notes/_note.html.haml index 9657b4eea82..071c48fa2e4 100644 --- a/app/views/shared/notes/_note.html.haml +++ b/app/views/shared/notes/_note.html.haml @@ -42,10 +42,7 @@ = note.redacted_note_html = edited_time_ago_with_tooltip(note, placement: 'bottom', html_class: 'note_edited_ago', include_author: true) - if note_editable - - if note.for_personal_snippet? - = render 'snippets/notes/edit', note: note - - else - = render 'projects/notes/edit', note: note + = render 'shared/notes/edit', note: note .note-awards = render 'award_emoji/awards_block', awardable: note, inline: false - if note.system diff --git a/app/views/shared/notes/_notes_with_form.html.haml b/app/views/shared/notes/_notes_with_form.html.haml new file mode 100644 index 00000000000..9930cbd96d7 --- /dev/null +++ b/app/views/shared/notes/_notes_with_form.html.haml @@ -0,0 +1,26 @@ +%ul#notes-list.notes.main-notes-list.timeline + = render "shared/notes/notes" + += render 'shared/notes/edit_form', project: @project + +%ul.notes.notes-form.timeline + %li.timeline-entry + .flash-container.timeline-content + + - if can_create_note? + .timeline-icon.hidden-xs.hidden-sm + %a.author_link{ href: user_path(current_user) } + = image_tag avatar_icon(current_user), alt: current_user.to_reference, class: 'avatar s40' + .timeline-content.timeline-content-form + = render "shared/notes/form", view: diff_view + - elsif !current_user + .disabled-comment.text-center + .disabled-comment-text.inline + Please + = link_to "register", new_session_path(:user, redirect_to_referer: 'yes') + or + = link_to "sign in", new_session_path(:user, redirect_to_referer: 'yes') + to post a comment + +:javascript + var notes = new Notes("#{notes_url}", #{@notes.map(&:id).to_json}, #{Time.now.to_i}, "#{diff_view}") |