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"
This commit is contained in:
Robin Ward 2019-06-05 12:12:13 -04:00
parent cdd2c8ef4a
commit f1d547c301
9 changed files with 55 additions and 7 deletions

View File

@ -12,9 +12,8 @@
<div class='post-contents-wrapper'> <div class='post-contents-wrapper'>
{{reviewable-created-by user=reviewable.target_created_by tagName=''}} {{reviewable-created-by user=reviewable.target_created_by tagName=''}}
<div class='post-contents'> <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'> <div class='post-body'>
{{#if reviewable.blank_post}} {{#if reviewable.blank_post}}
<p>{{i18n "review.deleted_post"}}</p> <p>{{i18n "review.deleted_post"}}</p>
{{else}} {{else}}

View File

@ -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>

View File

@ -10,7 +10,7 @@
{{reviewable-created-by user=reviewable.created_by tagName=''}} {{reviewable-created-by user=reviewable.created_by tagName=''}}
<div class='post-contents'> <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'> <div class='post-body'>
{{cook-text reviewable.payload.raw}} {{cook-text reviewable.payload.raw}}

View File

@ -389,6 +389,23 @@
display: flex; 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 { .post-contents {
width: 100%; width: 100%;

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true # frozen_string_literal: true
class ReviewableFlaggedPostSerializer < ReviewableSerializer 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 attributes :blank_post, :post_updated_at, :post_version
def post_version def post_version

View File

@ -2,6 +2,8 @@
class ReviewableQueuedPostSerializer < ReviewableSerializer class ReviewableQueuedPostSerializer < ReviewableSerializer
attributes :reply_to_post_number
payload_attributes( payload_attributes(
:raw, :raw,
:title, :title,
@ -11,11 +13,18 @@ class ReviewableQueuedPostSerializer < ReviewableSerializer
:is_warning, :is_warning,
:first_post_checks, :first_post_checks,
:featured_link, :featured_link,
:reply_to_post_number,
:is_poll, :is_poll,
:typing_duration_msecs, :typing_duration_msecs,
:composer_open_duration_msecs, :composer_open_duration_msecs,
:tags :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 end

View File

@ -363,6 +363,7 @@ en:
placeholder: "type the message title here" placeholder: "type the message title here"
review: review:
in_reply_to: "in reply to"
claim_help: claim_help:
optional: "You can claim this item to prevent others from reviewing it." optional: "You can claim this item to prevent others from reviewing it."
required: "You must claim items before you can review them." required: "You must claim items before you can review them."

View File

@ -194,10 +194,17 @@ class NewPostManager
# Enqueue this post # Enqueue this post
def enqueue(reason = nil) def enqueue(reason = nil)
result = NewPostResult.new(:enqueued) 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( reviewable = ReviewableQueuedPost.new(
created_by: @user, created_by: @user,
payload: { raw: @args[:raw], tags: @args[:tags] }, payload: payload,
topic_id: @args[:topic_id], topic_id: @args[:topic_id],
reviewable_by_moderator: true reviewable_by_moderator: true
) )

View File

@ -810,7 +810,10 @@ describe PostsController do
it 'queues the post if min_first_post_typing_time is not met' do it 'queues the post if min_first_post_typing_time is not met' do
post "/posts.json", params: { post "/posts.json", params: {
raw: 'this is the test content', 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) expect(response.status).to eq(200)
@ -822,6 +825,9 @@ describe PostsController do
expect(user).to be_silenced expect(user).to be_silenced
rp = ReviewableQueuedPost.find_by(created_by: user) 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(rp.reviewable_scores.first.reason).to eq('fast_typer')
expect(parsed['pending_post']).to be_present expect(parsed['pending_post']).to be_present