Skip to content

Commit

Permalink
BZ #1991964 - Show upgrade links under Administer > Upgrade
Browse files Browse the repository at this point in the history
Links to unversioned documentation which automatically redirects to
latest available version and the upgrade helper app
  • Loading branch information
adamruzicka committed Jan 30, 2024
1 parent dda2d3e commit e6ae4f0
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
11 changes: 11 additions & 0 deletions app/controllers/concerns/documentation_controller_branding.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
20 changes: 19 additions & 1 deletion lib/foreman_theme_satellite/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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|
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit e6ae4f0

Please sign in to comment.