Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

refactor body content into Blankslate

as-opfdffe85e26f8
diff --git a/modules/job_status/app/components/job_status/dialog/body_component.html.erb b/modules/job_status/app/components/job_status/dialog/body_component.html.erb
index f64caec3c35..f72dab6bc7c 100644
--- a/modules/job_status/app/components/job_status/dialog/body_component.html.erb
+++ b/modules/job_status/app/components/job_status/dialog/body_component.html.erb
@@ -12,35 +12,42 @@
<%= render Primer::Beta::Blankslate.new do |component|
component.with_visual_icon(icon: icon, size: :medium) unless icon.nil?
component.with_heading(tag: :h2).with_content(title)
- component.with_description { message }
- end %>
- <% if redirect_url.present? %>
- <%= render(Primer::Beta::Link.new(
- href: redirect_url,
- target: "_blank",
- data: {
- "job-status-polling-target": job_errors.present? ? nil : "redirect"
- }
- )) { I18n.t('js.job_status.redirect_link') } %>
- <% end %>
- <% if download_url.present? %>
- <%= flex_layout do |flex|
- flex.with_row(text_align: :center) { render(Primer::Beta::Text.new) { I18n.t('js.job_status.download_starts') } }
- flex.with_row(text_align: :center) {
- render(Primer::Beta::Link.new(
- href: download_url,
- target: "_blank",
- download: "download",
- data: {
- "job-status-polling-target": "download"
+ component.with_description do
+ flex_layout do |flex|
+ if message.present?
+ flex.with_row { render(Primer::Beta::Text.new) { message } }
+ end
+ if job_errors?
+ job_errors.each do |message|
+ flex.with_row { render(Primer::Beta::Text.new) { message } }
+ end
+ end
+ if redirect_url.present?
+ flex.with_row { render(Primer::Beta::Link.new(
+ href: redirect_url,
+ target: "_blank",
+ data: {
+ "job-status-polling-target": job_errors.present? ? nil : "redirect"
+ }
+ )) { I18n.t('js.job_status.redirect_link') } }
+ end
+ if download_url.present?
+ flex.with_row { render(Primer::Beta::Text.new) { I18n.t('js.job_status.download_starts') } }
+ flex.with_row {
+ render(Primer::Beta::Link.new(
+ href: download_url,
+ target: "_blank",
+ download: "download",
+ data: {
+ "job-status-polling-target": "download"
+ }
+ )) { I18n.t('js.job_status.click_to_download') }
}
- )) { I18n.t('js.job_status.click_to_download') }
- }
- end %>
- <% end %>
- <% if job_html.present? %>
- <%= flex_layout do |flex|
- flex.with_row(text_align: :center) { job_html.html_safe }
- end %>
- <% end %>
+ end
+ if job_html.present?
+ flex.with_row { job_html.html_safe }
+ end
+ end
+ end
+ end %>
<% end %>
diff --git a/modules/job_status/app/components/job_status/dialog/body_component.rb b/modules/job_status/app/components/job_status/dialog/body_component.rb
index db0b19595bc..b408e0324e3 100644
--- a/modules/job_status/app/components/job_status/dialog/body_component.rb
+++ b/modules/job_status/app/components/job_status/dialog/body_component.rb
@@ -101,9 +101,7 @@ module JobStatus
end
def message
- return "" if job.nil?
-
- return job_errors.join(" ") if job_errors?
+ return "" if job.nil? || job_errors?
job.message || I18n.t("js.job_status.generic_messages.#{job.status}")
end