Commit 494ae87840bf719e5fb4094781cc1dfc179af463

Authored by Riyad Preukschas
1 parent 1319373d

Refactor discussion reply

app/assets/javascripts/notes.js
... ... @@ -63,18 +63,19 @@ var NoteList = {
63 63  
64 64 // reply to diff notes
65 65 $(document).on("click",
66   - ".js-diff-note-reply-button",
67   - NoteList.replyToDiffNote);
  66 + ".js-discussion-reply-button",
  67 + NoteList.replyToDiscussionNote);
68 68  
69 69 // hide diff note form
70 70 $(document).on("click",
71   - ".js-hide-diff-note-form",
72   - NoteList.removeDiffNoteForm);
  71 + ".js-close-discussion-note-form",
  72 + NoteList.removeDiscussionNoteForm);
73 73  
74   - // do some diff note specific housekeeping when removing a diff note
  74 + // do some specific housekeeping when removing a diff or discussion note
75 75 $(document).on("click",
76   - ".diff_file .js-note-delete",
77   - NoteList.removeDiffNote);
  76 + ".diff_file .js-note-delete," +
  77 + ".discussion .js-note-delete",
  78 + NoteList.removeDiscussionNote);
78 79  
79 80 // remove a note (in general)
80 81 $(document).on("click",
... ... @@ -102,14 +103,14 @@ var NoteList = {
102 103 */
103 104 addDiffNote: function(e) {
104 105 // find the form
105   - var form = $(".js-note-forms .js-diff-note-form");
  106 + var form = $(".js-note-forms .js-discussion-note-form");
106 107 var row = $(this).closest("tr");
107 108 var nextRow = row.next();
108 109  
109 110 // does it already have notes?
110 111 if (nextRow.is(".notes_holder")) {
111   - $.proxy(NoteList.replyToDiffNote,
112   - nextRow.find(".js-diff-note-reply-button")
  112 + $.proxy(NoteList.replyToDiscussionNote,
  113 + nextRow.find(".js-discussion-reply-button")
113 114 ).call();
114 115 } else {
115 116 // add a notes row and insert the form
... ... @@ -117,7 +118,7 @@ var NoteList = {
117 118 form.clone().appendTo(row.next().find(".notes_content"));
118 119  
119 120 // show the form
120   - NoteList.setupDiffNoteForm($(this), row.next().find("form"));
  121 + NoteList.setupDiscussionNoteForm($(this), row.next().find("form"));
121 122 }
122 123  
123 124 e.preventDefault();
... ... @@ -131,11 +132,15 @@ var NoteList = {
131 132 *
132 133 * Note: must be called before removeNote()
133 134 */
134   - removeDiffNote: function() {
  135 + removeDiscussionNote: function() {
135 136 var notes = $(this).closest(".notes");
136 137  
137 138 // check if this is the last note for this line
138 139 if (notes.find(".note").length === 1) {
  140 + // for discussions
  141 + notes.closest(".discussion").remove();
  142 +
  143 + // for diff lines
139 144 notes.closest("tr").remove();
140 145 }
141 146 },
... ... @@ -146,15 +151,15 @@ var NoteList = {
146 151 * Shows the reply button again.
147 152 * Removes the form and if necessary it's temporary row.
148 153 */
149   - removeDiffNoteForm: function(e) {
  154 + removeDiscussionNoteForm: function(e) {
150 155 var form = $(this).closest("form");
151 156 var row = form.closest("tr");
152 157  
153 158 // show the reply button (will only work for replys)
154   - form.prev(".js-diff-note-reply-button").show();
  159 + form.prev(".js-discussion-reply-button").show();
155 160  
156 161 if (row.is(".js-temp-notes-holder")) {
157   - // remove temporary row
  162 + // remove temporary row for diff lines
158 163 row.remove();
159 164 } else {
160 165 // only remove the form
... ... @@ -179,10 +184,9 @@ var NoteList = {
179 184 *
180 185 * Shows the note form below the notes.
181 186 */
182   - replyToDiffNote: function() {
  187 + replyToDiscussionNote: function() {
183 188 // find the form
184   - var form = $(".js-note-forms .js-diff-note-form");
185   -
  189 + var form = $(".js-note-forms .js-discussion-note-form");
186 190  
187 191 // hide reply button
188 192 $(this).hide();
... ... @@ -190,7 +194,7 @@ var NoteList = {
190 194 form.clone().insertAfter($(this));
191 195  
192 196 // show the form
193   - NoteList.setupDiffNoteForm($(this), $(this).next("form"));
  197 + NoteList.setupDiscussionNoteForm($(this), $(this).next("form"));
194 198 },
195 199  
196 200 /**
... ... @@ -201,7 +205,7 @@ var NoteList = {
201 205 * Note: "this" must have the "discussionId", "lineCode", "noteableType" and
202 206 * "noteableId" data attributes set.
203 207 */
204   - setupDiffNoteForm: function(data_holder, form) {
  208 + setupDiscussionNoteForm: function(data_holder, form) {
205 209 // setup note target
206 210 form.attr("rel", data_holder.data("discussionId"));
207 211 form.find("#note_line_code").val(data_holder.data("lineCode"));
... ... @@ -210,10 +214,10 @@ var NoteList = {
210 214  
211 215 // setup interaction
212 216 disableButtonIfEmptyField(form.find(".js-note-text"), form.find(".js-comment-button"));
213   - setupGfmAutoComplete();
  217 + GitLab.GfmAutoComplete.setup();
214 218  
215 219 // cleanup after successfully creating a diff note
216   - form.on("ajax:success", NoteList.removeDiffNoteForm);
  220 + form.on("ajax:success", NoteList.removeDiscussionNoteForm);
217 221  
218 222 form.show();
219 223 },
... ... @@ -249,11 +253,11 @@ var NoteList = {
249 253 this.bottom_id = newNoteIds.last();
250 254 $("#notes-list").html(html);
251 255  
252   - // init infinite scrolling
253   - this.initLoadMore();
254   -
255   - // init getting new notes
256 256 if (this.reversed) {
  257 + // init infinite scrolling
  258 + this.initLoadMore();
  259 +
  260 + // init getting new notes
257 261 this.initRefreshNew();
258 262 }
259 263 },
... ... @@ -377,9 +381,9 @@ var NoteList = {
377 381 appendNewNote:
378 382 function(id, html) {
379 383 if (this.reversed) {
380   - $("#new-notes-list").prepend(html);
  384 + $("#notes-list").prepend(html);
381 385 } else {
382   - $("#new-notes-list").append(html);
  386 + $("#notes-list").append(html);
383 387 }
384 388 this.updateVotes();
385 389 },
... ...
app/assets/stylesheets/sections/notes.scss
... ... @@ -46,9 +46,12 @@ ul.notes {
46 46 @extend .borders;
47 47 background-color: #F9F9F9;
48 48 }
49   - .diff_file .note {
50   - border-bottom: 0px;
51   - padding: 0px;
  49 + .diff_file .notes {
  50 + /* reset */
  51 + background: inherit;
  52 + border: none;
  53 + @include box-shadow(none);
  54 +
52 55 }
53 56 .discussion-hidden .note {
54 57 @extend .cgray;
... ... @@ -59,6 +62,9 @@ ul.notes {
59 62 border-color: #ddd;
60 63 padding: 8px;
61 64 }
  65 + .reply-btn {
  66 + margin-top: 8px;
  67 + }
62 68 }
63 69 }
64 70  
... ... @@ -92,7 +98,7 @@ ul.notes {
92 98 }
93 99 }
94 100  
95   -.diff_file tr.notes_holder {
  101 +.diff_file .notes_holder {
96 102 font-family: $sansFontFamily;
97 103 font-size: 13px;
98 104 line-height: 18px;
... ... @@ -112,38 +118,9 @@ ul.notes {
112 118 }
113 119 }
114 120  
115   - .comment-btn {
  121 + .reply-btn {
116 122 margin-top: 8px;
117 123 }
118   -
119   - // TODO: start cleanup
120   - form {
121   - // hide it by default
122   - display: none;
123   - margin: 8px 0;
124   -
125   - .note_actions {
126   - margin:0;
127   - padding-top: 10px;
128   -
129   - .buttons {
130   - float:left;
131   - width:300px;
132   - }
133   - .options {
134   - .labels {
135   - float:left;
136   - padding-left:10px;
137   - label {
138   - padding: 6px 0;
139   - margin: 0;
140   - width:120px;
141   - }
142   - }
143   - }
144   - }
145   - }
146   - // TODO: end cleanup
147 124 }
148 125  
149 126 /**
... ... @@ -185,6 +162,7 @@ ul.notes {
185 162 top: 0;
186 163 }
187 164  
  165 +// TODO: start cleaup
188 166 .issue_notes,
189 167 .wiki_notes {
190 168 .note_content {
... ... @@ -193,6 +171,7 @@ ul.notes {
193 171 }
194 172 }
195 173  
  174 +/* for loading indicator */
196 175 .notes-status {
197 176 margin: 18px;
198 177 }
... ... @@ -205,6 +184,7 @@ p.notify_controls input{
205 184 p.notify_controls span{
206 185 font-weight: 700;
207 186 }
  187 +// TODO: end cleaup
208 188  
209 189 /**
210 190 * add line note button on the side of diffs
... ... @@ -242,56 +222,49 @@ p.notify_controls span{
242 222 * Note Forms
243 223 */
244 224  
245   -.comment-btn {
  225 +.comment-btn,
  226 +.reply-btn {
246 227 @extend .save-btn;
247 228 }
  229 +.new_discussion_note {
  230 + // hide it by default
  231 + display: none;
  232 + margin: 8px 5px 8px 0;
  233 +
  234 + // TODO: start cleanup
  235 + .note_actions {
  236 + margin:0;
  237 + padding-top: 10px;
  238 +
  239 + .buttons {
  240 + float:left;
  241 + width:300px;
  242 + }
  243 + .options {
  244 + .labels {
  245 + float:left;
  246 + padding-left:10px;
  247 + label {
  248 + padding: 6px 0;
  249 + margin: 0;
  250 + width:120px;
  251 + }
  252 + }
  253 + }
  254 + }
  255 + // TODO: end cleanup
  256 +}
248 257 .new_note {
249 258 textarea {
250 259 height:80px;
251 260 width:99%;
252 261 font-size:14px;
253 262 }
254   -}
255   -.note-forms {
256   - .new_diff_note {
257   - display: none;
258   - }
259   -}
260   -
261 263  
262   -#new_note {
  264 + // TODO: start cleanup
263 265 .attach_holder {
264 266 display:none;
265 267 }
266   -}
267   -
268   -.preview_note {
269   - margin: 2px;
270   - border: 1px solid #ddd;
271   - padding: 10px;
272   - min-height: 60px;
273   - background:#f5f5f5;
274   -}
275   -
276   -form.new_note {
277   - .input-file {
278   - font: 500px monospace;
279   - opacity: 0;
280   - filter: alpha(opacity=0);
281   - position: absolute;
282   - z-index: 1;
283   - top: 0;
284   - right: 0;
285   - padding: 0;
286   - margin: 0;
287   - }
288   -
289   - .note_advanced_opts {
290   - h6 {
291   - line-height: 32px;
292   - padding-right: 15px;
293   - }
294   - }
295 268  
296 269 .attachments {
297 270 position: relative;
... ... @@ -301,18 +274,17 @@ form.new_note {
301 274 margin:0 0 5px !important;
302 275  
303 276 .input_file {
304   - .file_upload {
305   - position: absolute;
306   - right: 14px;
307   - top: 7px;
308   - }
309   -
310 277 .file_name {
311 278 line-height: 30px;
312 279 width: 240px;
313 280 height: 28px;
314 281 overflow: hidden;
315 282 }
  283 + .file_upload {
  284 + position: absolute;
  285 + right:14px;
  286 + top:7px;
  287 + }
316 288 .input-file {
317 289 width: 260px;
318 290 height: 41px;
... ... @@ -320,9 +292,41 @@ form.new_note {
320 292 }
321 293 }
322 294 }
  295 + .input-file {
  296 + font: 500px monospace;
  297 + opacity:0;
  298 + filter: alpha(opacity=0);
  299 + position: absolute;
  300 + z-index: 1;
  301 + top:0;
  302 + right:0;
  303 + padding:0;
  304 + margin: 0;
  305 + }
  306 + .note_advanced_opts {
  307 + h6 {
  308 + line-height: 32px;
  309 + padding-right: 15px;
  310 + }
  311 + }
  312 + .note-text {
  313 + border: 1px solid #aaa;
  314 + box-shadow:none;
  315 + }
  316 + // TODO: end cleanup
  317 +}
  318 +
  319 +// hide the new discussion note form template
  320 +.note-forms {
  321 + .new_discussion_note {
  322 + display: none;
  323 + }
323 324 }
324 325  
325   -.note-text {
326   - border: 1px solid #aaa;
327   - box-shadow: none;
  326 +.preview_note {
  327 + margin: 2px;
  328 + border: 1px solid #ddd;
  329 + padding: 10px;
  330 + min-height: 60px;
  331 + background:#f5f5f5;
328 332 }
... ...
app/controllers/commit_controller.rb
... ... @@ -13,10 +13,14 @@ class CommitController < ProjectResourceController
13 13 @commit = result[:commit]
14 14 git_not_found! unless @commit
15 15  
16   - @suppress_diff = result[:suppress_diff]
17   - @note = result[:note]
18   - @line_notes = result[:line_notes]
19   - @notes_count = result[:notes_count]
  16 + @suppress_diff = result[:suppress_diff]
  17 +
  18 + @note = result[:note]
  19 + @line_notes = result[:line_notes]
  20 + @notes_count = result[:notes_count]
  21 + @target_type = :commit
  22 + @target_id = @commit.id
  23 +
20 24 @comments_allowed = @reply_allowed = true
21 25 @comments_target = { noteable_type: 'Commit',
22 26 noteable_id: @commit.id }
... ...
app/controllers/issues_controller.rb
... ... @@ -38,6 +38,8 @@ class IssuesController < ProjectResourceController
38 38  
39 39 def show
40 40 @note = @project.notes.new(noteable: @issue)
  41 + @target_type = :issue
  42 + @target_id = @issue.id
41 43  
42 44 respond_to do |format|
43 45 format.html
... ...
app/controllers/merge_requests_controller.rb
... ... @@ -21,6 +21,9 @@ class MergeRequestsController < ProjectResourceController
21 21 end
22 22  
23 23 def show
  24 + @target_type = :merge_request
  25 + @target_id = @merge_request.id
  26 +
24 27 respond_to do |format|
25 28 format.html
26 29 format.js
... ...
app/controllers/notes_controller.rb
... ... @@ -6,13 +6,11 @@ class NotesController < ProjectResourceController
6 6 respond_to :js
7 7  
8 8 def index
9   - @target_note = Note.new(noteable_type: params[:target_type].camelize,
10   - noteable_id: params[:target_id])
11   - @target = @target_note.noteable
12 9 @notes = Notes::LoadContext.new(project, current_user, params).execute
  10 + @target_type = params[:target_type].camelize
  11 + @target_id = params[:target_id]
13 12  
14 13 if params[:target_type] == "merge_request"
15   - @mixed_targets = true
16 14 @discussions = discussions_from_notes
17 15 end
18 16  
... ... @@ -21,6 +19,8 @@ class NotesController < ProjectResourceController
21 19  
22 20 def create
23 21 @note = Notes::CreateContext.new(project, current_user, params).execute
  22 + @target_type = params[:target_type].camelize
  23 + @target_id = params[:target_id]
24 24  
25 25 respond_to do |format|
26 26 format.html {redirect_to :back}
... ... @@ -58,7 +58,7 @@ class NotesController < ProjectResourceController
58 58 next if discussion_ids.include?(note.discussion_id)
59 59  
60 60 # don't group notes for the main target
61   - if for_main_target?(note)
  61 + if note_for_main_target?(note)
62 62 discussions << [note]
63 63 else
64 64 discussions << discussion_notes_for(note)
... ... @@ -70,7 +70,7 @@ class NotesController &lt; ProjectResourceController
70 70 end
71 71  
72 72 # Helps to distinguish e.g. commit notes in mr notes list
73   - def for_main_target?(note)
74   - !@mixed_targets || (@target.class.name == note.noteable_type && !note.for_diff_line?)
  73 + def note_for_main_target?(note)
  74 + @target_type.camelize == note.noteable_type && !note.for_diff_line?
75 75 end
76 76 end
... ...
app/controllers/projects_controller.rb
... ... @@ -75,7 +75,10 @@ class ProjectsController &lt; ProjectResourceController
75 75  
76 76 def wall
77 77 return render_404 unless @project.wall_enabled
78   - @note = Note.new
  78 +
  79 + @target_type = :wall
  80 + @target_id = nil
  81 + @note = @project.notes.new
79 82  
80 83 respond_to do |format|
81 84 format.html
... ...
app/controllers/snippets_controller.rb
... ... @@ -50,6 +50,8 @@ class SnippetsController &lt; ProjectResourceController
50 50  
51 51 def show
52 52 @note = @project.notes.new(noteable: @snippet)
  53 + @target_type = :snippet
  54 + @target_id = @snippet.id
53 55 end
54 56  
55 57 def destroy
... ...
app/helpers/notes_helper.rb
1 1 module NotesHelper
2 2 # Helps to distinguish e.g. commit notes in mr notes list
3 3 def note_for_main_target?(note)
4   - !@mixed_targets || (@target.class.name == note.noteable_type && !note.for_diff_line?)
  4 + @target_type.camelize == note.noteable_type && !note.for_diff_line?
  5 + end
  6 +
  7 + def note_target_fields
  8 + hidden_field_tag(:target_type, @target_type) +
  9 + hidden_field_tag(:target_id, @target_id)
5 10 end
6 11  
7 12 def link_to_commit_diff_line_note(note)
... ...
app/views/commit/show.html.haml
1 1 = render "commits/commit_box"
2 2 = render "commits/diffs", diffs: @commit.diffs
3   -= render "notes/notes_with_form", tid: @commit.id, tt: "commit"
  3 += render "notes/notes_with_form"
4 4  
5 5 :javascript
6 6 $(function(){
... ...
app/views/issues/show.html.haml
... ... @@ -61,4 +61,4 @@
61 61 = markdown @issue.description
62 62  
63 63  
64   -.issue_notes.voting_notes#notes= render "notes/notes_with_form", tid: @issue.id, tt: "issue"
  64 +.issue_notes.voting_notes#notes= render "notes/notes_with_form"
... ...
app/views/merge_requests/_show.html.haml
... ... @@ -16,7 +16,7 @@
16 16 Diff
17 17  
18 18 .merge_request_notes.voting_notes#notes{ class: (controller.action_name == 'show') ? "" : "hide" }
19   - = render("notes/notes_with_form", tid: @merge_request.id, tt: "merge_request")
  19 + = render "notes/notes_with_form"
20 20 .merge-request-diffs
21 21 = render "merge_requests/show/diffs" if @diffs
22 22 .status
... ...
app/views/merge_requests/show.js.haml
1 1 :plain
2   - $(".merge-request-notes").html("#{escape_javascript(render notes/notes_with_form", tid: @merge_request.id, tt: "merge_request")}");
  2 + $(".merge-request-notes").html("#{escape_javascript(render notes/notes_with_form")}");
... ...
app/views/notes/_common_form.html.haml
1 1 .note-form-holder
2 2 = form_for [@project, @note], remote: "true", multipart: true do |f|
  3 +
  4 + = note_target_fields
  5 + = f.hidden_field :noteable_id
  6 + = f.hidden_field :noteable_type
  7 +
3 8 %h3.page_title Leave a comment
4 9 -if @note.errors.any?
5 10 .alert-message.block-message.error
6 11 - @note.errors.full_messages.each do |msg|
7 12 %div= msg
8 13  
9   - = f.hidden_field :noteable_id
10   - = f.hidden_field :noteable_type
11 14 = f.text_area :note, size: 255, class: 'js-note-text js-gfm-input'
12 15 #preview-note.preview_note.hide
13 16 .hint
... ...
app/views/notes/_create_diff_note.js.haml
... ... @@ -1,14 +0,0 @@
1   -- if note.valid?
2   - :plain
3   - // hide and reset the form
4   - var form = $("form[rel='#{note.discussion_id}']");
5   - var row = form.closest("tr");
6   -
7   - // is this the first note?
8   - if (row.is(".js-temp-notes-holder")) {
9   - // insert the note and the reply button after it
10   - row.after("#{escape_javascript(render "notes/diff_notes_with_reply", notes: [note])}");
11   - } else {
12   - // instert new note before reply button
13   - row.find(".notes").append("#{escape_javascript(render "notes/note", note: note)}");
14   - }
app/views/notes/_create_discussion_note.js.haml 0 → 100644
... ... @@ -0,0 +1,13 @@
  1 +- if note.valid?
  2 + :plain
  3 + // is this the first note of discussion?
  4 + var row = $("form[rel='#{note.discussion_id}']").closest("tr");
  5 + if (row.is(".js-temp-notes-holder")) {
  6 + // insert the note and the reply button after it
  7 + row.after("#{escape_javascript(render "notes/diff_notes_with_reply", notes: [note])}");
  8 + // will be added again below
  9 + row.next().find(".note").remove();
  10 + }
  11 +
  12 + // append new note to all discussions
  13 + $(".notes[rel='#{note.discussion_id}']").append("#{escape_javascript(render "notes/note", note: note)}");
... ...
app/views/notes/_diff_note_form.html.haml
... ... @@ -1,26 +0,0 @@
1   -= form_for [@project, @note], remote: true, html: { multipart: true, class: "new_note new_diff_note js-diff-note-form" } do |f|
2   - .span10
3   - -if @note.errors.any?
4   - .alert-message.block-message.error
5   - - @note.errors.full_messages.each do |msg|
6   - %div= msg
7   -
8   - = f.hidden_field :noteable_id
9   - = f.hidden_field :noteable_type
10   - = f.hidden_field :line_code
11   - = f.text_area :note, size: 255, class: 'js-note-text js-gfm-input'
12   - .note_actions
13   - .buttons
14   - = f.submit 'Add Comment', class: "btn save-btn js-comment-button"
15   - %button.btn.js-hide-diff-note-form Cancel
16   - .options
17   - %h6.left Notify via email:
18   - .labels
19   - = label_tag :notify do
20   - = check_box_tag :notify, 1, @note.noteable_type != "Commit"
21   - %span Project team
22   -
23   - - if @note.notify_only_author?(current_user)
24   - = label_tag :notify_author do
25   - = check_box_tag :notify_author, 1 , @note.noteable_type == "Commit"
26   - %span Commit author
app/views/notes/_diff_notes_with_reply.html.haml
1 1 - note = notes.first # example note
2   -%tr.notes_holder{ data: { :'discussion-id' => note.discussion_id } }
  2 +%tr.notes_holder
3 3 %td.notes_line{ colspan: 2 }
4 4 %span.btn.disabled
5 5 %i.icon-comment
6 6 = notes.count
7 7 %td.notes_content
8   - %ul.notes
  8 + %ul.notes{ rel: note.discussion_id }
9 9 = render notes
10 10  
11   - -# reply button
12   - = link_to "javascript:;",
13   - class: "btn comment-btn js-diff-note-reply-button",
14   - data: { noteable_type: note.noteable_type,
15   - noteable_id: note.noteable_id,
16   - line_code: note.line_code,
17   - discussion_id: note.discussion_id },
18   - title: "Add a comment to this line" do
19   - %i.icon-comment
20   - Reply
  11 + = render "notes/discussion_reply_button", note: note
... ...
app/views/notes/_discussion.html.haml
... ... @@ -30,11 +30,13 @@
30 30 ago
31 31 .discussion-body
32 32 - if note.for_diff_line?
33   - .diff_file.content
34   - = render "notes/discussion_diff", discussion_notes: discussion_notes, note: note
  33 + .content
  34 + .diff_file= render "notes/discussion_diff", discussion_notes: discussion_notes, note: note
35 35 - else
36   - .notes.content
37   - = render discussion_notes
  36 + .content
  37 + .notes{ rel: discussion_notes.first.discussion_id }
  38 + = render discussion_notes
  39 + = render "notes/discussion_reply_button", note: discussion_notes.first
38 40  
39 41 -# will be shown when the other one is hidden
40 42 .discussion-hidden.content.hide
... ...
app/views/notes/_discussion_diff.html.haml
1 1 - diff = note.diff
2 2 .diff_file_header
3   - %i.icon-file
4 3 - if diff.deleted_file
5   - %span{id: "#{diff.a_path}"}= diff.a_path
  4 + %span= diff.old_path
6 5 - else
7   - %span{id: "#{diff.b_path}"}= diff.b_path
  6 + %span= diff.new_path
  7 + - if diff.a_mode && diff.b_mode && diff.a_mode != diff.b_mode
  8 + %span.file-mode= "#{diff.a_mode} → #{diff.b_mode}"
8 9 %br/
9 10 .diff_file_content
10 11 %table
... ...
app/views/notes/_discussion_note_form.html.haml 0 → 100644
... ... @@ -0,0 +1,28 @@
  1 += form_for [@project, @note], remote: true, html: { multipart: true, class: "new_note new_discussion_note js-discussion-note-form" } do |f|
  2 +
  3 + = note_target_fields
  4 + = f.hidden_field :line_code
  5 + = f.hidden_field :noteable_id
  6 + = f.hidden_field :noteable_type
  7 +
  8 + -if @note.errors.any?
  9 + .alert-message.block-message.error
  10 + - @note.errors.full_messages.each do |msg|
  11 + %div= msg
  12 +
  13 + = f.text_area :note, size: 255, class: 'js-note-text js-gfm-input'
  14 + .note_actions
  15 + .buttons
  16 + = f.submit 'Add Comment', class: "btn comment-btn js-comment-button"
  17 + %button.btn.js-close-discussion-note-form Cancel
  18 + .options
  19 + %h6.left Notify via email:
  20 + .labels
  21 + = label_tag :notify do
  22 + = check_box_tag :notify, 1, @note.noteable_type != "Commit"
  23 + %span Project team
  24 +
  25 + - if @note.notify_only_author?(current_user)
  26 + = label_tag :notify_author do
  27 + = check_box_tag :notify_author, 1 , @note.noteable_type == "Commit"
  28 + %span Commit author
... ...
app/views/notes/_discussion_reply_button.html.haml 0 → 100644
... ... @@ -0,0 +1,9 @@
  1 += link_to "javascript:;",
  2 + class: "btn reply-btn js-discussion-reply-button",
  3 + data: { noteable_type: note.noteable_type,
  4 + noteable_id: note.noteable_id,
  5 + line_code: note.line_code,
  6 + discussion_id: note.discussion_id },
  7 + title: "Add a reply" do
  8 + %i.icon-comment
  9 + Reply
... ...
app/views/notes/_notes_with_form.html.haml
1 1 %ul#notes-list.notes
2   -%ul#new-notes-list.notes
3   -.notes-status
4 2  
5 3 - if can? current_user, :write_note, @project
6 4 .note-forms.js-note-forms
7 5 = render "notes/common_form"
8   - = render "notes/diff_note_form"
  6 + = render "notes/discussion_note_form"
9 7  
10 8 :javascript
11 9 $(function(){
12   - NoteList.init("#{tid}", "#{tt}", "#{project_notes_path(@project)}");
  10 + NoteList.init("#{@target_id}", "#{@target_type}", "#{project_notes_path(@project)}");
13 11 });
... ...
app/views/notes/_reversed_notes_with_form.html.haml
... ... @@ -7,5 +7,5 @@
7 7  
8 8 :javascript
9 9 $(function(){
10   - NoteList.init("#{tid}", "#{tt}", "#{project_notes_path(@project)}");
  10 + NoteList.init("#{@target_id}", "#{@target_type}", "#{project_notes_path(@project)}");
11 11 });
... ...
app/views/notes/create.js.haml
1   -- if @note.line_code
2   - = render "create_diff_note", note: @note
3   -- else
  1 +- if note_for_main_target?(@note)
4 2 = render "create_common_note", note: @note
  3 +- else
  4 + = render "create_discussion_note", note: @note
... ...
app/views/projects/wall.html.haml
1 1 %div.wall_page
2   - = render "notes/reversed_notes_with_form", tid: nil, tt: "wall"
  2 + = render "notes/reversed_notes_with_form"
... ...
app/views/snippets/show.html.haml
... ... @@ -8,4 +8,4 @@
8 8  
9 9 %br
10 10 %div= render 'blob'
11   -%div#notes= render "notes/notes_with_form", tid: @snippet.id, tt: "snippet"
  11 +%div#notes= render "notes/notes_with_form"
... ...