summaryrefslogtreecommitdiff
path: root/app/models/milestone_note.rb
blob: 19171e682b7e53fef7ae073f708be8b944c716aa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# frozen_string_literal: true

class MilestoneNote < SyntheticNote
  attr_accessor :milestone

  def self.from_event(event, resource: nil, resource_parent: nil)
    attrs = note_attributes('milestone', event, resource, resource_parent).merge(milestone: event.milestone)

    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
    event.remove? ? 'removed milestone' : "changed milestone to #{milestone.to_reference(project, format: format)}"
  end
end