lib/katello/plugin.rb in katello-4.8.4 vs lib/katello/plugin.rb in katello-4.9.0.rc1
- old
+ new
@@ -2,11 +2,12 @@
require 'katello/repository_types'
require 'katello/host_status_manager'
# rubocop:disable Metrics/BlockLength
Foreman::Plugin.register :katello do
- requires_foreman '>= 2.6'
+ requires_foreman '>= 3.7'
+ register_gettext
sub_menu :top_menu, :content_menu, :caption => N_('Content'),
:icon => 'fa fa-book', :after => :monitor_menu do
menu :top_menu,
:red_hat_subscriptions,
@@ -265,27 +266,29 @@
:onlyif => proc { |proxy| proxy.pulp_primary? }
end
extend_page 'hosts/_list' do |context|
context.with_profile :content, _('Content'), default: false do
- common_th_class = 'hidden-tablet hidden-xs'
- common_td_class = "#{common_th_class} ellipsis"
+ common_class = 'hidden-tablet hidden-xs ellipsis'
use_pagelet :hosts_table_column_header, :name
use_pagelet :hosts_table_column_content, :name
- add_pagelet :hosts_table_column_header, key: :subscription_status, label: _('Subscription status'), sortable: true, class: common_th_class, width: '10%'
- add_pagelet :hosts_table_column_content, key: :subscription_status, class: common_td_class, callback: ->(host) { host_status_icon(host.subscription_global_status) }
- add_pagelet :hosts_table_column_header, key: :installable_updates, label: _('Installable updates'), class: common_th_class, width: '15%'
- add_pagelet :hosts_table_column_content, key: :installable_updates, class: common_td_class, callback: ->(host) { errata_counts(host) }
+ add_pagelet :hosts_table_column_header, key: :subscription_status, label: _('Subscription status'), sortable: true, class: common_class, width: '10%', export_key: 'subscription_global_status'
+ add_pagelet :hosts_table_column_content, key: :subscription_status, class: common_class, callback: ->(host) { host_status_icon(host.subscription_global_status) }
+ add_pagelet :hosts_table_column_header, key: :installable_updates, label: _('Installable updates'), class: common_class, width: '15%',
+ export_data: [:security, :bugfix, :enhancement].map { |kind| CsvExporter::ExportDefinition.new("installable_updates.#{kind}", callback: ->(host) { (host.content_facet_attributes&.errata_counts || {})[kind] }) } +
+ [:rpm, :deb].map { |kind| CsvExporter::ExportDefinition.new("installable_packages.#{kind}", callback: ->(host) { host&.content_facet_attributes&.public_send("upgradable_#{kind}_count".to_sym) || 0 }) }
+ add_pagelet :hosts_table_column_content, key: :installable_updates, class: common_class, callback: ->(host) { errata_counts(host) }
use_pagelet :hosts_table_column_header, :os_title
use_pagelet :hosts_table_column_content, :os_title
- add_pagelet :hosts_table_column_header, key: :lifecycle_environment, label: _('Lifecycle environment'), sortable: true, class: common_th_class, width: '10%'
- add_pagelet :hosts_table_column_content, key: :lifecycle_environment, class: common_td_class, callback: ->(host) { host.content_facet&.single_lifecycle_environment&.name }
- add_pagelet :hosts_table_column_header, key: :content_view, label: _('Content view'), sortable: true, class: common_th_class, width: '10%'
- add_pagelet :hosts_table_column_content, key: :content_view, class: common_td_class, callback: ->(host) { host.content_facet&.single_content_view&.name }
- add_pagelet :hosts_table_column_header, key: :registered_at, label: _('Registered'), sortable: true, class: common_th_class, width: '10%'
- add_pagelet :hosts_table_column_content, key: :registered_at, class: common_td_class, callback: ->(host) { host_registered_time(host) }
- add_pagelet :hosts_table_column_header, key: :last_checkin, label: _('Last checkin'), sortable: true, class: common_th_class, width: '10%'
- add_pagelet :hosts_table_column_content, key: :last_checkin, class: common_td_class, callback: ->(host) { host_checkin_time(host) }
+ add_pagelet :hosts_table_column_header, key: :lifecycle_environment, label: _('Lifecycle environment'), sortable: true, class: common_class, width: '10%',
+ export_data: CsvExporter::ExportDefinition.new('single_lifecycle_environment', label: 'Lifecycle Environment')
+ add_pagelet :hosts_table_column_content, key: :lifecycle_environment, class: common_class, callback: ->(host) { host.content_facet&.single_lifecycle_environment&.name }
+ add_pagelet :hosts_table_column_header, key: :content_view, label: _('Content view'), sortable: true, class: common_class, width: '10%', export_data: CsvExporter::ExportDefinition.new('single_content_view', label: 'Content View')
+ add_pagelet :hosts_table_column_content, key: :content_view, class: common_class, callback: ->(host) { host.content_facet&.single_content_view&.name }
+ add_pagelet :hosts_table_column_header, key: :registered_at, label: _('Registered'), sortable: true, class: common_class, width: '10%', export_data: CsvExporter::ExportDefinition.new('subscription_facet_attributes.registered_at', label: 'Registered')
+ add_pagelet :hosts_table_column_content, key: :registered_at, class: common_class, callback: ->(host) { host_registered_time(host) }
+ add_pagelet :hosts_table_column_header, key: :last_checkin, label: _('Last checkin'), sortable: true, class: common_class, width: '10%', export_data: CsvExporter::ExportDefinition.new('subscription_facet_attributes.last_checkin', label: 'Last Checkin')
+ add_pagelet :hosts_table_column_content, key: :last_checkin, class: common_class, callback: ->(host) { host_checkin_time(host) }
end
end
::Katello::HostStatusManager::STATUSES.each do |status_class|
register_custom_status(status_class)