Fix report notification breadcrumbs [SCI-9856]

This commit is contained in:
Martin Artnik 2023-12-12 12:11:52 +01:00
parent b1492ff0ce
commit ce3618003b
4 changed files with 23 additions and 0 deletions

View file

@ -28,6 +28,10 @@ module Reports
message: I18n.t('projects.reports.index.generation.completed_notification_message',
report_link: "<a href='#{report_path}'>#{escape_input(report.name)}</a>",
team_name: escape_input(report.team.name)),
subject_id: report_id,
subject_class: 'Report',
subject_name: report.name,
report_type: 'docx',
user: @user
}
)

View file

@ -168,6 +168,10 @@ module Reports
message: I18n.t('projects.reports.index.generation.completed_notification_message',
report_link: "<a href='#{report_path}'>#{escape_input(@report.name)}</a>",
team_name: escape_input(@report.team.name)),
subject_id: @report.id,
subject_class: 'Report',
subject_name: @report.name,
report_type: 'pdf',
user: @user
}
)

View file

@ -12,4 +12,12 @@ class DeliveryNotification < BaseNotification
def title
params[:title]
end
def subject
return unless params[:subject_id] && params[:subject_class]
params[:subject_class].constantize.find(params[:subject_id])
rescue ActiveRecord::RecordNotFound
NonExistantRecord.new(params[:subject_name])
end
end

View file

@ -65,6 +65,13 @@ class NotificationSerializer < ActiveModel::Serializer
when RepositoryRow
parent = subject.team
url = repository_path(subject.repository)
when Report
parent = subject.team
url = reports_path(
preview_report_id: subject.id,
preview_type: object.params[:report_type],
team_id: subject.team.id
)
when LabelTemplate
parent = subject.team
url = label_template_path(subject)