Add methods to resolve diff notes and discussions
This commit is contained in:
parent
c9aee48ced
commit
bbab5d014f
2 changed files with 30 additions and 0 deletions
|
@ -85,6 +85,24 @@ class DiffNote < Note
|
||||||
self.resolved_at.present?
|
self.resolved_at.present?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def resolve!(current_user)
|
||||||
|
return unless resolvable?
|
||||||
|
return if resolved?
|
||||||
|
|
||||||
|
self.resolved_at = Time.now
|
||||||
|
self.resolved_by = current_user
|
||||||
|
save!
|
||||||
|
end
|
||||||
|
|
||||||
|
def unresolve!
|
||||||
|
return unless resolvable?
|
||||||
|
return unless resolved?
|
||||||
|
|
||||||
|
self.resolved_at = nil
|
||||||
|
self.resolved_by = nil
|
||||||
|
save!
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def supported?
|
def supported?
|
||||||
|
|
|
@ -63,6 +63,18 @@ class Discussion
|
||||||
notes.any?(&:to_be_resolved?)
|
notes.any?(&:to_be_resolved?)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def resolve!(current_user)
|
||||||
|
notes.each do |note|
|
||||||
|
note.resolve!(current_user) if note.resolvable?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def unresolve!
|
||||||
|
notes.each do |note|
|
||||||
|
note.unresolve! if note.resolvable?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def for_target?(target)
|
def for_target?(target)
|
||||||
self.noteable == target && !diff_discussion?
|
self.noteable == target && !diff_discussion?
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue