From dfaad4e44180757d4a34a6c3dceed0ce00810a72 Mon Sep 17 00:00:00 2001 From: nofaralfasi Date: Mon, 1 Jan 2024 18:48:53 +0200 Subject: [PATCH] Fixes #36982 - display short hostname on REX job pages If the `display_fqdn_for_hosts` setting is set to false, show the short hostname on REX job pages. --- app/helpers/job_invocations_helper.rb | 2 +- app/helpers/remote_execution_helper.rb | 4 ++-- .../actions/remote_execution/run_host_job.rb | 9 +++++++-- .../_preview_hosts_list.html.erb | 2 +- app/views/template_invocations/show.html.erb | 4 ++-- webpack/JobWizard/JobWizardSelectors.js | 9 +++++++-- webpack/JobWizard/__tests__/fixtures.js | 6 +++--- webpack/JobWizard/autofill.js | 12 ++++++++---- .../steps/HostsAndInputs/HostPreviewModal.js | 6 +++--- .../steps/HostsAndInputs/SelectGQL.js | 1 + .../steps/HostsAndInputs/SelectedChips.js | 19 +++++++++++++------ .../JobWizard/steps/HostsAndInputs/hosts.gql | 1 + .../JobWizard/steps/HostsAndInputs/index.js | 5 +++++ .../JobWizard/steps/ReviewDetails/index.js | 5 +++-- webpack/JobWizard/steps/form/SearchSelect.js | 4 +++- .../steps/form/__tests__/SelectSearch.test.js | 2 ++ 16 files changed, 62 insertions(+), 29 deletions(-) diff --git a/app/helpers/job_invocations_helper.rb b/app/helpers/job_invocations_helper.rb index 7e7e2e186..05889c1b7 100644 --- a/app/helpers/job_invocations_helper.rb +++ b/app/helpers/job_invocations_helper.rb @@ -33,7 +33,7 @@ def preview_hosts(template_invocation) end def collapsed_preview(target) - title = target.try(:name) || 'N/A' + title = target || 'N/A' content_tag(:h5, :class => "expander collapsed out", :data => { :toggle => 'collapse', diff --git a/app/helpers/remote_execution_helper.rb b/app/helpers/remote_execution_helper.rb index 573578a63..72700e9b3 100644 --- a/app/helpers/remote_execution_helper.rb +++ b/app/helpers/remote_execution_helper.rb @@ -34,7 +34,7 @@ def template_invocation_actions(task, host, job_invocation, template_invocation) action: { href: current_host_details_path(host), 'data-method': 'get', id: "#{host.name}-actions-detail" } } end if authorized_for(controller: :job_invocations, action: :create) && (!host.infrastructure_host? || User.current.can?(:execute_jobs_on_infrastructure_hosts)) - links << { title: (_('Rerun on %s') % host.name), + links << { title: (_('Rerun on %s') % host), action: { href: rerun_job_invocation_path(job_invocation, host_ids: [ host.id ]), 'data-method': 'get', id: "#{host.name}-actions-rerun" } } end @@ -274,7 +274,7 @@ def targeting_hosts(job_invocation, hosts) task = template_invocation.try(:run_host_job_task) link_authorized = !task.nil? && authorized_for(hash_for_template_invocation_path(:id => template_invocation).merge(:auth_object => host, :permission => :view_hosts, :authorizer => job_hosts_authorizer)) - { name: host.name, + { name: host.to_label, link: link_authorized ? template_invocation_path(:id => template_invocation) : '', status: template_invocation_status(task, job_invocation.task), actions: template_invocation_actions(task, host, job_invocation, template_invocation) } diff --git a/app/lib/actions/remote_execution/run_host_job.rb b/app/lib/actions/remote_execution/run_host_job.rb index 0a8d0bf94..2b2a6bc4c 100644 --- a/app/lib/actions/remote_execution/run_host_job.rb +++ b/app/lib/actions/remote_execution/run_host_job.rb @@ -28,6 +28,7 @@ def inner_plan(job_invocation, host, template_invocation, proxy_selector, option raise _('Could not use any template used in the job invocation') if template_invocation.blank? features = template_invocation.template.remote_execution_features.pluck(:label).uniq action_subject(host, + :host_display_name => host.to_label, :job_category => job_invocation.job_category, :description => job_invocation.description, :job_invocation_id => job_invocation.id, @@ -101,8 +102,12 @@ def live_output end def humanized_input - N_('%{description} on %{host}') % { :host => input[:host].try(:[], :name), - :description => input[:description].try(:capitalize) || input[:job_category] } + return unless input.present? + + N_('%{description} on %{host}') % { + host: input[:host_display_name], + description: input[:description].try(:capitalize) || input[:job_category], + } end def humanized_name diff --git a/app/views/job_invocations/_preview_hosts_list.html.erb b/app/views/job_invocations/_preview_hosts_list.html.erb index c598234b4..c36b66146 100644 --- a/app/views/job_invocations/_preview_hosts_list.html.erb +++ b/app/views/job_invocations/_preview_hosts_list.html.erb @@ -7,7 +7,7 @@ <% if @hosts.any? -%>