2023-09-01 15:47:07 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class Admin::SystemCheck::SoftwareVersionCheck < Admin::SystemCheck::BaseCheck
|
|
|
|
include RoutingHelper
|
|
|
|
|
|
|
|
def skip?
|
|
|
|
!current_user.can?(:view_devops) || !SoftwareUpdate.check_enabled?
|
|
|
|
end
|
|
|
|
|
|
|
|
def pass?
|
|
|
|
software_updates.empty?
|
|
|
|
end
|
|
|
|
|
|
|
|
def message
|
|
|
|
if software_updates.any?(&:urgent?)
|
|
|
|
Admin::SystemCheck::Message.new(:software_version_critical_check, nil, admin_software_updates_path, true)
|
2024-09-26 19:27:57 +00:00
|
|
|
elsif software_updates.any?(&:patch_type?)
|
2023-09-01 15:47:07 +00:00
|
|
|
Admin::SystemCheck::Message.new(:software_version_patch_check, nil, admin_software_updates_path)
|
2024-09-26 19:27:57 +00:00
|
|
|
else
|
|
|
|
Admin::SystemCheck::Message.new(:software_version_check, nil, admin_software_updates_path)
|
2023-09-01 15:47:07 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def software_updates
|
2024-09-26 19:27:57 +00:00
|
|
|
@software_updates ||= SoftwareUpdate.pending_to_a
|
2023-09-01 15:47:07 +00:00
|
|
|
end
|
|
|
|
end
|