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
fix(job-status-modal): after user clicked the redirect, closing the dialog no longer navigates back (from the navigated redirect)
as-op8fe4a222148f
diff --git a/frontend/src/stimulus/controllers/dynamic/job-status-polling.controller.ts b/frontend/src/stimulus/controllers/dynamic/job-status-polling.controller.tsindex ce06ad9bcae..25b7539301c 100644--- a/frontend/src/stimulus/controllers/dynamic/job-status-polling.controller.ts+++ b/frontend/src/stimulus/controllers/dynamic/job-status-polling.controller.ts@@ -10,6 +10,7 @@ export default class JobStatusPollingController extends Controller<HTMLElement>declare readonly frameTarget:FrameElement;interval:ReturnType<typeof setInterval>;+ userInteraction:boolean = false;connect() {this.interval = setInterval(() => this.frameTarget.reload(), 2000);@@ -17,7 +18,7 @@ export default class JobStatusPollingController extends Controller<HTMLElement>disconnect() {this.stopPolling();- if (this.backOnCloseValue) {+ if (this.backOnCloseValue && !this.userInteraction) {window.history.back();}}@@ -39,7 +40,14 @@ export default class JobStatusPollingController extends Controller<HTMLElement>setTimeout(() => element.click(), 50);}+ redirectClick(_:Event) {+ this.userInteraction = true;+ }+redirectTargetConnected(element:HTMLLinkElement) {- setTimeout(() => { window.location.href = element.href; }, 2000);+ setTimeout(() => {+ this.userInteraction = true;+ window.location.href = element.href;+ }, 2000);}}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 9fd33a19a80..05faf32ce7c 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@@ -19,6 +19,7 @@flex.with_row { render(Primer::Beta::Link.new(href: redirect_url,data: {+ action: 'job-status-polling#redirectClick',"job-status-polling-target": job_errors.present? ? nil : "redirect"})) { I18n.t('job_status_dialog.redirect_link') } }diff --git a/modules/job_status/spec/features/job_status_spec.rb b/modules/job_status/spec/features/job_status_spec.rbindex f4e7ef98442..da7461a180a 100644--- a/modules/job_status/spec/features/job_status_spec.rb+++ b/modules/job_status/spec/features/job_status_spec.rb@@ -88,5 +88,13 @@ RSpec.describe "Job status", :js doexpect(page).to have_content "Some error"expect(page).to have_css("a[href='#{home_url}']", text: "Please click here to continue")end++ it "does not navigate back after user clicked the redirect" do+ visit "/projects"+ visit "/job_statuses/#{status.job_id}"+ click_on I18n.t('job_status_dialog.redirect_link')++ expect(page).to have_current_path(home_path, wait: 10)+ endendend