UX: Update post actions to "Approve Post" and "Reject Post"

UX: Update post actions to “Approve Post” and “Reject Post”

This should be more clear.

diff --git a/app/controllers/queued_posts_controller.rb b/app/controllers/queued_posts_controller.rb
index e2afe3d..d3ef8d2 100644
--- a/app/controllers/queued_posts_controller.rb
+++ b/app/controllers/queued_posts_controller.rb
@@ -37,9 +37,9 @@ class QueuedPostsController < ApplicationController
     state = update_params[:state]
     begin
       if state == 'approved'
-        reviewable.perform(current_user, :approve)
+        reviewable.perform(current_user, :approve_post)
       elsif state == 'rejected'
-        reviewable.perform(current_user, :reject)
+        reviewable.perform(current_user, :reject_post)
         if update_params[:delete_user] == 'true' && guardian.can_delete_user?(reviewable.created_by)
           UserDestroyer.new(current_user).destroy(reviewable.created_by, user_deletion_opts)
         end
diff --git a/app/jobs/scheduled/auto_queue_handler.rb b/app/jobs/scheduled/auto_queue_handler.rb
index 46072b8..78d8a8a 100644
--- a/app/jobs/scheduled/auto_queue_handler.rb
+++ b/app/jobs/scheduled/auto_queue_handler.rb
@@ -16,7 +16,7 @@ module Jobs
         if reviewable.is_a?(ReviewableFlaggedPost)
           reviewable.perform(Discourse.system_user, :ignore)
         elsif reviewable.is_a?(ReviewableQueuedPost)
-          reviewable.perform(Discourse.system_user, :reject)
+          reviewable.perform(Discourse.system_user, :reject_post)
         elsif reviewable.is_a?(ReviewableUser)
           reviewable.perform(Discourse.system_user, :reject_user_delete)
         end
diff --git a/app/models/reviewable_queued_post.rb b/app/models/reviewable_queued_post.rb
index 289705b..1ab4dc2 100644
--- a/app/models/reviewable_queued_post.rb
+++ b/app/models/reviewable_queued_post.rb
@@ -10,8 +10,20 @@ class ReviewableQueuedPost < Reviewable
 
   def build_actions(actions, guardian, args)
     if guardian.is_staff?
-      actions.add(:approve) unless approved?
-      actions.add(:reject) unless rejected?
+
+      unless approved?
+        actions.add(:approve_post) do |a|
+          a.icon = 'check'
+          a.label = "reviewables.actions.approve_post.title"
+        end
+      end
+
+      unless rejected?
+        actions.add(:reject_post) do |a|
+          a.icon = 'times'
+          a.label = "reviewables.actions.reject_post.title"
+        end
+      end
 
       if pending? && guardian.can_delete_user?(created_by)
         actions.add(:delete_user) do |action|
@@ -46,7 +58,7 @@ class ReviewableQueuedPost < Reviewable
     result
   end
 
