A platform for community discussion. Free, open, simple.
UX: don't tell users they can reply with questions about a revision if there's no user set (#39022)
Kris0d0c14dc59bc
diff --git a/app/models/reviewable_queued_post.rb b/app/models/reviewable_queued_post.rbindex c32856bf210..4442751228c 100644--- a/app/models/reviewable_queued_post.rb+++ b/app/models/reviewable_queued_post.rb@@ -154,6 +154,20 @@ class ReviewableQueuedPost < Reviewableenddef perform_revise_and_reject_post(performed_by, args)+ has_contact_user = SiteSetting.site_contact_username.present?+ is_new_topic = self.topic.blank?++ edit_instructions_key =+ if is_new_topic && has_contact_user+ "system_messages.reviewable_queued_post_revise_and_reject_edit_topic"+ elsif is_new_topic+ "system_messages.reviewable_queued_post_revise_and_reject_edit_topic_no_reply"+ elsif has_contact_user+ "system_messages.reviewable_queued_post_revise_and_reject_edit_post"+ else+ "system_messages.reviewable_queued_post_revise_and_reject_edit_post_no_reply"+ end+pm_translation_args = {topic_title: self.topic&.title || self.payload["title"],topic_url: self.topic&.url,@@ -161,11 +175,14 @@ class ReviewableQueuedPost < Reviewablefeedback: args[:revise_feedback],original_post: self.payload["raw"],site_name: SiteSetting.title,+ edit_instructions:+ I18n.t(edit_instructions_key, locale: self.target_created_by.effective_locale),}+SystemMessage.create(self.target_created_by,(- if self.topic.blank?+ if is_new_topic:reviewable_queued_post_revise_and_reject_new_topicelse:reviewable_queued_post_revise_and_rejectdiff --git a/config/locales/server.en.yml b/config/locales/server.en.ymlindex 57730937143..18072d9c3e5 100644--- a/config/locales/server.en.yml+++ b/config/locales/server.en.yml@@ -3444,6 +3444,10 @@ en:For additional guidance, please refer to our [community guidelines](%{base_url}/guidelines).+ reviewable_queued_post_revise_and_reject_edit_post: "You can edit your original post below and re-submit to make the suggested changes, or reply to this message if you have any questions."+ reviewable_queued_post_revise_and_reject_edit_post_no_reply: "You can edit your original post below and re-submit to make the suggested changes."+ reviewable_queued_post_revise_and_reject_edit_topic: "You can edit your topic's original post below and re-submit to make the suggested changes, or reply to this message if you have any questions."+ reviewable_queued_post_revise_and_reject_edit_topic_no_reply: "You can edit your topic's original post below and re-submit to make the suggested changes."reviewable_queued_post_revise_and_reject:title: "Feedback on your post"subject_template: "Feedback on your post in %{topic_title}"@@ -3456,7 +3460,7 @@ en:Feedback: %{feedback}- You can edit your original post below and re-submit to make the suggested changes, or reply to this message if you have any questions.+ %{edit_instructions}--------@@ -3479,7 +3483,7 @@ en:Feedback: %{feedback}- You can edit your topic's original post below and re-submit to make the suggested changes, or reply to this message if you have any questions.+ %{edit_instructions}--------diff --git a/spec/models/reviewable_queued_post_spec.rb b/spec/models/reviewable_queued_post_spec.rbindex f405f5d15a7..091a39e2334 100644--- a/spec/models/reviewable_queued_post_spec.rb+++ b/spec/models/reviewable_queued_post_spec.rb@@ -164,6 +164,8 @@ RSpec.describe ReviewableQueuedPost, type: :model dofeedback: args[:revise_feedback],original_post: reviewable.payload["raw"],site_name: SiteSetting.title,+ edit_instructions:+ I18n.t("system_messages.reviewable_queued_post_revise_and_reject_edit_post"),}expect(topic.topic_allowed_users.pluck(:user_id)).to include(contact_user.id)expect(topic.topic_allowed_groups.pluck(:group_id)).to include(contact_group.id)@@ -173,6 +175,7 @@ RSpec.describe ReviewableQueuedPost, type: :model dotranslation_params,).chomp,)+ expect(topic.first_post.raw).to include("reply to this message")endit "supports sending a custom revise reason" do@@ -192,6 +195,21 @@ RSpec.describe ReviewableQueuedPost, type: :model doexpect(topic.first_post.raw).to include("Boring")end+ context "when no site contact user is configured" do+ before do+ SiteSetting.site_contact_group_name = ""+ SiteSetting.site_contact_username = ""+ end++ it "omits reply instructions from the PM" do+ args = { revise_reason: "Duplicate", revise_feedback: "This is old news" }+ reviewable.perform(moderator, :revise_and_reject_post, args)++ topic = Topic.where(archetype: Archetype.private_message).last+ expect(topic.first_post.raw).not_to include("reply to this message")+ end+ end+context "when the topic is nil in the case of a new topic being created" dolet(:reviewable) { Fabricate(:reviewable_queued_post_topic) }@@ -216,6 +234,8 @@ RSpec.describe ReviewableQueuedPost, type: :model dofeedback: args[:revise_feedback],original_post: reviewable.payload["raw"],site_name: SiteSetting.title,+ edit_instructions:+ I18n.t("system_messages.reviewable_queued_post_revise_and_reject_edit_topic"),}expect(topic.first_post.raw.chomp).to eq(I18n.t(