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
Allow jobs to define a title for the job status modal
Oliver Günther45fc54b7e080
diff --git a/app/workers/copy_project_job.rb b/app/workers/copy_project_job.rbindex 64a88a5cfcd..f32340bbb79 100644--- a/app/workers/copy_project_job.rb+++ b/app/workers/copy_project_job.rb@@ -82,6 +82,12 @@ class CopyProjectJob < ApplicationJobtrueend+ protected++ def title+ I18n.t(:label_copy_project)+ end+privatedef successful_status_updatediff --git a/app/workers/work_packages/exports/export_job.rb b/app/workers/work_packages/exports/export_job.rbindex 77b364eb28d..0442293291f 100644--- a/app/workers/work_packages/exports/export_job.rb+++ b/app/workers/work_packages/exports/export_job.rb@@ -18,6 +18,12 @@ module WorkPackagestrueend+ protected++ def title+ I18n.t('export.your_work_packages_export')+ end+privatedef export_work_packages(export, mime_type, query, options)diff --git a/config/locales/en.yml b/config/locales/en.ymlindex ff95690ece0..4fd53e34d9a 100644--- a/config/locales/en.yml+++ b/config/locales/en.yml@@ -1160,6 +1160,7 @@ en:work_package_note: 'Work Package note added'export:+ your_work_packages_export: "Your work packages export"succeeded: "The export has completed successfully."format:atom: "Atom"diff --git a/frontend/src/app/modules/job-status/job-status-modal/job-status.modal.html b/frontend/src/app/modules/job-status/job-status-modal/job-status.modal.htmlindex 65bc176a8bf..6de66e1c268 100644--- a/frontend/src/app/modules/job-status/job-status-modal/job-status.modal.html+++ b/frontend/src/app/modules/job-status/job-status-modal/job-status.modal.html@@ -2,6 +2,7 @@<div class="op-modal--modal-container job-status--modal"tabindex="0"><div class="op-modal--modal-header">+ <h3 [textContent]="title"></h3><a class="op-modal--modal-close-button"><iclass="icon-close"@@ -11,8 +12,6 @@</a></div>- <h3 [textContent]="text.title"></h3>-<div><div class="loading-indicator--location"data-indicator-name="modal">diff --git a/frontend/src/app/modules/job-status/job-status-modal/job-status.modal.ts b/frontend/src/app/modules/job-status/job-status-modal/job-status.modal.tsindex c3644cdd6c0..0855de1d9a8 100644--- a/frontend/src/app/modules/job-status/job-status-modal/job-status.modal.ts+++ b/frontend/src/app/modules/job-status/job-status-modal/job-status.modal.ts@@ -50,6 +50,9 @@ export class JobStatusModal extends OpModalComponent implements OnInit {/** Public message to show */public message:string;+ /** Title to show */+ public title:string = this.text.title;+/** A link in case the job results in a download */public downloadHref:string|null = null;@@ -123,6 +126,7 @@ export class JobStatusModal extends OpModalComponent implements OnInit {this.I18n.t(`js.job_status.generic_messages.${status}`, { defaultValue: status });if (body.payload) {+ this.title = body.payload.title || this.text.title;this.handleRedirect(body.payload?.redirect);this.handleDownload(body.payload?.download);}diff --git a/frontend/src/app/modules/job-status/job-status.interface.ts b/frontend/src/app/modules/job-status/job-status.interface.tsindex 3b39dca9fb7..369e3274dd1 100644--- a/frontend/src/app/modules/job-status/job-status.interface.ts+++ b/frontend/src/app/modules/job-status/job-status.interface.ts@@ -20,6 +20,7 @@ export interface JobStatusInterface {* Additional payload object*/payload?:{+ title?:string;download?:string;redirect?:string;};diff --git a/modules/job_status/app/workers/job_status/application_job_with_status.rb b/modules/job_status/app/workers/job_status/application_job_with_status.rbindex b2262c39d1f..4bce5fe8493 100644--- a/modules/job_status/app/workers/job_status/application_job_with_status.rb+++ b/modules/job_status/app/workers/job_status/application_job_with_status.rb@@ -72,12 +72,34 @@ module JobStatusresource.reference = status_referenceend- new_attributes = args.reverse_merge(status: status, message: nil, payload: nil)- resource.update! new_attributes+ # Update properties with the language of the user+ # to ensure things like the title are correct+ User.execute_as(resource.user) do+ resource.attributes = build_status_attributes(args.merge(status: status))+ end++ resource.save!endprotected+ ##+ # Builds the attributes for updating the status+ def build_status_attributes(attributes)+ if title+ attributes[:payload] ||= {}+ attributes[:payload][:title] = title+ end++ attributes.reverse_merge(message: nil, payload: nil)+ end++ ##+ # Title of the job status, optional+ def title+ nil+ end+### Crafts a payload for a redirection resultdef redirect_payload(path)diff --git a/spec/features/work_packages/export_spec.rb b/spec/features/work_packages/export_spec.rbindex a3d2e3be7e7..c9068c871d1 100644--- a/spec/features/work_packages/export_spec.rb+++ b/spec/features/work_packages/export_spec.rb@@ -73,6 +73,9 @@ describe 'work package export', type: :feature doexpect(page).to have_content I18n.t('js.job_status.generic_messages.in_queue'),wait: 10+ # Expect title+ expect(page).to have_selector 'h3', text: I18n.t('export.your_work_packages_export')+beginperform_enqueued_jobsrescuediff --git a/spec/workers/copy_project_job_spec.rb b/spec/workers/copy_project_job_spec.rbindex 22360be5904..03197089043 100644--- a/spec/workers/copy_project_job_spec.rb+++ b/spec/workers/copy_project_job_spec.rb@@ -181,7 +181,7 @@ describe CopyProjectJob, type: :model doexpect(copy_job.job_status).to be_presentexpect(copy_job.job_status[:status]).to eq 'failure'expect(copy_job.job_status[:message]).to include "Cannot copy project #{source_project.name}"- expect(copy_job.job_status[:payload]).to be_nil+ expect(copy_job.job_status[:payload]).to eq('title' => 'Copy project')endend@@ -199,7 +199,7 @@ describe CopyProjectJob, type: :model dodescribe 'perform' dobefore dologin_as(user)- expect(User).to receive(:current=).with(user)+ expect(User).to receive(:current=).with(user).at_least(:once)enddescribe 'subproject' do