2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-11-22 15:47:28 +01:00
|
|
|
class Attachment::ProgressComponent < ApplicationComponent
|
|
|
|
attr_reader :attachment
|
2023-12-06 15:10:44 +01:00
|
|
|
attr_reader :ignore_antivirus
|
2022-11-22 15:47:28 +01:00
|
|
|
|
2023-12-06 15:10:44 +01:00
|
|
|
def initialize(attachment:, ignore_antivirus: false)
|
2022-11-22 15:47:28 +01:00
|
|
|
@attachment = attachment
|
2023-12-06 15:10:44 +01:00
|
|
|
@ignore_antivirus = ignore_antivirus
|
2022-11-22 15:47:28 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def progress_label
|
|
|
|
case
|
2023-12-06 15:10:44 +01:00
|
|
|
when !ignore_antivirus && attachment.virus_scanner.pending?
|
2022-11-22 19:25:45 +01:00
|
|
|
t(".antivirus_pending")
|
2022-11-22 15:47:28 +01:00
|
|
|
when attachment.watermark_pending?
|
2022-11-22 19:25:45 +01:00
|
|
|
t(".watermark_pending")
|
2022-11-22 15:47:28 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def render?
|
|
|
|
progress_label.present?
|
|
|
|
end
|
|
|
|
end
|