Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
494ae878
Commit
494ae878
authored
Dec 02, 2012
by
Riyad Preukschas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor discussion reply
parent
1319373d
Changes
26
Hide whitespace changes
Inline
Side-by-side
Showing
26 changed files
with
229 additions
and
183 deletions
+229
-183
app/assets/javascripts/notes.js
app/assets/javascripts/notes.js
+32
-28
app/assets/stylesheets/sections/notes.scss
app/assets/stylesheets/sections/notes.scss
+85
-81
app/controllers/commit_controller.rb
app/controllers/commit_controller.rb
+8
-4
app/controllers/issues_controller.rb
app/controllers/issues_controller.rb
+2
-0
app/controllers/merge_requests_controller.rb
app/controllers/merge_requests_controller.rb
+3
-0
app/controllers/notes_controller.rb
app/controllers/notes_controller.rb
+7
-7
app/controllers/projects_controller.rb
app/controllers/projects_controller.rb
+4
-1
app/controllers/snippets_controller.rb
app/controllers/snippets_controller.rb
+2
-0
app/helpers/notes_helper.rb
app/helpers/notes_helper.rb
+6
-1
app/views/commit/show.html.haml
app/views/commit/show.html.haml
+1
-1
app/views/issues/show.html.haml
app/views/issues/show.html.haml
+1
-1
app/views/merge_requests/_show.html.haml
app/views/merge_requests/_show.html.haml
+1
-1
app/views/merge_requests/show.js.haml
app/views/merge_requests/show.js.haml
+1
-1
app/views/notes/_common_form.html.haml
app/views/notes/_common_form.html.haml
+5
-2
app/views/notes/_create_discussion_note.js.haml
app/views/notes/_create_discussion_note.js.haml
+13
-0
app/views/notes/_diff_note_form.html.haml
app/views/notes/_diff_note_form.html.haml
+0
-26
app/views/notes/_diff_notes_with_reply.html.haml
app/views/notes/_diff_notes_with_reply.html.haml
+3
-12
app/views/notes/_discussion.html.haml
app/views/notes/_discussion.html.haml
+6
-4
app/views/notes/_discussion_diff.html.haml
app/views/notes/_discussion_diff.html.haml
+4
-3
app/views/notes/_discussion_note_form.html.haml
app/views/notes/_discussion_note_form.html.haml
+28
-0
app/views/notes/_discussion_reply_button.html.haml
app/views/notes/_discussion_reply_button.html.haml
+9
-0
app/views/notes/_notes_with_form.html.haml
app/views/notes/_notes_with_form.html.haml
+2
-4
app/views/notes/_reversed_notes_with_form.html.haml
app/views/notes/_reversed_notes_with_form.html.haml
+1
-1
app/views/notes/create.js.haml
app/views/notes/create.js.haml
+3
-3
app/views/projects/wall.html.haml
app/views/projects/wall.html.haml
+1
-1
app/views/snippets/show.html.haml
app/views/snippets/show.html.haml
+1
-1
No files found.
app/assets/javascripts/notes.js
View file @
494ae878
...
@@ -63,18 +63,19 @@ var NoteList = {
...
@@ -63,18 +63,19 @@ var NoteList = {
// reply to diff notes
// reply to diff notes
$
(
document
).
on
(
"
click
"
,
$
(
document
).
on
(
"
click
"
,
"
.js-di
ff-note
-reply-button
"
,
"
.js-di
scussion
-reply-button
"
,
NoteList
.
replyToDi
ff
Note
);
NoteList
.
replyToDi
scussion
Note
);
// hide diff note form
// hide diff note form
$
(
document
).
on
(
"
click
"
,
$
(
document
).
on
(
"
click
"
,
"
.js-
hide-diff
-note-form
"
,
"
.js-
close-discussion
-note-form
"
,
NoteList
.
removeDi
ff
NoteForm
);
NoteList
.
removeDi
scussion
NoteForm
);
// do some
diff note specific housekeeping when removing a diff
note
// do some
specific housekeeping when removing a diff or discussion
note
$
(
document
).
on
(
"
click
"
,
$
(
document
).
on
(
"
click
"
,
"
.diff_file .js-note-delete
"
,
"
.diff_file .js-note-delete,
"
+
NoteList
.
removeDiffNote
);
"
.discussion .js-note-delete
"
,
NoteList
.
removeDiscussionNote
);
// remove a note (in general)
// remove a note (in general)
$
(
document
).
on
(
"
click
"
,
$
(
document
).
on
(
"
click
"
,
...
@@ -102,14 +103,14 @@ var NoteList = {
...
@@ -102,14 +103,14 @@ var NoteList = {
*/
*/
addDiffNote
:
function
(
e
)
{
addDiffNote
:
function
(
e
)
{
// find the form
// find the form
var
form
=
$
(
"
.js-note-forms .js-di
ff
-note-form
"
);
var
form
=
$
(
"
.js-note-forms .js-di
scussion
-note-form
"
);
var
row
=
$
(
this
).
closest
(
"
tr
"
);
var
row
=
$
(
this
).
closest
(
"
tr
"
);
var
nextRow
=
row
.
next
();
var
nextRow
=
row
.
next
();
// does it already have notes?
// does it already have notes?
if
(
nextRow
.
is
(
"
.notes_holder
"
))
{
if
(
nextRow
.
is
(
"
.notes_holder
"
))
{
$
.
proxy
(
NoteList
.
replyToDi
ff
Note
,
$
.
proxy
(
NoteList
.
replyToDi
scussion
Note
,
nextRow
.
find
(
"
.js-di
ff-note
-reply-button
"
)
nextRow
.
find
(
"
.js-di
scussion
-reply-button
"
)
).
call
();
).
call
();
}
else
{
}
else
{
// add a notes row and insert the form
// add a notes row and insert the form
...
@@ -117,7 +118,7 @@ var NoteList = {
...
@@ -117,7 +118,7 @@ var NoteList = {
form
.
clone
().
appendTo
(
row
.
next
().
find
(
"
.notes_content
"
));
form
.
clone
().
appendTo
(
row
.
next
().
find
(
"
.notes_content
"
));
// show the form
// show the form
NoteList
.
setupDi
ff
NoteForm
(
$
(
this
),
row
.
next
().
find
(
"
form
"
));
NoteList
.
setupDi
scussion
NoteForm
(
$
(
this
),
row
.
next
().
find
(
"
form
"
));
}
}
e
.
preventDefault
();
e
.
preventDefault
();
...
@@ -131,11 +132,15 @@ var NoteList = {
...
@@ -131,11 +132,15 @@ var NoteList = {
*
*
* Note: must be called before removeNote()
* Note: must be called before removeNote()
*/
*/
removeDi
ff
Note
:
function
()
{
removeDi
scussion
Note
:
function
()
{
var
notes
=
$
(
this
).
closest
(
"
.notes
"
);
var
notes
=
$
(
this
).
closest
(
"
.notes
"
);
// check if this is the last note for this line
// check if this is the last note for this line
if
(
notes
.
find
(
"
.note
"
).
length
===
1
)
{
if
(
notes
.
find
(
"
.note
"
).
length
===
1
)
{
// for discussions
notes
.
closest
(
"
.discussion
"
).
remove
();
// for diff lines
notes
.
closest
(
"
tr
"
).
remove
();
notes
.
closest
(
"
tr
"
).
remove
();
}
}
},
},
...
@@ -146,15 +151,15 @@ var NoteList = {
...
@@ -146,15 +151,15 @@ var NoteList = {
* Shows the reply button again.
* Shows the reply button again.
* Removes the form and if necessary it's temporary row.
* Removes the form and if necessary it's temporary row.
*/
*/
removeDi
ff
NoteForm
:
function
(
e
)
{
removeDi
scussion
NoteForm
:
function
(
e
)
{
var
form
=
$
(
this
).
closest
(
"
form
"
);
var
form
=
$
(
this
).
closest
(
"
form
"
);
var
row
=
form
.
closest
(
"
tr
"
);
var
row
=
form
.
closest
(
"
tr
"
);
// show the reply button (will only work for replys)
// show the reply button (will only work for replys)
form
.
prev
(
"
.js-di
ff-note
-reply-button
"
).
show
();
form
.
prev
(
"
.js-di
scussion
-reply-button
"
).
show
();
if
(
row
.
is
(
"
.js-temp-notes-holder
"
))
{
if
(
row
.
is
(
"
.js-temp-notes-holder
"
))
{
// remove temporary row
// remove temporary row
for diff lines
row
.
remove
();
row
.
remove
();
}
else
{
}
else
{
// only remove the form
// only remove the form
...
@@ -179,10 +184,9 @@ var NoteList = {
...
@@ -179,10 +184,9 @@ var NoteList = {
*
*
* Shows the note form below the notes.
* Shows the note form below the notes.
*/
*/
replyToDi
ff
Note
:
function
()
{
replyToDi
scussion
Note
:
function
()
{
// find the form
// find the form
var
form
=
$
(
"
.js-note-forms .js-diff-note-form
"
);
var
form
=
$
(
"
.js-note-forms .js-discussion-note-form
"
);
// hide reply button
// hide reply button
$
(
this
).
hide
();
$
(
this
).
hide
();
...
@@ -190,7 +194,7 @@ var NoteList = {
...
@@ -190,7 +194,7 @@ var NoteList = {
form
.
clone
().
insertAfter
(
$
(
this
));
form
.
clone
().
insertAfter
(
$
(
this
));
// show the form
// show the form
NoteList
.
setupDi
ff
NoteForm
(
$
(
this
),
$
(
this
).
next
(
"
form
"
));
NoteList
.
setupDi
scussion
NoteForm
(
$
(
this
),
$
(
this
).
next
(
"
form
"
));
},
},
/**
/**
...
@@ -201,7 +205,7 @@ var NoteList = {
...
@@ -201,7 +205,7 @@ var NoteList = {
* Note: "this" must have the "discussionId", "lineCode", "noteableType" and
* Note: "this" must have the "discussionId", "lineCode", "noteableType" and
* "noteableId" data attributes set.
* "noteableId" data attributes set.
*/
*/
setupDi
ff
NoteForm
:
function
(
data_holder
,
form
)
{
setupDi
scussion
NoteForm
:
function
(
data_holder
,
form
)
{
// setup note target
// setup note target
form
.
attr
(
"
rel
"
,
data_holder
.
data
(
"
discussionId
"
));
form
.
attr
(
"
rel
"
,
data_holder
.
data
(
"
discussionId
"
));
form
.
find
(
"
#note_line_code
"
).
val
(
data_holder
.
data
(
"
lineCode
"
));
form
.
find
(
"
#note_line_code
"
).
val
(
data_holder
.
data
(
"
lineCode
"
));
...
@@ -210,10 +214,10 @@ var NoteList = {
...
@@ -210,10 +214,10 @@ var NoteList = {
// setup interaction
// setup interaction
disableButtonIfEmptyField
(
form
.
find
(
"
.js-note-text
"
),
form
.
find
(
"
.js-comment-button
"
));
disableButtonIfEmptyField
(
form
.
find
(
"
.js-note-text
"
),
form
.
find
(
"
.js-comment-button
"
));
setupGfmAutoComplete
();
GitLab
.
GfmAutoComplete
.
setup
();
// cleanup after successfully creating a diff note
// cleanup after successfully creating a diff note
form
.
on
(
"
ajax:success
"
,
NoteList
.
removeDi
ff
NoteForm
);
form
.
on
(
"
ajax:success
"
,
NoteList
.
removeDi
scussion
NoteForm
);
form
.
show
();
form
.
show
();
},
},
...
@@ -249,11 +253,11 @@ var NoteList = {
...
@@ -249,11 +253,11 @@ var NoteList = {
this
.
bottom_id
=
newNoteIds
.
last
();
this
.
bottom_id
=
newNoteIds
.
last
();
$
(
"
#notes-list
"
).
html
(
html
);
$
(
"
#notes-list
"
).
html
(
html
);
// init infinite scrolling
this
.
initLoadMore
();
// init getting new notes
if
(
this
.
reversed
)
{
if
(
this
.
reversed
)
{
// init infinite scrolling
this
.
initLoadMore
();
// init getting new notes
this
.
initRefreshNew
();
this
.
initRefreshNew
();
}
}
},
},
...
@@ -377,9 +381,9 @@ var NoteList = {
...
@@ -377,9 +381,9 @@ var NoteList = {
appendNewNote
:
appendNewNote
:
function
(
id
,
html
)
{
function
(
id
,
html
)
{
if
(
this
.
reversed
)
{
if
(
this
.
reversed
)
{
$
(
"
#n
ew-n
otes-list
"
).
prepend
(
html
);
$
(
"
#notes-list
"
).
prepend
(
html
);
}
else
{
}
else
{
$
(
"
#n
ew-n
otes-list
"
).
append
(
html
);
$
(
"
#notes-list
"
).
append
(
html
);
}
}
this
.
updateVotes
();
this
.
updateVotes
();
},
},
...
...
app/assets/stylesheets/sections/notes.scss
View file @
494ae878
...
@@ -46,9 +46,12 @@ ul.notes {
...
@@ -46,9 +46,12 @@ ul.notes {
@extend
.borders
;
@extend
.borders
;
background-color
:
#F9F9F9
;
background-color
:
#F9F9F9
;
}
}
.diff_file
.note
{
.diff_file
.notes
{
border-bottom
:
0px
;
/* reset */
padding
:
0px
;
background
:
inherit
;
border
:
none
;
@include
box-shadow
(
none
);
}
}
.discussion-hidden
.note
{
.discussion-hidden
.note
{
@extend
.cgray
;
@extend
.cgray
;
...
@@ -59,6 +62,9 @@ ul.notes {
...
@@ -59,6 +62,9 @@ ul.notes {
border-color
:
#ddd
;
border-color
:
#ddd
;
padding
:
8px
;
padding
:
8px
;
}
}
.reply-btn
{
margin-top
:
8px
;
}
}
}
}
}
...
@@ -92,7 +98,7 @@ ul.notes {
...
@@ -92,7 +98,7 @@ ul.notes {
}
}
}
}
.diff_file
tr
.notes_holder
{
.diff_file
.notes_holder
{
font-family
:
$sansFontFamily
;
font-family
:
$sansFontFamily
;
font-size
:
13px
;
font-size
:
13px
;
line-height
:
18px
;
line-height
:
18px
;
...
@@ -112,38 +118,9 @@ ul.notes {
...
@@ -112,38 +118,9 @@ ul.notes {
}
}
}
}
.
comment
-btn
{
.
reply
-btn
{
margin-top
:
8px
;
margin-top
:
8px
;
}
}
// TODO: start cleanup
form
{
// hide it by default
display
:
none
;
margin
:
8px
0
;
.note_actions
{
margin
:
0
;
padding-top
:
10px
;
.buttons
{
float
:left
;
width
:
300px
;
}
.options
{
.labels
{
float
:left
;
padding-left
:
10px
;
label
{
padding
:
6px
0
;
margin
:
0
;
width
:
120px
;
}
}
}
}
}
// TODO: end cleanup
}
}
/**
/**
...
@@ -185,6 +162,7 @@ ul.notes {
...
@@ -185,6 +162,7 @@ ul.notes {
top
:
0
;
top
:
0
;
}
}
// TODO: start cleaup
.issue_notes
,
.issue_notes
,
.wiki_notes
{
.wiki_notes
{
.note_content
{
.note_content
{
...
@@ -193,6 +171,7 @@ ul.notes {
...
@@ -193,6 +171,7 @@ ul.notes {
}
}
}
}
/* for loading indicator */
.notes-status
{
.notes-status
{
margin
:
18px
;
margin
:
18px
;
}
}
...
@@ -205,6 +184,7 @@ p.notify_controls input{
...
@@ -205,6 +184,7 @@ p.notify_controls input{
p
.notify_controls
span
{
p
.notify_controls
span
{
font-weight
:
700
;
font-weight
:
700
;
}
}
// TODO: end cleaup
/**
/**
* add line note button on the side of diffs
* add line note button on the side of diffs
...
@@ -242,56 +222,49 @@ p.notify_controls span{
...
@@ -242,56 +222,49 @@ p.notify_controls span{
* Note Forms
* Note Forms
*/
*/
.comment-btn
{
.comment-btn
,
.reply-btn
{
@extend
.save-btn
;
@extend
.save-btn
;
}
}
.new_discussion_note
{
// hide it by default
display
:
none
;
margin
:
8px
5px
8px
0
;
// TODO: start cleanup
.note_actions
{
margin
:
0
;
padding-top
:
10px
;
.buttons
{
float
:left
;
width
:
300px
;
}
.options
{
.labels
{
float
:left
;
padding-left
:
10px
;
label
{
padding
:
6px
0
;
margin
:
0
;
width
:
120px
;
}
}
}
}
// TODO: end cleanup
}
.new_note
{
.new_note
{
textarea
{
textarea
{
height
:
80px
;
height
:
80px
;
width
:
99%
;
width
:
99%
;
font-size
:
14px
;
font-size
:
14px
;
}
}
}
.note-forms
{
.new_diff_note
{
display
:
none
;
}
}
#new_note
{
// TODO: start cleanup
.attach_holder
{
.attach_holder
{
display
:none
;
display
:none
;
}
}
}
.preview_note
{
margin
:
2px
;
border
:
1px
solid
#ddd
;
padding
:
10px
;
min-height
:
60px
;
background
:
#f5f5f5
;
}
form
.new_note
{
.input-file
{
font
:
500px
monospace
;
opacity
:
0
;
filter
:
alpha
(
opacity
=
0
);
position
:
absolute
;
z-index
:
1
;
top
:
0
;
right
:
0
;
padding
:
0
;
margin
:
0
;
}
.note_advanced_opts
{
h6
{
line-height
:
32px
;
padding-right
:
15px
;
}
}
.attachments
{
.attachments
{
position
:
relative
;
position
:
relative
;
...
@@ -301,18 +274,17 @@ form.new_note {
...
@@ -301,18 +274,17 @@ form.new_note {
margin
:
0
0
5px
!
important
;
margin
:
0
0
5px
!
important
;
.input_file
{
.input_file
{
.file_upload
{
position
:
absolute
;
right
:
14px
;
top
:
7px
;
}
.file_name
{
.file_name
{
line-height
:
30px
;
line-height
:
30px
;
width
:
240px
;
width
:
240px
;
height
:
28px
;
height
:
28px
;
overflow
:
hidden
;
overflow
:
hidden
;
}
}
.file_upload
{
position
:
absolute
;
right
:
14px
;
top
:
7px
;
}
.input-file
{
.input-file
{
width
:
260px
;
width
:
260px
;
height
:
41px
;
height
:
41px
;
...
@@ -320,9 +292,41 @@ form.new_note {
...
@@ -320,9 +292,41 @@ form.new_note {
}
}
}
}
}
}
.input-file
{
font
:
500px
monospace
;
opacity
:
0
;
filter
:
alpha
(
opacity
=
0
);
position
:
absolute
;
z-index
:
1
;
top
:
0
;
right
:
0
;
padding
:
0
;
margin
:
0
;
}
.note_advanced_opts
{
h6
{
line-height
:
32px
;
padding-right
:
15px
;
}
}
.note-text
{
border
:
1px
solid
#aaa
;
box-shadow
:none
;
}
// TODO: end cleanup
}
// hide the new discussion note form template
.note-forms
{
.new_discussion_note
{
display
:
none
;
}
}
}
.note-text
{
.preview_note
{
border
:
1px
solid
#aaa
;
margin
:
2px
;
box-shadow
:
none
;
border
:
1px
solid
#ddd
;
padding
:
10px
;
min-height
:
60px
;
background
:
#f5f5f5
;
}
}
app/controllers/commit_controller.rb
View file @
494ae878
...
@@ -13,10 +13,14 @@ class CommitController < ProjectResourceController
...
@@ -13,10 +13,14 @@ class CommitController < ProjectResourceController
@commit
=
result
[
:commit
]
@commit
=
result
[
:commit
]
git_not_found!
unless
@commit
git_not_found!
unless
@commit
@suppress_diff
=
result
[
:suppress_diff
]
@suppress_diff
=
result
[
:suppress_diff
]
@note
=
result
[
:note
]
@line_notes
=
result
[
:line_notes
]
@note
=
result
[
:note
]
@notes_count
=
result
[
:notes_count
]
@line_notes
=
result
[
:line_notes
]
@notes_count
=
result
[
:notes_count
]
@target_type
=
:commit
@target_id
=
@commit
.
id
@comments_allowed
=
@reply_allowed
=
true
@comments_allowed
=
@reply_allowed
=
true
@comments_target
=
{
noteable_type:
'Commit'
,
@comments_target
=
{
noteable_type:
'Commit'
,
noteable_id:
@commit
.
id
}
noteable_id:
@commit
.
id
}
...
...
app/controllers/issues_controller.rb
View file @
494ae878
...
@@ -38,6 +38,8 @@ class IssuesController < ProjectResourceController
...
@@ -38,6 +38,8 @@ class IssuesController < ProjectResourceController
def
show
def
show
@note
=
@project
.
notes
.
new
(
noteable:
@issue
)
@note
=
@project
.
notes
.
new
(
noteable:
@issue
)
@target_type
=
:issue
@target_id
=
@issue
.
id
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
html
format
.
html
...
...
app/controllers/merge_requests_controller.rb
View file @
494ae878
...
@@ -21,6 +21,9 @@ class MergeRequestsController < ProjectResourceController
...
@@ -21,6 +21,9 @@ class MergeRequestsController < ProjectResourceController
end
end
def
show
def
show
@target_type
=
:merge_request
@target_id
=
@merge_request
.
id
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
html
format
.
html
format
.
js
format
.
js
...
...
app/controllers/notes_controller.rb
View file @
494ae878
...
@@ -6,13 +6,11 @@ class NotesController < ProjectResourceController
...
@@ -6,13 +6,11 @@ class NotesController < ProjectResourceController
respond_to
:js
respond_to
:js
def
index
def
index
@target_note
=
Note
.
new
(
noteable_type:
params
[
:target_type
].
camelize
,
noteable_id:
params
[
:target_id
])
@target
=
@target_note
.
noteable
@notes
=
Notes
::
LoadContext
.
new
(
project
,
current_user
,
params
).
execute
@notes
=
Notes
::
LoadContext
.
new
(
project
,
current_user
,
params
).
execute
@target_type
=
params
[
:target_type
].
camelize
@target_id
=
params
[
:target_id
]
if
params
[
:target_type
]
==
"merge_request"
if
params
[
:target_type
]
==
"merge_request"
@mixed_targets
=
true
@discussions
=
discussions_from_notes
@discussions
=
discussions_from_notes
end
end
...
@@ -21,6 +19,8 @@ class NotesController < ProjectResourceController
...
@@ -21,6 +19,8 @@ class NotesController < ProjectResourceController
def
create
def
create
@note
=
Notes
::
CreateContext
.
new
(
project
,
current_user
,
params
).
execute
@note
=
Notes
::
CreateContext
.
new
(
project
,
current_user
,
params
).
execute
@target_type
=
params
[
:target_type
].
camelize
@target_id
=
params
[
:target_id
]
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
html
{
redirect_to
:back
}
format
.
html
{
redirect_to
:back
}
...
@@ -58,7 +58,7 @@ class NotesController < ProjectResourceController
...
@@ -58,7 +58,7 @@ class NotesController < ProjectResourceController
next
if
discussion_ids
.
include?
(
note
.
discussion_id
)
next
if
discussion_ids
.
include?
(
note
.
discussion_id
)
# don't group notes for the main target
# don't group notes for the main target
if
for_main_target?
(
note
)
if
note_
for_main_target?
(
note
)
discussions
<<
[
note
]
discussions
<<
[
note
]
else
else
discussions
<<
discussion_notes_for
(
note
)
discussions
<<
discussion_notes_for
(
note
)
...
@@ -70,7 +70,7 @@ class NotesController < ProjectResourceController
...
@@ -70,7 +70,7 @@ class NotesController < ProjectResourceController
end
end
# Helps to distinguish e.g. commit notes in mr notes list
# Helps to distinguish e.g. commit notes in mr notes list
def
for_main_target?
(
note
)
def
note_
for_main_target?
(
note
)
!
@mixed_targets
||
(
@target
.
class
.
name
==
note
.
noteable_type
&&
!
note
.
for_diff_line?
)
@target_type
.
camelize
==
note
.
noteable_type
&&
!
note
.
for_diff_line?
end
end
end
end
app/controllers/projects_controller.rb
View file @
494ae878
...
@@ -75,7 +75,10 @@ class ProjectsController < ProjectResourceController
...
@@ -75,7 +75,10 @@ class ProjectsController < ProjectResourceController
def
wall
def
wall
return
render_404
unless
@project
.
wall_enabled
return
render_404
unless
@project
.
wall_enabled
@note
=
Note
.
new
@target_type
=
:wall
@target_id
=
nil
@note
=
@project
.
notes
.
new
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
html
format
.
html
...
...
app/controllers/snippets_controller.rb
View file @
494ae878
...
@@ -50,6 +50,8 @@ class SnippetsController < ProjectResourceController
...
@@ -50,6 +50,8 @@ class SnippetsController < ProjectResourceController
def
show
def
show
@note
=
@project
.
notes
.
new
(
noteable:
@snippet
)
@note
=
@project
.
notes
.
new
(
noteable:
@snippet
)
@target_type
=
:snippet
@target_id
=
@snippet
.
id
end
end
def
destroy
def
destroy
...
...
app/helpers/notes_helper.rb
View file @
494ae878
module
NotesHelper
module
NotesHelper
# Helps to distinguish e.g. commit notes in mr notes list
# Helps to distinguish e.g. commit notes in mr notes list
def
note_for_main_target?
(
note
)
def
note_for_main_target?
(
note
)
!
@mixed_targets
||
(
@target
.
class
.
name
==
note
.
noteable_type
&&
!
note
.
for_diff_line?
)
@target_type
.
camelize
==
note
.
noteable_type
&&
!
note
.
for_diff_line?
end
def
note_target_fields
hidden_field_tag
(
:target_type
,
@target_type
)
+
hidden_field_tag
(
:target_id
,
@target_id
)
end
end
def
link_to_commit_diff_line_note
(
note
)
def
link_to_commit_diff_line_note
(
note
)
...
...
app/views/commit/show.html.haml
View file @
494ae878
=
render
"commits/commit_box"
=
render
"commits/commit_box"
=
render
"commits/diffs"
,
diffs:
@commit
.
diffs
=
render
"commits/diffs"
,
diffs:
@commit
.
diffs
=
render
"notes/notes_with_form"
,
tid:
@commit
.
id
,
tt:
"commit"
=
render
"notes/notes_with_form"
:javascript
:javascript
$
(
function
(){
$
(
function
(){
...
...
app/views/issues/show.html.haml
View file @
494ae878
...
@@ -61,4 +61,4 @@
...
@@ -61,4 +61,4 @@
=
markdown
@issue
.
description
=
markdown
@issue
.
description
.issue_notes.voting_notes
#notes
=
render
"notes/notes_with_form"
,
tid:
@issue
.
id
,
tt:
"issue"
.issue_notes.voting_notes
#notes
=
render
"notes/notes_with_form"
app/views/merge_requests/_show.html.haml
View file @
494ae878
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
Diff
Diff
.merge_request_notes.voting_notes
#notes
{
class:
(
controller
.
action_name
==
'show'
)
?
""
:
"hide"
}
.merge_request_notes.voting_notes
#notes
{
class:
(
controller
.
action_name
==
'show'
)
?
""
:
"hide"
}
=
render
(
"notes/notes_with_form"
,
tid:
@merge_request
.
id
,
tt:
"merge_request"
)
=
render
"notes/notes_with_form"
.merge-request-diffs
.merge-request-diffs
=
render
"merge_requests/show/diffs"
if
@diffs
=
render
"merge_requests/show/diffs"
if
@diffs
.status
.status
...
...
app/views/merge_requests/show.js.haml
View file @
494ae878
:plain
:plain
$(".merge-request-notes").html("
#{
escape_javascript
(
render
notes
/
notes_with_form
"
, tid: @merge_request.id, tt: "
merge_request
"
)
}
");
$(".merge-request-notes").html("
#{
escape_javascript
(
render
notes
/
notes_with_form
")
}
");
app/views/notes/_common_form.html.haml
View file @
494ae878
.note-form-holder
.note-form-holder
=
form_for
[
@project
,
@note
],
remote:
"true"
,
multipart:
true
do
|
f
|
=
form_for
[
@project
,
@note
],
remote:
"true"
,
multipart:
true
do
|
f
|
=
note_target_fields
=
f
.
hidden_field
:noteable_id
=
f
.
hidden_field
:noteable_type
%h3
.page_title
Leave a comment
%h3
.page_title
Leave a comment
-
if
@note
.
errors
.
any?
-
if
@note
.
errors
.
any?
.alert-message.block-message.error
.alert-message.block-message.error
-
@note
.
errors
.
full_messages
.
each
do
|
msg
|
-
@note
.
errors
.
full_messages
.
each
do
|
msg
|
%div
=
msg
%div
=
msg
=
f
.
hidden_field
:noteable_id
=
f
.
hidden_field
:noteable_type
=
f
.
text_area
:note
,
size:
255
,
class:
'js-note-text js-gfm-input'
=
f
.
text_area
:note
,
size:
255
,
class:
'js-note-text js-gfm-input'
#preview-note
.preview_note.hide
#preview-note
.preview_note.hide
.hint
.hint
...
...
app/views/notes/_create_di
ff
_note.js.haml
→
app/views/notes/_create_di
scussion
_note.js.haml
View file @
494ae878
-
if
note
.
valid?
-
if
note
.
valid?
:plain
:plain
// hide and reset the form
// is this the first note of discussion?
var form = $("form[rel='
#{
note
.
discussion_id
}
']");
var row = $("form[rel='
#{
note
.
discussion_id
}
']").closest("tr");
var row = form.closest("tr");
// is this the first note?
if (row.is(".js-temp-notes-holder")) {
if (row.is(".js-temp-notes-holder")) {
// insert the note and the reply button after it
// insert the note and the reply button after it
row.after("
#{
escape_javascript
(
render
"notes/diff_notes_with_reply"
,
notes:
[
note
])
}
");
row.after("
#{
escape_javascript
(
render
"notes/diff_notes_with_reply"
,
notes:
[
note
])
}
");
} else {
// will be added again below
// instert new note before reply button
row.next().find(".note").remove();
row.find(".notes").append("
#{
escape_javascript
(
render
"notes/note"
,
note:
note
)
}
");
}
}
// append new note to all discussions
$(".notes[rel='
#{
note
.
discussion_id
}
']").append("
#{
escape_javascript
(
render
"notes/note"
,
note:
note
)
}
");
app/views/notes/_diff_note_form.html.haml
deleted
100644 → 0
View file @
1319373d
=
form_for
[
@project
,
@note
],
remote:
true
,
html:
{
multipart:
true
,
class:
"new_note new_diff_note js-diff-note-form"
}
do
|
f
|
.span10
-
if
@note
.
errors
.
any?
.alert-message.block-message.error
-
@note
.
errors
.
full_messages
.
each
do
|
msg
|
%div
=
msg
=
f
.
hidden_field
:noteable_id
=
f
.
hidden_field
:noteable_type
=
f
.
hidden_field
:line_code
=
f
.
text_area
:note
,
size:
255
,
class:
'js-note-text js-gfm-input'
.note_actions
.buttons
=
f
.
submit
'Add Comment'
,
class:
"btn save-btn js-comment-button"
%button
.btn.js-hide-diff-note-form
Cancel
.options
%h6
.left
Notify via email:
.labels
=
label_tag
:notify
do
=
check_box_tag
:notify
,
1
,
@note
.
noteable_type
!=
"Commit"
%span
Project team
-
if
@note
.
notify_only_author?
(
current_user
)
=
label_tag
:notify_author
do
=
check_box_tag
:notify_author
,
1
,
@note
.
noteable_type
==
"Commit"
%span
Commit author
app/views/notes/_diff_notes_with_reply.html.haml
View file @
494ae878
-
note
=
notes
.
first
# example note
-
note
=
notes
.
first
# example note
%tr
.notes_holder
{
data:
{
:'discussion-id'
=>
note
.
discussion_id
}
}
%tr
.notes_holder
%td
.notes_line
{
colspan:
2
}
%td
.notes_line
{
colspan:
2
}
%span
.btn.disabled
%span
.btn.disabled
%i
.icon-comment
%i
.icon-comment
=
notes
.
count
=
notes
.
count
%td
.notes_content
%td
.notes_content
%ul
.notes
%ul
.notes
{
rel:
note
.
discussion_id
}
=
render
notes
=
render
notes
-# reply button
=
render
"notes/discussion_reply_button"
,
note:
note
=
link_to
"javascript:;"
,
class:
"btn comment-btn js-diff-note-reply-button"
,
data:
{
noteable_type:
note
.
noteable_type
,
noteable_id:
note
.
noteable_id
,
line_code:
note
.
line_code
,
discussion_id:
note
.
discussion_id
},
title:
"Add a comment to this line"
do
%i
.icon-comment
Reply
app/views/notes/_discussion.html.haml
View file @
494ae878
...
@@ -30,11 +30,13 @@
...
@@ -30,11 +30,13 @@
ago
ago
.discussion-body
.discussion-body
-
if
note
.
for_diff_line?
-
if
note
.
for_diff_line?
.
diff_file.
content
.content
=
render
"notes/discussion_diff"
,
discussion_notes:
discussion_notes
,
note:
note
.diff_file
=
render
"notes/discussion_diff"
,
discussion_notes:
discussion_notes
,
note:
note
-
else
-
else
.notes.content
.content
=
render
discussion_notes
.notes
{
rel:
discussion_notes
.
first
.
discussion_id
}
=
render
discussion_notes
=
render
"notes/discussion_reply_button"
,
note:
discussion_notes
.
first
-# will be shown when the other one is hidden
-# will be shown when the other one is hidden
.discussion-hidden.content.hide
.discussion-hidden.content.hide
...
...
app/views/notes/_discussion_diff.html.haml
View file @
494ae878
-
diff
=
note
.
diff
-
diff
=
note
.
diff
.diff_file_header
.diff_file_header
%i
.icon-file
-
if
diff
.
deleted_file
-
if
diff
.
deleted_file
%span
{
id:
"#{diff.a_path}"
}=
diff
.
a
_path
%span
=
diff
.
old
_path
-
else
-
else
%span
{
id:
"#{diff.b_path}"
}=
diff
.
b_path
%span
=
diff
.
new_path
-
if
diff
.
a_mode
&&
diff
.
b_mode
&&
diff
.
a_mode
!=
diff
.
b_mode
%span
.file-mode
=
"
#{
diff
.
a_mode
}
→
#{
diff
.
b_mode
}
"
%br
/
%br
/
.diff_file_content
.diff_file_content
%table
%table
...
...
app/views/notes/_discussion_note_form.html.haml
0 → 100644
View file @
494ae878
=
form_for
[
@project
,
@note
],
remote:
true
,
html:
{
multipart:
true
,
class:
"new_note new_discussion_note js-discussion-note-form"
}
do
|
f
|
=
note_target_fields
=
f
.
hidden_field
:line_code
=
f
.
hidden_field
:noteable_id
=
f
.
hidden_field
:noteable_type
-
if
@note
.
errors
.
any?
.alert-message.block-message.error
-
@note
.
errors
.
full_messages
.
each
do
|
msg
|
%div
=
msg
=
f
.
text_area
:note
,
size:
255
,
class:
'js-note-text js-gfm-input'
.note_actions
.buttons
=
f
.
submit
'Add Comment'
,
class:
"btn comment-btn js-comment-button"
%button
.btn.js-close-discussion-note-form
Cancel
.options
%h6
.left
Notify via email:
.labels
=
label_tag
:notify
do
=
check_box_tag
:notify
,
1
,
@note
.
noteable_type
!=
"Commit"
%span
Project team
-
if
@note
.
notify_only_author?
(
current_user
)
=
label_tag
:notify_author
do
=
check_box_tag
:notify_author
,
1
,
@note
.
noteable_type
==
"Commit"
%span
Commit author
app/views/notes/_discussion_reply_button.html.haml
0 → 100644
View file @
494ae878
=
link_to
"javascript:;"
,
class:
"btn reply-btn js-discussion-reply-button"
,
data:
{
noteable_type:
note
.
noteable_type
,
noteable_id:
note
.
noteable_id
,
line_code:
note
.
line_code
,
discussion_id:
note
.
discussion_id
},
title:
"Add a reply"
do
%i
.icon-comment
Reply
app/views/notes/_notes_with_form.html.haml
View file @
494ae878
%ul
#notes-list
.notes
%ul
#notes-list
.notes
%ul
#new-notes-list
.notes
.notes-status
-
if
can?
current_user
,
:write_note
,
@project
-
if
can?
current_user
,
:write_note
,
@project
.note-forms.js-note-forms
.note-forms.js-note-forms
=
render
"notes/common_form"
=
render
"notes/common_form"
=
render
"notes/di
ff
_note_form"
=
render
"notes/di
scussion
_note_form"
:javascript
:javascript
$
(
function
(){
$
(
function
(){
NoteList
.
init
(
"
#{
tid
}
"
,
"
#{
tt
}
"
,
"
#{
project_notes_path
(
@project
)
}
"
);
NoteList
.
init
(
"
#{
@target_id
}
"
,
"
#{
@target_type
}
"
,
"
#{
project_notes_path
(
@project
)
}
"
);
});
});
app/views/notes/_reversed_notes_with_form.html.haml
View file @
494ae878
...
@@ -7,5 +7,5 @@
...
@@ -7,5 +7,5 @@
:javascript
:javascript
$
(
function
(){
$
(
function
(){
NoteList
.
init
(
"
#{
tid
}
"
,
"
#{
tt
}
"
,
"
#{
project_notes_path
(
@project
)
}
"
);
NoteList
.
init
(
"
#{
@target_id
}
"
,
"
#{
@target_type
}
"
,
"
#{
project_notes_path
(
@project
)
}
"
);
});
});
app/views/notes/create.js.haml
View file @
494ae878
-
if
@note
.
line_code
-
if
note_for_main_target?
(
@note
)
=
render
"create_diff_note"
,
note:
@note
-
else
=
render
"create_common_note"
,
note:
@note
=
render
"create_common_note"
,
note:
@note
-
else
=
render
"create_discussion_note"
,
note:
@note
app/views/projects/wall.html.haml
View file @
494ae878
%div
.wall_page
%div
.wall_page
=
render
"notes/reversed_notes_with_form"
,
tid:
nil
,
tt:
"wall"
=
render
"notes/reversed_notes_with_form"
app/views/snippets/show.html.haml
View file @
494ae878
...
@@ -8,4 +8,4 @@
...
@@ -8,4 +8,4 @@
%br
%br
%div
=
render
'blob'
%div
=
render
'blob'
%div
#notes
=
render
"notes/notes_with_form"
,
tid:
@snippet
.
id
,
tt:
"snippet"
%div
#notes
=
render
"notes/notes_with_form"
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment