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
Boxiang Sun
gitlab-ce
Commits
2aef3b00
Commit
2aef3b00
authored
Jun 06, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor link to new diff note rendering
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
bc6a17a6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
6 deletions
+29
-6
app/helpers/notes_helper.rb
app/helpers/notes_helper.rb
+19
-0
app/models/note.rb
app/models/note.rb
+9
-5
app/views/projects/commits/_text_file.html.haml
app/views/projects/commits/_text_file.html.haml
+1
-1
No files found.
app/helpers/notes_helper.rb
View file @
2aef3b00
...
@@ -42,4 +42,23 @@ module NotesHelper
...
@@ -42,4 +42,23 @@ module NotesHelper
project_id:
noteable
.
project
.
id
,
project_id:
noteable
.
project
.
id
,
}.
to_json
}.
to_json
end
end
def
link_to_new_diff_note
(
line_code
)
discussion_id
=
Note
.
build_discussion_id
(
@comments_target
[
:noteable_type
],
@comments_target
[
:noteable_id
]
||
@comments_target
[
:commit_id
],
line_code
)
data
=
{
noteable_type:
@comments_target
[
:noteable_type
],
noteable_id:
@comments_target
[
:noteable_id
],
commit_id:
@comments_target
[
:commit_id
],
line_code:
line_code
,
discussion_id:
discussion_id
}
link_to
""
,
"javascript:;"
,
class:
"add-diff-note js-add-diff-note-button"
,
data:
data
,
title:
"Add a comment to this line"
end
end
end
app/models/note.rb
View file @
2aef3b00
...
@@ -122,11 +122,15 @@ class Note < ActiveRecord::Base
...
@@ -122,11 +122,15 @@ class Note < ActiveRecord::Base
discussions
discussions
end
end
end
# Determine whether or not a cross-reference note already exists.
def
build_discussion_id
(
type
,
id
,
line_code
)
def
self
.
cross_reference_exists?
(
noteable
,
mentioner
)
[
:discussion
,
type
.
try
(
:underscore
),
id
,
line_code
].
join
(
"-"
).
to_sym
where
(
noteable_id:
noteable
.
id
,
system:
true
,
note:
"_mentioned in
#{
mentioner
.
gfm_reference
}
_"
).
any?
end
# Determine whether or not a cross-reference note already exists.
def
cross_reference_exists?
(
noteable
,
mentioner
)
where
(
noteable_id:
noteable
.
id
,
system:
true
,
note:
"_mentioned in
#{
mentioner
.
gfm_reference
}
_"
).
any?
end
end
end
def
commit_author
def
commit_author
...
@@ -194,7 +198,7 @@ class Note < ActiveRecord::Base
...
@@ -194,7 +198,7 @@ class Note < ActiveRecord::Base
end
end
def
discussion_id
def
discussion_id
@discussion_id
||=
[
:discussion
,
noteable_type
.
try
(
:underscore
),
noteable_id
||
commit_id
,
line_code
].
join
(
"-"
).
to_sym
@discussion_id
||=
Note
.
build_discussion_id
(
noteable_type
,
noteable_id
||
commit_id
,
line_code
)
end
end
# Returns true if this is a downvote note,
# Returns true if this is a downvote note,
...
...
app/views/projects/commits/_text_file.html.haml
View file @
2aef3b00
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
%td
.old_line
%td
.old_line
=
link_to
raw
(
type
==
"new"
?
" "
:
line_old
),
"#
#{
line_code
}
"
,
id:
line_code
=
link_to
raw
(
type
==
"new"
?
" "
:
line_old
),
"#
#{
line_code
}
"
,
id:
line_code
-
if
@comments_allowed
-
if
@comments_allowed
=
render
"projects/notes/diff_note_link"
,
line_code:
line_code
=
link_to_new_diff_note
(
line_code
)
%td
.new_line
=
link_to
raw
(
type
==
"old"
?
" "
:
line_new
)
,
"#
#{
line_code
}
"
,
id:
line_code
%td
.new_line
=
link_to
raw
(
type
==
"old"
?
" "
:
line_new
)
,
"#
#{
line_code
}
"
,
id:
line_code
%td
.line_content
{
class:
"noteable_line #{type} #{line_code}"
,
"line_code"
=>
line_code
}=
raw
diff_line_content
(
line
)
%td
.line_content
{
class:
"noteable_line #{type} #{line_code}"
,
"line_code"
=>
line_code
}=
raw
diff_line_content
(
line
)
...
...
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