diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..fb1ac57 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +github: [merefield] diff --git a/assets/javascripts/discourse/components/process-buttons.gjs b/assets/javascripts/discourse/components/process-buttons.gjs index a238fdb..2faccd4 100644 --- a/assets/javascripts/discourse/components/process-buttons.gjs +++ b/assets/javascripts/discourse/components/process-buttons.gjs @@ -39,10 +39,13 @@ export default class ProcessButtonsComponent extends Component { return; } - const message = i18n(`process_manager.options.${option}.confirmation`); - const targetSuffix = this.processActionHelperText(processAction); - const confirmationMessage = - targetSuffix && message ? `${message} ${targetSuffix}` : message; + const confirmation = i18n(`process_manager.options.${option}.confirmation`); + const confirmationMessage = processAction.target_step_name + ? i18n("process_manager.topic_banner.transition_confirmation_target", { + confirmation: confirmation.replace(/\?$/, ""), + target_step_name: processAction.target_step_name, + }) + : confirmation; this.dialog.yesNoConfirm({ message: confirmationMessage, @@ -53,7 +56,7 @@ export default class ProcessButtonsComponent extends Component { data: { option }, }) .then(() => { - this.router.transitionTo("/c/" + this.args.category_id); + this.router.transitionTo("discovery.processes"); }) .catch(async (err) => { this.transitioningOption = null; diff --git a/assets/javascripts/discourse/initializers/init-process-manager.gjs b/assets/javascripts/discourse/initializers/init-process-manager.gjs index 44a930f..82acf32 100644 --- a/assets/javascripts/discourse/initializers/init-process-manager.gjs +++ b/assets/javascripts/discourse/initializers/init-process-manager.gjs @@ -198,6 +198,8 @@ export default { ); api.addPostSmallActionIcon("process_transition", "right-left"); + // TODO(11-2026): Remove this legacy action code after Workflow-era posts have aged out. + api.addPostSmallActionIcon("workflow_transition", "right-left"); }); }, }; diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 662d64c..d8a2390 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -18,6 +18,7 @@ en: process_topic_arrival: "A topic titled %{topic_title} has arrived in step: %{process_step_name} of the process: %{process_name}, authored by %{username}" action_codes: process_transition: "acted upon topic in a process %{when}" + workflow_transition: "acted upon topic in a process %{when}" topics: bottom: processes: Currently, there are no more viewable process topics. @@ -43,7 +44,8 @@ en: one: "In this step for %{count} day" other: "In this step for %{count} days" actions_intro: "Actions:" - transition_target: "-> %{target_step_name}" + transition_target: "Target step: %{target_step_name}" + transition_confirmation_target: "%{confirmation} and move it to %{target_step_name}?" blocked_reason_create_permission: "You can reply in this step, but only users with topic creation permission in this category can transition it." visualisation_button: "Visualise" visualisation_title: "Process: %{process_name}" @@ -77,49 +79,49 @@ en: options: submit: button_label: "Submit" - confirmation: "Are you sure you want to submit this topic?" + confirmation: "Are you sure you want to submit this item?" start: button_label: "Start" - confirmation: "Are you sure you want to start this process?" + confirmation: "Are you sure you want to start this item?" accept: button_label: "Accept" - confirmation: "Are you sure you want to accept this topic?" + confirmation: "Are you sure you want to accept this item?" reject: button_label: "Reject" - confirmation: "Are you sure you want to reject this topic?" + confirmation: "Are you sure you want to reject this item?" great: button_label: "Great" - confirmation: "Are you sure you want to mark this topic as great?" + confirmation: "Are you sure you want to mark this item as great?" good: button_label: "Good" - confirmation: "Are you sure you want to mark this topic as good?" + confirmation: "Are you sure you want to mark this item as good?" average: button_label: "Average" - confirmation: "Are you sure you want to mark this topic as average?" + confirmation: "Are you sure you want to mark this item as average?" bad: button_label: "Bad" - confirmation: "Are you sure you want to mark this topic as bad?" + confirmation: "Are you sure you want to mark this item as bad?" terrible: button_label: "Terrible" - confirmation: "Are you sure you want to mark this topic as terrible?" + confirmation: "Are you sure you want to mark this item as terrible?" done: button_label: "Done" - confirmation: "Are you sure you want to mark this topic as done?" + confirmation: "Are you sure you want to mark this item as done?" next: button_label: "Next" - confirmation: "Are you sure you want to move this Topic to the next step?" + confirmation: "Are you sure you want to move this item to the next step?" back: button_label: "Back" - confirmation: "Are you sure you want to move this Topic back to the previous step?" + confirmation: "Are you sure you want to move this item back to the previous step?" finish: button_label: "Finish" - confirmation: "Are you sure you want to finish this process?" + confirmation: "Are you sure you want to finish this item?" close: button_label: "Close" - confirmation: "Are you sure you want to close this process?" + confirmation: "Are you sure you want to close this item?" reopen: button_label: "Reopen" - confirmation: "Are you sure you want to reopen this process?" + confirmation: "Are you sure you want to reopen this item?" admin_js: admin: site_settings: diff --git a/plugin.rb b/plugin.rb index 742915f..00840fa 100644 --- a/plugin.rb +++ b/plugin.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # name: discourse-process-manager # about: A process management plugin for Discourse -# version: 0.6.0 +# version: 0.6.1 # authors: Robert Barrow # contact_emails: robert@pavilion.tech # url: https://github.com/merefield/discourse-process-manager diff --git a/spec/lib/process_transition_legacy_action_code_spec.rb b/spec/lib/process_transition_legacy_action_code_spec.rb new file mode 100644 index 0000000..fe541c1 --- /dev/null +++ b/spec/lib/process_transition_legacy_action_code_spec.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +require_relative "../plugin_helper" + +RSpec.describe "Process transition legacy action code support" do + it "keeps a client translation for legacy Workflow-era small action posts" do + locale_path = File.expand_path("../../config/locales/client.en.yml", __dir__) + source = File.read(locale_path) + + expect(source).to include('workflow_transition: "acted upon topic in a process %{when}"') + end + + it "keeps a small action icon for legacy Workflow-era small action posts" do + initializer_path = + File.expand_path( + "../../assets/javascripts/discourse/initializers/init-process-manager.gjs", + __dir__, + ) + source = File.read(initializer_path) + + expect(source).to include('api.addPostSmallActionIcon("workflow_transition", "right-left")') + expect(source).to include("Remove this legacy action code") + end +end diff --git a/spec/system/page_objects/pages/process_topic.rb b/spec/system/page_objects/pages/process_topic.rb index def8c07..7cf01e2 100644 --- a/spec/system/page_objects/pages/process_topic.rb +++ b/spec/system/page_objects/pages/process_topic.rb @@ -23,6 +23,11 @@ def has_disabled_action_button? def has_step_age_badge_text?(text) has_css?(".process-step-age-badge", text: text) end + + def click_process_action(label) + find(".process-step-actions .process-action-button .btn", text: label).click + self + end end end end diff --git a/spec/system/process_topic_banner_spec.rb b/spec/system/process_topic_banner_spec.rb index 3134282..f29afa7 100644 --- a/spec/system/process_topic_banner_spec.rb +++ b/spec/system/process_topic_banner_spec.rb @@ -1,6 +1,10 @@ # frozen_string_literal: true RSpec.describe "Process topic banner" do + let(:dialog) { PageObjects::Components::Dialog.new } + let(:process_topic_page) { PageObjects::Pages::ProcessTopic.new } + + fab!(:admin) fab!(:actor, :user) fab!(:viewer, :user) fab!(:actor_group, :group) @@ -92,4 +96,18 @@ expect(Time.zone.parse(entered_at)).to be < 2.days.ago end + + it "returns to process discovery after a topic action" do + sign_in(admin) + process_topic_page.visit_topic(topic).click_process_action("Accept") + + expect(dialog).to have_content( + "Are you sure you want to accept this item and move it to Review?", + ) + + dialog.click_yes + + expect(page).to have_current_path("/processes", url: false) + expect(process_state.reload.process_step_id).to eq(step_2.id) + end end