From 817661aed9b114d8ea2d98a2c5593a4af450889f Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Wed, 26 Jun 2019 12:20:38 -0400 Subject: [PATCH] UX: Require a confirmation if approving a post in a closed topic --- app/models/reviewable_queued_post.rb | 19 ++++++++++++++++--- config/locales/server.en.yml | 1 + 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/app/models/reviewable_queued_post.rb b/app/models/reviewable_queued_post.rb index e0fedce6973..7fc6bc17fd3 100644 --- a/app/models/reviewable_queued_post.rb +++ b/app/models/reviewable_queued_post.rb @@ -13,9 +13,18 @@ class ReviewableQueuedPost < Reviewable def build_actions(actions, guardian, args) unless approved? - actions.add(:approve_post) do |a| - a.icon = 'check' - a.label = "reviewables.actions.approve_post.title" + + if topic&.closed? + actions.add(:approve_post_closed) do |a| + a.icon = 'check' + a.label = "reviewables.actions.approve_post.title" + a.confirm_message = "reviewables.actions.approve_post.confirm_closed" + end + else + actions.add(:approve_post) do |a| + a.icon = 'check' + a.label = "reviewables.actions.approve_post.title" + end end end @@ -106,6 +115,10 @@ class ReviewableQueuedPost < Reviewable end end + def perform_approve_post_closed(performed_by, args) + perform_approve_post(performed_by, args) + end + def perform_reject_post(performed_by, args) # Backwards compatibility, new code should listen for `reviewable_transitioned_to` DiscourseEvent.trigger(:rejected_post, self) diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index 2140b1f407a..69b00cb78bb 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -4521,6 +4521,7 @@ en: title: "Approve" approve_post: title: "Approve Post" + confirm_closed: "This topic is closed. Would you like to create the post anyway?" reject_post: title: "Reject Post" approve_user: