diff --git a/app/controllers/concerns/documentation_controller_branding.rb b/app/controllers/concerns/documentation_controller_branding.rb index 33f3adf..6cfbe12 100644 --- a/app/controllers/concerns/documentation_controller_branding.rb +++ b/app/controllers/concerns/documentation_controller_branding.rb @@ -3,6 +3,17 @@ module DocumentationControllerBranding extend ActiveSupport::Concern + def external_url(type:, options: {}) + return super unless type == 'upgrade' + + case options[:section] + when 'documentation' + ForemanThemeSatellite.unversioned_documentation_root + when 'helper' + "#{ForemanThemeSatellite.documentation_server}/labsinfo/satelliteupgradehelper" + end + end + def documentation_url(section = nil, options = {}) url = '' unless section.nil? diff --git a/lib/foreman_theme_satellite/engine.rb b/lib/foreman_theme_satellite/engine.rb index c0bc978..b3959ed 100644 --- a/lib/foreman_theme_satellite/engine.rb +++ b/lib/foreman_theme_satellite/engine.rb @@ -18,6 +18,7 @@ class Engine < ::Rails::Engine SettingRegistry.prepend SettingRegistryBranding end + # rubocop:disable Metrics/BlockLength initializer 'foreman_theme_satellite.register_plugin', :before=> :finisher_hook do |app| Foreman::Plugin.register :foreman_theme_satellite do requires_foreman '>= 3.7.0' @@ -53,8 +54,19 @@ class Engine < ::Rails::Engine extend_rabl_template 'api/v2/home/status', 'api/v2/home/status_extensions' extend_template_helpers ForemanThemeSatellite::RendererMethods + + divider :admin_menu, caption: N_('Upgrade'), parent: :administer_menu + menu :admin_menu, :general_documentation, + url_hash: { controller: :links, action: :show, type: :upgrade, section: :documentation }, + caption: N_('Documentation'), + parent: :administer_menu + menu :admin_menu, :upgrade_helper, + url_hash: { controller: :links, action: :show, type: :upgrade, section: :helper }, + caption: N_('Upgrade helper'), + parent: :administer_menu end end + # rubocop:enable Metrics/BlockLength initializer 'foreman_theme_satellite.load_app_instance_data' do |app| ForemanThemeSatellite::Engine.paths['db/migrate'].existent.each do |path| @@ -148,7 +160,13 @@ def self.documentation_version def self.documentation_root @documentation_root ||= begin - "#{documentation_server}/documentation/en-us/red_hat_satellite/#{documentation_version}/html" + "#{unversioned_documentation_root}/#{documentation_version}/html" + end + end + + def self.unversioned_documentation_root + @unversioned_documentation_root ||= begin + "#{documentation_server}/documentation/en-us/red_hat_satellite" end end