-  def perform_approve(performed_by, args)
+  def perform_approve_post(performed_by, args)
     created_post = nil
 
     creator = PostCreator.new(created_by, create_options.merge(
@@ -83,7 +95,7 @@ class ReviewableQueuedPost < Reviewable
     create_result(:success, :approved) { |result| result.created_post = created_post }
   end
 
-  def perform_reject(performed_by, args)
+  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 86ade46..c433b7f 100644
--- a/config/locales/server.en.yml
+++ b/config/locales/server.en.yml
@@ -4477,6 +4477,10 @@ en:
         title: "Ignore"
       approve:
         title: "Approve"
+      approve_post:
+        title: "Approve Post"
+      reject_post:
+        title: "Reject Post"
       approve_user:
         title: "Approve User"
       reject_user:
diff --git a/spec/components/new_post_manager_spec.rb b/spec/components/new_post_manager_spec.rb
index 837c81d..dd78f18 100644
--- a/spec/components/new_post_manager_spec.rb
+++ b/spec/components/new_post_manager_spec.rb
@@ -294,7 +294,7 @@ describe NewPostManager do
       expect(Reviewable.list_for(Discourse.system_user).count).to eq(1)
       expect(@counter).to be(0)
 
-      reviewable.perform(Discourse.system_user, :approve)
+      reviewable.perform(Discourse.system_user, :approve_post)
 
       manager = NewPostManager.new(
         topic.user,
diff --git a/spec/models/reviewable_queued_post_spec.rb b/spec/models/reviewable_queued_post_spec.rb
index a7c78f4..1ab47bd 100644
--- a/spec/models/reviewable_queued_post_spec.rb
+++ b/spec/models/reviewable_queued_post_spec.rb
@@ -35,16 +35,16 @@ RSpec.describe ReviewableQueuedPost, type: :model do
 
     context "actions" do
 
-      context "approve" do
+      context "approve_post" do
         it 'triggers an extensibility event' do
-          event = DiscourseEvent.track(:approved_post) { reviewable.perform(moderator, :approve) }
+          event = DiscourseEvent.track(:approved_post) { reviewable.perform(moderator, :approve_post) }
           expect(event).to be_present
           expect(event[:params].first).to eq(reviewable)
         end
 
         it "creates a post" do
           topic_count, post_count = Topic.count, Post.count
-          result = reviewable.perform(moderator, :approve)
+          result = reviewable.perform(moderator, :approve_post)
           expect(result.success?).to eq(true)
           expect(result.created_post).to be_present
           expect(result.created_post).to be_valid
@@ -64,12 +64,12 @@ RSpec.describe ReviewableQueuedPost, type: :model do
           expect(notifications).to be_present
 
           # We can't approve twice
-          expect(-> { reviewable.perform(moderator, :approve) }).to raise_error(Reviewable::InvalidAction)
+          expect(-> { reviewable.perform(moderator, :approve_post) }).to raise_error(Reviewable::InvalidAction)
         end
 
         it "skips validations" do
           reviewable.payload['raw'] = 'x'
-          result = reviewable.perform(moderator, :approve)
+          result = reviewable.perform(moderator, :approve_post)
           expect(result.created_post).to be_present
         end
 
@@ -82,28 +82,28 @@ RSpec.describe ReviewableQueuedPost, type: :model do
           SiteSetting.num_users_to_silence_new_user = 1
           expect(Guardian.new(newuser).can_create_post?(topic)).to eq(false)
 
-          result = reviewable.perform(moderator, :approve)
+          result = reviewable.perform(moderator, :approve_post)
           expect(result.success?).to eq(true)
         end
 
       end
 
-      context "reject" do
+      context "reject_post" do
         it 'triggers an extensibility event' do
-          event = DiscourseEvent.track(:rejected_post) { reviewable.perform(moderator, :reject) }
+          event = DiscourseEvent.track(:rejected_post) { reviewable.perform(moderator, :reject_post) }
           expect(event).to be_present
           expect(event[:params].first).to eq(reviewable)
         end
 
         it "doesn't create a post" do
           post_count = Post.count
-          result = reviewable.perform(moderator, :reject)
+          result = reviewable.perform(moderator, :reject_post)
           expect(result.success?).to eq(true)
           expect(result.created_post).to be_nil
           expect(Post.count).to eq(post_count)
 
           # We can't reject twice
-          expect(-> { reviewable.perform(moderator, :reject) }).to raise_error(Reviewable::InvalidAction)
+          expect(-> { reviewable.perform(moderator, :reject_post) }).to raise_error(Reviewable::InvalidAction)
         end
       end
 
@@ -147,7 +147,7 @@ RSpec.describe ReviewableQueuedPost, type: :model do
 
     it "creates the post and topic when approved" do
       topic_count, post_count = Topic.count, Post.count
-      result = reviewable.perform(moderator, :approve)
+      result = reviewable.perform(moderator, :approve_post)
 
       expect(result.success?).to eq(true)
       expect(result.created_post).to be_present
@@ -163,7 +163,7 @@ RSpec.describe ReviewableQueuedPost, type: :model do
 
     it "creates the post and topic when rejected" do
       topic_count, post_count = Topic.count, Post.count
-      result = reviewable.perform(moderator, :reject)
+      result = reviewable.perform(moderator, :reject_post)
 

[... diff too long, it was truncated ...]

GitHub sha: 6f56fba0

1 Like

This commit has been mentioned on Discourse Meta. There might be relevant details there: