FEATURE: Show "in reply to" on the review queue

FEATURE: Show “in reply to” on the review queue

We now show if a queued or flagged post is a reply to another when in the review queue. It’s especially helpful for queued posts where normally they are linked to the topic where they are created, and you have no context about the reply.

Note that this will only apply to new queued posts going forward. Previously queued posts will not show the “in reply to”

diff --git a/app/assets/javascripts/discourse/templates/components/reviewable-flagged-post.hbs b/app/assets/javascripts/discourse/templates/components/reviewable-flagged-post.hbs
index be4407f..22b5ceb 100644
--- a/app/assets/javascripts/discourse/templates/components/reviewable-flagged-post.hbs
+++ b/app/assets/javascripts/discourse/templates/components/reviewable-flagged-post.hbs
@@ -12,9 +12,8 @@
 <div class='post-contents-wrapper'>
   {{reviewable-created-by user=reviewable.target_created_by tagName=''}}
   <div class='post-contents'>
-    {{reviewable-created-by-name user=reviewable.target_created_by tagName=''}}
+    {{reviewable-post-header reviewable=reviewable createdBy=reviewable.target_created_by tagName=''}}
     <div class='post-body'>
-
       {{#if reviewable.blank_post}}
         <p>{{i18n "review.deleted_post"}}</p>
       {{else}}
diff --git a/app/assets/javascripts/discourse/templates/components/reviewable-post-header.hbs b/app/assets/javascripts/discourse/templates/components/reviewable-post-header.hbs
new file mode 100644
index 0000000..70b7d32
--- /dev/null
+++ b/app/assets/javascripts/discourse/templates/components/reviewable-post-header.hbs
@@ -0,0 +1,9 @@
+<div class='reviewable-post-header'>
+  {{reviewable-created-by-name user=createdBy tagName=''}}
+  {{#if reviewable.reply_to_post_number}}
+    <a href={{concat reviewable.topic_url "/" reviewable.reply_to_post_number}} class='reviewable-reply-to'>
+      {{d-icon "share"}}
+      <span>{{i18n "review.in_reply_to"}}</span>
+    </a>
+  {{/if}}
+</div>
diff --git a/app/assets/javascripts/discourse/templates/components/reviewable-queued-post.hbs b/app/assets/javascripts/discourse/templates/components/reviewable-queued-post.hbs
index 1a02f4d..b5220b8 100644
--- a/app/assets/javascripts/discourse/templates/components/reviewable-queued-post.hbs
+++ b/app/assets/javascripts/discourse/templates/components/reviewable-queued-post.hbs
@@ -10,7 +10,7 @@
   {{reviewable-created-by user=reviewable.created_by tagName=''}}
 
   <div class='post-contents'>
-    {{reviewable-created-by-name user=reviewable.created_by tagName=''}}
+    {{reviewable-post-header reviewable=reviewable createdBy=reviewable.created_by tagName=''}}
 
     <div class='post-body'>
       {{cook-text reviewable.payload.raw}}
diff --git a/app/assets/stylesheets/common/base/reviewables.scss b/app/assets/stylesheets/common/base/reviewables.scss
index 8e78aed..ba89457 100644
--- a/app/assets/stylesheets/common/base/reviewables.scss
+++ b/app/assets/stylesheets/common/base/reviewables.scss
@@ -389,6 +389,23 @@
       display: flex;
     }
   }
+  .reviewable-post-header {
+    display: flex;
+    justify-content: space-between;
+    max-width: $topic-body-width;
+    width: $topic-body-width;
+    align-items: center;
+
+    .reviewable-reply-to {
+      display: flex;
+      align-items: center;
+      color: $primary-medium;
+      font-size: 0.9em;
+      .d-icon {
+        margin-right: 0.5em;
+      }
+    }
+  }
 
   .post-contents {
     width: 100%;
diff --git a/app/serializers/reviewable_flagged_post_serializer.rb b/app/serializers/reviewable_flagged_post_serializer.rb
index 9a0e28c..797fe39 100644
--- a/app/serializers/reviewable_flagged_post_serializer.rb
+++ b/app/serializers/reviewable_flagged_post_serializer.rb
@@ -1,7 +1,7 @@
 # frozen_string_literal: true
 
 class ReviewableFlaggedPostSerializer < ReviewableSerializer
-  target_attributes :cooked, :raw, :reply_count
+  target_attributes :cooked, :raw, :reply_count, :reply_to_post_number
   attributes :blank_post, :post_updated_at, :post_version
 
   def post_version
diff --git a/app/serializers/reviewable_queued_post_serializer.rb b/app/serializers/reviewable_queued_post_serializer.rb
index fa29213..dbc06ac 100644
--- a/app/serializers/reviewable_queued_post_serializer.rb
+++ b/app/serializers/reviewable_queued_post_serializer.rb
@@ -2,6 +2,8 @@
 
 class ReviewableQueuedPostSerializer < ReviewableSerializer
 
+  attributes :reply_to_post_number
+
   payload_attributes(
     :raw,
     :title,
@@ -11,11 +13,18 @@ class ReviewableQueuedPostSerializer < ReviewableSerializer
     :is_warning,
     :first_post_checks,
     :featured_link,
-    :reply_to_post_number,
     :is_poll,
     :typing_duration_msecs,
     :composer_open_duration_msecs,
     :tags
   )
 
+  def reply_to_post_number
+    object.payload['reply_to_post_number'].to_i
+  end
+
+  def include_reply_to_post_number?
+    object.payload['reply_to_post_number'].present?
+  end
+
 end
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index 65b7a27..0a761e5 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -363,6 +363,7 @@ en:
         placeholder: "type the message title here"
 
     review:
+      in_reply_to: "in reply to"
       claim_help:
         optional: "You can claim this item to prevent others from reviewing it."
         required: "You must claim items before you can review them."
diff --git a/lib/new_post_manager.rb b/lib/new_post_manager.rb
index b03bec8..ba5e468 100644
--- a/lib/new_post_manager.rb
+++ b/lib/new_post_manager.rb
@@ -194,10 +194,17 @@ class NewPostManager
   # Enqueue this post
   def enqueue(reason = nil)
     result = NewPostResult.new(:enqueued)
+    payload = {
+      raw: @args[:raw],
+      tags: @args[:tags]
+    }
+    %w(typing_duration_msecs composer_open_duration_msecs reply_to_post_number).each do |a|
+      payload[a] = @args[a].to_i if @args[a]
+    end
 
     reviewable = ReviewableQueuedPost.new(
       created_by: @user,
-      payload: { raw: @args[:raw], tags: @args[:tags] },
+      payload: payload,
       topic_id: @args[:topic_id],
       reviewable_by_moderator: true
     )
diff --git a/spec/requests/posts_controller_spec.rb b/spec/requests/posts_controller_spec.rb
index 8044572..61880b4 100644
--- a/spec/requests/posts_controller_spec.rb
+++ b/spec/requests/posts_controller_spec.rb
@@ -810,7 +810,10 @@ describe PostsController do
         it 'queues the post if min_first_post_typing_time is not met' do
           post "/posts.json", params: {
             raw: 'this is the test content',
-            title: 'this is the test title for the topic'
+            title: 'this is the test title for the topic',
+            composer_open_duration_msecs: 204,
+            typing_duration_msecs: 100,
+            reply_to_post_number: 123
           }
 
           expect(response.status).to eq(200)
@@ -822,6 +825,9 @@ describe PostsController do
           expect(user).to be_silenced
 
           rp = ReviewableQueuedPost.find_by(created_by: user)
+          expect(rp.payload['typing_duration_msecs']).to eq(100)
+          expect(rp.payload['composer_open_duration_msecs']).to eq(204)
+          expect(rp.payload['reply_to_post_number']).to eq(123)
           expect(rp.reviewable_scores.first.reason).to eq('fast_typer')
 
           expect(parsed['pending_post']).to be_present

GitHub sha: f1d547c3

1 Like