From 54dc5edd92474d82ce8cad83aee47886327dcb65 Mon Sep 17 00:00:00 2001
From: Ewoud Kohl van Wijngaarden
Date: Tue, 27 Jun 2023 15:12:35 +0200
Subject: [PATCH] Consistent version in documentation URLs
This now uses the plugin manual helper to redirect users. It
consistently uses the same version as the REX documentation buttons.
Ideally it would also use the plugin_manual type in documentation_url,
but that doesn't work in Foreman itself.
---
app/helpers/remote_execution_helper.rb | 7 +++++--
app/views/job_invocations/welcome.html.erb | 3 ++-
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/app/helpers/remote_execution_helper.rb b/app/helpers/remote_execution_helper.rb
index 50f2a1d83..234f417c0 100644
--- a/app/helpers/remote_execution_helper.rb
+++ b/app/helpers/remote_execution_helper.rb
@@ -203,8 +203,7 @@ def time_in_words_span(time)
end
def documentation_button_rex(section = '')
- url = 'http://theforeman.org/plugins/foreman_remote_execution/' +
- "#{ForemanRemoteExecution::VERSION.split('.').take(2).join('.')}/index.html#"
+ url = "https://theforeman.org/plugins/foreman_remote_execution/#{rex_doc_version}/index.html#"
documentation_button section, :root_url => url
end
@@ -276,4 +275,8 @@ def targeting_hosts(job_invocation, hosts)
actions: template_invocation_actions(task, host, job_invocation, template_invocation) }
end
end
+
+ def rex_doc_version
+ ForemanRemoteExecution::VERSION.split('.').take(2).join('.')
+ end
end
diff --git a/app/views/job_invocations/welcome.html.erb b/app/views/job_invocations/welcome.html.erb
index 66173d16b..1d5ca6b67 100644
--- a/app/views/job_invocations/welcome.html.erb
+++ b/app/views/job_invocations/welcome.html.erb
@@ -7,7 +7,8 @@
<%= _("Foreman can run arbitrary commands on remote hosts using different providers, such as SSH or Ansible. Communication goes through the Smart Proxy so Foreman does not have to have direct access to the target hosts and can scale to control many hosts.") %>
<%= link_to _('Learn more about this in the documentation.'),
- documentation_url('1.ForemanRemoteExecution1.3Manual', :root_url => 'https://www.theforeman.org/plugins/foreman_remote_execution/1.3/index.html#'), :rel => 'external' %>
+ external_link_path(type: 'plugin_manual', name: 'foreman_remote_execution', version: rex_doc_version, section: "#1.ForemanRemoteExecution#{rex_doc_version}Manual"),
+ rel: 'external' %>
<%= display_link_if_authorized(_("Run Job"), { :action => :create }, { :class => "btn btn-primary btn-lg" }) %>