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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
implement other background job use cases
as-opb7e54620a40d
diff --git a/frontend/src/stimulus/controllers/dynamic/job-status-polling.controller.ts b/frontend/src/stimulus/controllers/dynamic/job-status-polling.controller.tsindex 0899031113e..dc022b9f188 100644--- a/frontend/src/stimulus/controllers/dynamic/job-status-polling.controller.ts+++ b/frontend/src/stimulus/controllers/dynamic/job-status-polling.controller.ts@@ -2,7 +2,10 @@ import { Controller } from "@hotwired/stimulus";import { FrameElement } from '@hotwired/turbo';export default class JobStatusPollingController extends Controller<FrameElement> {- static targets = ["finished", "download", "redirect"];+ static targets = ['finished', 'download', 'redirect'];+ static values = { backOnClose: { type: Boolean, default: false } };++ declare readonly backOnCloseValue:boolean;interval:ReturnType<typeof setInterval>;@@ -15,6 +18,9 @@ export default class JobStatusPollingController extends Controller<FrameElement>disconnect() {this.finishedTargetConnected();+ if (this.backOnCloseValue) {+ window.history.back();+ }}finishedTargetConnected() {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.erbindex 476fec9ff7e..13f76a5ea50 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@@ -1,7 +1,10 @@<%= turbo_frame_tag "job_status_modal" do %><% if pending? %><%= component_wrapper do %>- <div class="op-loading-indicator"><div></div><div></div></div>+ <div class="op-loading-indicator">+ <div></div>+ <div></div>+ </div><% end %><% else %><%= content_tag :div, "", data: { "job-status-polling-target": "finished" } %>@@ -16,7 +19,7 @@href: redirect_url,target: "_blank",data: {- "job-status-polling-target": "redirect"+ "job-status-polling-target": job_errors? ? nil : "redirect"})) { I18n.t('js.job_status.redirect_link') } %><% end %>@@ -27,6 +30,7 @@render(Primer::Beta::Link.new(href: download_url,target: "_blank",+ download: "download",data: {"job-status-polling-target": "download"}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.rbindex cf718dbf36b..ea8f5f4bd41 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@@ -75,6 +75,16 @@ module JobStatusjob.payload["download"]end+ def job_errors+ job.payload["errors"]+ end++ def job_errors?+ return false if job.nil?++ job.payload["errors"].present?+ end+def job_html?return false if job.nil?@@ -88,22 +98,26 @@ module JobStatusenddef pending?- return false if job.nil?+ return false if job.nil? || has_error?pending_statuses.include?(job.status)end+ def has_error?+ error_statuses.include?(job.status) || job_errors?+ end+def titlereturn I18n.t("js.job_status.generic_messages.not_found") if job.nil?- return I18n.t("js.job_status.errors") if error_statuses.include?(job.status)+ return I18n.t("js.job_status.errors") if has_error?job.payload["title"] || I18n.t("js.job_status.title")enddef iconreturn :alert if job.nil?- return :"x-circle" if error_statuses.include?(job.status)+ return :"x-circle" if has_error?:"issue-closed" if success_statuses.include?(job.status)end@@ -111,6 +125,8 @@ module JobStatusdef messagereturn "" if job.nil?+ return job_errors.join(" ") if job_errors?+job.message || I18n.t("js.job_status.generic_messages.#{job.status}")endenddiff --git a/modules/job_status/app/components/job_status/dialog/dialog_component.html.erb b/modules/job_status/app/components/job_status/dialog/dialog_component.html.erbindex 8a6f335fec6..ecfbf92ffa2 100644--- a/modules/job_status/app/components/job_status/dialog/dialog_component.html.erb+++ b/modules/job_status/app/components/job_status/dialog/dialog_component.html.erb@@ -1,6 +1,7 @@<%= render(Primer::Alpha::Dialog.new(title: I18n.t('js.job_status.title'),visually_hide_title: true,+ size: :large,id: MODAL_ID)) do |dialog| %><% dialog.with_body do %>@@ -9,6 +10,7 @@data: {"application-target": "dynamic",controller: 'job-status-polling',+ "job-status-polling-back-on-close-value": back_on_close,}) do %><% end %>diff --git a/modules/job_status/app/components/job_status/dialog/dialog_component.rb b/modules/job_status/app/components/job_status/dialog/dialog_component.rbindex 9ab504f5dbc..b09afd6b424 100644--- a/modules/job_status/app/components/job_status/dialog/dialog_component.rb+++ b/modules/job_status/app/components/job_status/dialog/dialog_component.rb@@ -37,11 +37,12 @@ module JobStatusinclude OpTurbo::Streamableinclude OpPrimer::ComponentHelpers- attr_reader :job_uuid+ attr_reader :job_uuid, :back_on_close- def initialize(job_uuid:)+ def initialize(job_uuid:, back_on_close: false)super+ @back_on_close = back_on_close@job_uuid = job_uuidendend