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
Léo-Paul Géneau
gitlab-ce
Commits
f7e7dc7e
Commit
f7e7dc7e
authored
11 years ago
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make note anchors actually work
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
73af33e4
No related merge requests found
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
59 additions
and
66 deletions
+59
-66
app/assets/javascripts/notes.js
app/assets/javascripts/notes.js
+0
-3
app/controllers/projects/commit_controller.rb
app/controllers/projects/commit_controller.rb
+2
-1
app/controllers/projects/issues_controller.rb
app/controllers/projects/issues_controller.rb
+2
-1
app/controllers/projects/merge_requests_controller.rb
app/controllers/projects/merge_requests_controller.rb
+4
-3
app/controllers/projects/notes_controller.rb
app/controllers/projects/notes_controller.rb
+1
-33
app/controllers/projects/snippets_controller.rb
app/controllers/projects/snippets_controller.rb
+2
-1
app/models/note.rb
app/models/note.rb
+46
-23
app/views/projects/notes/_notes.html.haml
app/views/projects/notes/_notes.html.haml
+1
-1
app/views/projects/notes/_notes_with_form.html.haml
app/views/projects/notes/_notes_with_form.html.haml
+1
-0
No files found.
app/assets/javascripts/notes.js
View file @
f7e7dc7e
...
@@ -13,9 +13,6 @@ var NoteList = {
...
@@ -13,9 +13,6 @@ var NoteList = {
NoteList
.
setupMainTargetNoteForm
();
NoteList
.
setupMainTargetNoteForm
();
// get initial set of notes
NoteList
.
getContent
();
// Unbind events to prevent firing twice
// Unbind events to prevent firing twice
$
(
document
).
off
(
"
click
"
,
"
.js-add-diff-note-button
"
);
$
(
document
).
off
(
"
click
"
,
"
.js-add-diff-note-button
"
);
$
(
document
).
off
(
"
click
"
,
"
.js-discussion-reply-button
"
);
$
(
document
).
off
(
"
click
"
,
"
.js-discussion-reply-button
"
);
...
...
This diff is collapsed.
Click to expand it.
app/controllers/projects/commit_controller.rb
View file @
f7e7dc7e
...
@@ -24,7 +24,8 @@ class Projects::CommitController < Projects::ApplicationController
...
@@ -24,7 +24,8 @@ class Projects::CommitController < Projects::ApplicationController
@line_notes
=
result
[
:line_notes
]
@line_notes
=
result
[
:line_notes
]
@branches
=
result
[
:branches
]
@branches
=
result
[
:branches
]
@notes_count
=
result
[
:notes_count
]
@notes_count
=
result
[
:notes_count
]
@target_type
=
:commit
@target_type
=
"Commit"
@notes
=
project
.
notes
.
for_commit_id
(
@commit
.
id
).
not_inline
.
fresh
@target_id
=
@commit
.
id
@target_id
=
@commit
.
id
@comments_allowed
=
@reply_allowed
=
true
@comments_allowed
=
@reply_allowed
=
true
...
...
This diff is collapsed.
Click to expand it.
app/controllers/projects/issues_controller.rb
View file @
f7e7dc7e
...
@@ -49,7 +49,8 @@ class Projects::IssuesController < Projects::ApplicationController
...
@@ -49,7 +49,8 @@ class Projects::IssuesController < Projects::ApplicationController
def
show
def
show
@note
=
@project
.
notes
.
new
(
noteable:
@issue
)
@note
=
@project
.
notes
.
new
(
noteable:
@issue
)
@target_type
=
:issue
@notes
=
@issue
.
notes
.
inc_author
.
fresh
@target_type
=
'Issue'
@target_id
=
@issue
.
id
@target_id
=
@issue
.
id
respond_with
(
@issue
)
respond_with
(
@issue
)
...
...
This diff is collapsed.
Click to expand it.
app/controllers/projects/merge_requests_controller.rb
View file @
f7e7dc7e
...
@@ -198,6 +198,10 @@ class Projects::MergeRequestsController < Projects::ApplicationController
...
@@ -198,6 +198,10 @@ class Projects::MergeRequestsController < Projects::ApplicationController
def
define_show_vars
def
define_show_vars
# Build a note object for comment form
# Build a note object for comment form
@note
=
@project
.
notes
.
new
(
noteable:
@merge_request
)
@note
=
@project
.
notes
.
new
(
noteable:
@merge_request
)
@notes
=
@merge_request
.
mr_and_commit_notes
.
inc_author
.
fresh
@discussions
=
Note
.
discussions_from_notes
(
@notes
)
@target_type
=
'MergeRequest'
@target_id
=
@merge_request
.
id
# Get commits from repository
# Get commits from repository
# or from cache if already merged
# or from cache if already merged
...
@@ -205,9 +209,6 @@ class Projects::MergeRequestsController < Projects::ApplicationController
...
@@ -205,9 +209,6 @@ class Projects::MergeRequestsController < Projects::ApplicationController
@allowed_to_merge
=
allowed_to_merge?
@allowed_to_merge
=
allowed_to_merge?
@show_merge_controls
=
@merge_request
.
opened?
&&
@commits
.
any?
&&
@allowed_to_merge
@show_merge_controls
=
@merge_request
.
opened?
&&
@commits
.
any?
&&
@allowed_to_merge
@target_type
=
:merge_request
@target_id
=
@merge_request
.
id
end
end
def
allowed_to_merge?
def
allowed_to_merge?
...
...
This diff is collapsed.
Click to expand it.
app/controllers/projects/notes_controller.rb
View file @
f7e7dc7e
...
@@ -11,7 +11,7 @@ class Projects::NotesController < Projects::ApplicationController
...
@@ -11,7 +11,7 @@ class Projects::NotesController < Projects::ApplicationController
@target_id
=
params
[
:target_id
]
@target_id
=
params
[
:target_id
]
if
params
[
:target_type
]
==
"merge_request"
if
params
[
:target_type
]
==
"merge_request"
@discussions
=
discussions_from_notes
@discussions
=
Note
.
discussions_from_notes
(
@notes
)
end
end
respond_to
do
|
format
|
respond_to
do
|
format
|
...
@@ -76,36 +76,4 @@ class Projects::NotesController < Projects::ApplicationController
...
@@ -76,36 +76,4 @@ class Projects::NotesController < Projects::ApplicationController
def
preview
def
preview
render
text:
view_context
.
markdown
(
params
[
:note
])
render
text:
view_context
.
markdown
(
params
[
:note
])
end
end
protected
def
discussion_notes_for
(
note
)
@notes
.
select
do
|
other_note
|
note
.
discussion_id
==
other_note
.
discussion_id
end
end
def
discussions_from_notes
discussion_ids
=
[]
discussions
=
[]
@notes
.
each
do
|
note
|
next
if
discussion_ids
.
include?
(
note
.
discussion_id
)
# don't group notes for the main target
if
note_for_main_target?
(
note
)
discussions
<<
[
note
]
else
discussions
<<
discussion_notes_for
(
note
)
discussion_ids
<<
note
.
discussion_id
end
end
discussions
end
# Helps to distinguish e.g. commit notes in mr notes list
def
note_for_main_target?
(
note
)
(
@target_type
.
camelize
==
note
.
noteable_type
&&
!
note
.
for_diff_line?
)
end
end
end
This diff is collapsed.
Click to expand it.
app/controllers/projects/snippets_controller.rb
View file @
f7e7dc7e
...
@@ -48,7 +48,8 @@ class Projects::SnippetsController < Projects::ApplicationController
...
@@ -48,7 +48,8 @@ class Projects::SnippetsController < Projects::ApplicationController
def
show
def
show
@note
=
@project
.
notes
.
new
(
noteable:
@snippet
)
@note
=
@project
.
notes
.
new
(
noteable:
@snippet
)
@target_type
=
:snippet
@notes
=
@snippet
.
notes
.
fresh
@target_type
=
'Snippet'
@target_id
=
@snippet
.
id
@target_id
=
@snippet
.
id
end
end
...
...
This diff is collapsed.
Click to expand it.
app/models/note.rb
View file @
f7e7dc7e
...
@@ -56,29 +56,52 @@ class Note < ActiveRecord::Base
...
@@ -56,29 +56,52 @@ class Note < ActiveRecord::Base
serialize
:st_diff
serialize
:st_diff
before_create
:set_diff
,
if:
->
(
n
)
{
n
.
line_code
.
present?
}
before_create
:set_diff
,
if:
->
(
n
)
{
n
.
line_code
.
present?
}
def
self
.
create_status_change_note
(
noteable
,
project
,
author
,
status
,
source
)
class
<<
self
body
=
"_Status changed to
#{
status
}#{
' by '
+
source
.
gfm_reference
if
source
}
_"
def
create_status_change_note
(
noteable
,
project
,
author
,
status
,
source
)
body
=
"_Status changed to
#{
status
}#{
' by '
+
source
.
gfm_reference
if
source
}
_"
create
({
noteable:
noteable
,
create
({
project:
project
,
noteable:
noteable
,
author:
author
,
project:
project
,
note:
body
,
author:
author
,
system:
true
note:
body
,
},
without_protection:
true
)
system:
true
end
},
without_protection:
true
)
end
# +noteable+ was referenced from +mentioner+, by including GFM in either +mentioner+'s description or an associated Note.
# Create a system Note associated with +noteable+ with a GFM back-reference to +mentioner+.
def
create_cross_reference_note
(
noteable
,
mentioner
,
author
,
project
)
create
({
noteable:
noteable
,
commit_id:
(
noteable
.
sha
if
noteable
.
respond_to?
:sha
),
project:
project
,
author:
author
,
note:
"_mentioned in
#{
mentioner
.
gfm_reference
}
_"
,
system:
true
},
without_protection:
true
)
end
# +noteable+ was referenced from +mentioner+, by including GFM in either +mentioner+'s description or an associated Note.
def
discussions_from_notes
(
notes
)
# Create a system Note associated with +noteable+ with a GFM back-reference to +mentioner+.
discussion_ids
=
[]
def
self
.
create_cross_reference_note
(
noteable
,
mentioner
,
author
,
project
)
discussions
=
[]
create
({
noteable:
noteable
,
notes
.
each
do
|
note
|
commit_id:
(
noteable
.
sha
if
noteable
.
respond_to?
:sha
),
next
if
discussion_ids
.
include?
(
note
.
discussion_id
)
project:
project
,
author:
author
,
# don't group notes for the main target
note:
"_mentioned in
#{
mentioner
.
gfm_reference
}
_"
,
if
!
note
.
for_diff_line?
&&
note
.
noteable_type
==
"MergeRequest"
system:
true
discussions
<<
[
note
]
},
without_protection:
true
)
else
discussions
<<
notes
.
select
do
|
other_note
|
note
.
discussion_id
==
other_note
.
discussion_id
end
discussion_ids
<<
note
.
discussion_id
end
end
discussions
end
end
end
# Determine whether or not a cross-reference note already exists.
# Determine whether or not a cross-reference note already exists.
...
@@ -89,7 +112,7 @@ class Note < ActiveRecord::Base
...
@@ -89,7 +112,7 @@ class Note < ActiveRecord::Base
def
commit_author
def
commit_author
@commit_author
||=
@commit_author
||=
project
.
users
.
find_by_email
(
noteable
.
author_email
)
||
project
.
users
.
find_by_email
(
noteable
.
author_email
)
||
project
.
users
.
find_by_name
(
noteable
.
author_name
)
project
.
users
.
find_by_name
(
noteable
.
author_name
)
rescue
rescue
nil
nil
end
end
...
...
This diff is collapsed.
Click to expand it.
app/views/projects/notes/_notes.html.haml
View file @
f7e7dc7e
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
-
if
note_for_main_target?
(
note
)
-
if
note_for_main_target?
(
note
)
=
render
discussion_notes
=
render
discussion_notes
-
else
-
else
=
render
'discussion'
,
discussion_notes:
discussion_notes
=
render
'
projects/notes/
discussion'
,
discussion_notes:
discussion_notes
-
else
-
else
-
@notes
.
each
do
|
note
|
-
@notes
.
each
do
|
note
|
-
next
unless
note
.
author
-
next
unless
note
.
author
...
...
This diff is collapsed.
Click to expand it.
app/views/projects/notes/_notes_with_form.html.haml
View file @
f7e7dc7e
%ul
#notes-list
.notes
%ul
#notes-list
.notes
=
render
"projects/notes/notes"
.js-notes-busy
.js-notes-busy
.js-main-target-form
.js-main-target-form
...
...
This diff is collapsed.
Click to expand it.
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