change logic on line_code
This commit is contained in:
parent
bda7fe38d0
commit
f598cc7897
9 changed files with 54 additions and 21 deletions
|
@ -71,6 +71,10 @@ var NoteList = {
|
||||||
$(document).on("click",
|
$(document).on("click",
|
||||||
".js-choose-note-attachment-button",
|
".js-choose-note-attachment-button",
|
||||||
NoteList.chooseNoteAttachment);
|
NoteList.chooseNoteAttachment);
|
||||||
|
|
||||||
|
$(document).on("click",
|
||||||
|
".js-show-outdated-discussion",
|
||||||
|
function(e) { $(this).next('.outdated-discussion').show(); e.preventDefault() });
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,7 @@ ul.notes {
|
||||||
margin-top: 3px;
|
margin-top: 3px;
|
||||||
}
|
}
|
||||||
.attachment {
|
.attachment {
|
||||||
font-size: 16px;
|
font-size: 14px;
|
||||||
margin-top: -20px;
|
margin-top: -20px;
|
||||||
|
|
||||||
.icon-attachment {
|
.icon-attachment {
|
||||||
|
@ -92,7 +92,6 @@ ul.notes {
|
||||||
}
|
}
|
||||||
.note-body {
|
.note-body {
|
||||||
margin-left: 45px;
|
margin-left: 45px;
|
||||||
padding-top: 5px;
|
|
||||||
}
|
}
|
||||||
.note-header {
|
.note-header {
|
||||||
padding-bottom: 5px;
|
padding-bottom: 5px;
|
||||||
|
@ -284,7 +283,7 @@ ul.notes {
|
||||||
font-size: 24px;
|
font-size: 24px;
|
||||||
padding: 4px;
|
padding: 4px;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: 0;
|
right: 10px;
|
||||||
}
|
}
|
||||||
.note_preview {
|
.note_preview {
|
||||||
background: #f5f5f5;
|
background: #f5f5f5;
|
||||||
|
@ -307,3 +306,9 @@ ul.notes {
|
||||||
.notes-busy {
|
.notes-busy {
|
||||||
margin: 18px;
|
margin: 18px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.note-image-attach {
|
||||||
|
@extend .span4;
|
||||||
|
@extend .thumbnail;
|
||||||
|
margin-left: 45px;
|
||||||
|
}
|
||||||
|
|
|
@ -9,11 +9,13 @@ module CommitsHelper
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def build_line_anchor(index, line_new, line_old)
|
def build_line_anchor(diff, line_new, line_old)
|
||||||
"#{index}_#{line_old}_#{line_new}"
|
"#{hexdigest(diff.new_path)}_#{line_old}_#{line_new}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def each_diff_line(diff_arr, index)
|
def each_diff_line(diff, index)
|
||||||
|
diff_arr = diff.diff.lines.to_a
|
||||||
|
|
||||||
line_old = 1
|
line_old = 1
|
||||||
line_new = 1
|
line_new = 1
|
||||||
type = nil
|
type = nil
|
||||||
|
@ -39,7 +41,7 @@ module CommitsHelper
|
||||||
next
|
next
|
||||||
else
|
else
|
||||||
type = identification_type(line)
|
type = identification_type(line)
|
||||||
line_code = build_line_anchor(index, line_new, line_old)
|
line_code = build_line_anchor(diff, line_new, line_old)
|
||||||
yield(full_line, type, line_code, line_new, line_old)
|
yield(full_line, type, line_code, line_new, line_old)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ module NotesHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def link_to_merge_request_diff_line_note(note)
|
def link_to_merge_request_diff_line_note(note)
|
||||||
if note.for_merge_request_diff_line?
|
if note.for_merge_request_diff_line? and note.diff
|
||||||
link_to "#{note.diff_file_name}:L#{note.diff_new_line}", diffs_project_merge_request_path(note.project, note.noteable_id, anchor: note.line_code)
|
link_to "#{note.diff_file_name}:L#{note.diff_new_line}", diffs_project_merge_request_path(note.project, note.noteable_id, anchor: note.line_code)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -33,7 +33,7 @@ class Note < ActiveRecord::Base
|
||||||
delegate :name, :email, to: :author, prefix: true
|
delegate :name, :email, to: :author, prefix: true
|
||||||
|
|
||||||
validates :note, :project, presence: true
|
validates :note, :project, presence: true
|
||||||
validates :line_code, format: { with: /\A\d+_\d+_\d+\Z/ }, allow_blank: true
|
validates :line_code, format: { with: /\A[a-z0-9]+_\d+_\d+\Z/ }, allow_blank: true
|
||||||
validates :attachment, file_size: { maximum: 10.megabytes.to_i }
|
validates :attachment, file_size: { maximum: 10.megabytes.to_i }
|
||||||
|
|
||||||
validates :noteable_id, presence: true, if: ->(n) { n.noteable_type.present? && n.noteable_type != 'Commit' }
|
validates :noteable_id, presence: true, if: ->(n) { n.noteable_type.present? && n.noteable_type != 'Commit' }
|
||||||
|
@ -69,11 +69,17 @@ class Note < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def diff
|
def diff
|
||||||
noteable.diffs[diff_file_index]
|
if noteable.diffs.present?
|
||||||
|
noteable.diffs.select do |d|
|
||||||
|
if d.b_path
|
||||||
|
Digest::SHA1.hexdigest(d.b_path) == diff_file_index
|
||||||
|
end
|
||||||
|
end.first
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def diff_file_index
|
def diff_file_index
|
||||||
line_code.split('_')[0].to_i
|
line_code.split('_')[0]
|
||||||
end
|
end
|
||||||
|
|
||||||
def diff_file_name
|
def diff_file_name
|
||||||
|
@ -85,7 +91,7 @@ class Note < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def discussion_id
|
def discussion_id
|
||||||
@discussion_id ||= [:discussion, noteable_type.underscore, noteable_id, line_code].join("-").to_sym
|
@discussion_id ||= [:discussion, noteable_type.try(:underscore), noteable_id, line_code].join("-").to_sym
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns true if this is a downvote note,
|
# Returns true if this is a downvote note,
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
%a.supp_diff_link Diff suppressed. Click to show
|
%a.supp_diff_link Diff suppressed. Click to show
|
||||||
|
|
||||||
%table{class: "#{'hide' if too_big}"}
|
%table{class: "#{'hide' if too_big}"}
|
||||||
- each_diff_line(diff.diff.lines.to_a, index) do |line, type, line_code, line_new, line_old|
|
- each_diff_line(diff, index) do |line, type, line_code, line_new, line_old|
|
||||||
%tr.line_holder{ id: line_code }
|
%tr.line_holder{ id: line_code }
|
||||||
- if type == "match"
|
- if type == "match"
|
||||||
%td.old_line= "..."
|
%td.old_line= "..."
|
||||||
|
|
|
@ -12,8 +12,15 @@
|
||||||
%div
|
%div
|
||||||
= link_to note.author_name, project_team_member_path(@project, @project.team_member_by_id(note.author)), class: "note-author"
|
= link_to note.author_name, project_team_member_path(@project, @project.team_member_by_id(note.author)), class: "note-author"
|
||||||
- if note.for_merge_request?
|
- if note.for_merge_request?
|
||||||
started a discussion on this merge request diff
|
- if note.diff
|
||||||
= link_to_merge_request_diff_line_note(note)
|
started a discussion on this merge request diff
|
||||||
|
= link_to_merge_request_diff_line_note(note)
|
||||||
|
- else
|
||||||
|
started
|
||||||
|
%strong
|
||||||
|
%i.icon-remove
|
||||||
|
outdated
|
||||||
|
discussion on this merge request diff
|
||||||
- elsif note.for_commit?
|
- elsif note.for_commit?
|
||||||
started a discussion on commit
|
started a discussion on commit
|
||||||
#{link_to note.noteable.short_id, project_commit_path(@project, note.noteable)}
|
#{link_to note.noteable.short_id, project_commit_path(@project, note.noteable)}
|
||||||
|
@ -29,8 +36,17 @@
|
||||||
ago
|
ago
|
||||||
.discussion-body
|
.discussion-body
|
||||||
- if note.for_diff_line?
|
- if note.for_diff_line?
|
||||||
.content
|
- if note.diff
|
||||||
.diff_file= render "notes/discussion_diff", discussion_notes: discussion_notes, note: note
|
.content
|
||||||
|
.diff_file= render "notes/discussion_diff", discussion_notes: discussion_notes, note: note
|
||||||
|
- else
|
||||||
|
= link_to 'show outdated discussion', '#', class: 'js-show-outdated-discussion'
|
||||||
|
%div.hide.outdated-discussion
|
||||||
|
.content
|
||||||
|
.notes{ rel: discussion_notes.first.discussion_id }
|
||||||
|
= render discussion_notes
|
||||||
|
|
||||||
|
|
||||||
- else
|
- else
|
||||||
.content
|
.content
|
||||||
.notes{ rel: discussion_notes.first.discussion_id }
|
.notes{ rel: discussion_notes.first.discussion_id }
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
%br/
|
%br/
|
||||||
.diff_file_content
|
.diff_file_content
|
||||||
%table
|
%table
|
||||||
- each_diff_line(diff.diff.lines.to_a, note.diff_file_index) do |line, type, line_code, line_new, line_old|
|
- each_diff_line(diff, note.diff_file_index) do |line, type, line_code, line_new, line_old|
|
||||||
%tr.line_holder{ id: line_code }
|
%tr.line_holder{ id: line_code }
|
||||||
- if type == "match"
|
- if type == "match"
|
||||||
%td.old_line= "..."
|
%td.old_line= "..."
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
Link here
|
Link here
|
||||||
|
|
||||||
- if(note.author_id == current_user.id) || can?(current_user, :admin_note, @project)
|
- if(note.author_id == current_user.id) || can?(current_user, :admin_note, @project)
|
||||||
= link_to project_note_path(@project, note), title: "Remove comment", method: :delete, confirm: 'Are you sure?', remote: true, class: "danger js-note-delete" do
|
= link_to project_note_path(@project, note), title: "Remove comment", method: :delete, confirm: 'Are you sure you want to remove comment?', remote: true, class: "danger js-note-delete" do
|
||||||
%i.icon-remove-circle
|
%i.icon-trash.cred
|
||||||
= image_tag gravatar_icon(note.author.email), class: "avatar s32"
|
= image_tag gravatar_icon(note.author.email), class: "avatar s32"
|
||||||
= link_to note.author_name, project_team_member_path(@project, @project.team_member_by_id(note.author)), class: "note-author"
|
= link_to note.author_name, project_team_member_path(@project, @project.team_member_by_id(note.author)), class: "note-author"
|
||||||
%span.note-last-update
|
%span.note-last-update
|
||||||
|
@ -29,7 +29,7 @@
|
||||||
= markdown(note.note)
|
= markdown(note.note)
|
||||||
- if note.attachment.url
|
- if note.attachment.url
|
||||||
- if note.attachment.image?
|
- if note.attachment.image?
|
||||||
= image_tag note.attachment.url, class: 'thumbnail span4'
|
= image_tag note.attachment.url, class: 'note-image-attach'
|
||||||
.attachment.right
|
.attachment.right
|
||||||
= link_to note.attachment.url, target: "_blank" do
|
= link_to note.attachment.url, target: "_blank" do
|
||||||
%i.icon-attachment
|
%i.icon-attachment
|
||||||
|
|
Loading…
Reference in a new issue