2020-02-19 13:09:10 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-03-31 11:07:53 -04:00
|
|
|
class MilestoneNote < SyntheticNote
|
|
|
|
attr_accessor :milestone
|
2020-02-19 13:09:10 -05:00
|
|
|
|
|
|
|
def self.from_event(event, resource: nil, resource_parent: nil)
|
2020-03-31 11:07:53 -04:00
|
|
|
attrs = note_attributes('milestone', event, resource, resource_parent).merge(milestone: event.milestone)
|
2020-02-19 13:09:10 -05:00
|
|
|
|
|
|
|
MilestoneNote.new(attrs)
|
|
|
|
end
|
|
|
|
|
|
|
|
def note_html
|
|
|
|
@note_html ||= Banzai::Renderer.cacheless_render_field(self, :note, { group: group, project: project })
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def note_text(html: false)
|
|
|
|
format = milestone&.group_milestone? ? :name : :iid
|
|
|
|
milestone.nil? ? 'removed milestone' : "changed milestone to #{milestone.to_reference(project, format: format)}"
|
|
|
|
end
|
|
|
|
end
|