Skip to content

Commit

Permalink
FEATURE: Show "in reply to" on the review queue
Browse files Browse the repository at this point in the history
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"
  • Loading branch information
eviltrout committed Jun 5, 2019
1 parent cdd2c8e commit f1d547c
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand Down
Original file line number Diff line number Diff line change
@@ -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>
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand Down
17 changes: 17 additions & 0 deletions app/assets/stylesheets/common/base/reviewables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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%;
Expand Down
2 changes: 1 addition & 1 deletion app/serializers/reviewable_flagged_post_serializer.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down
11 changes: 10 additions & 1 deletion app/serializers/reviewable_queued_post_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

class ReviewableQueuedPostSerializer < ReviewableSerializer

attributes :reply_to_post_number

payload_attributes(
:raw,
:title,
Expand All @@ -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
1 change: 1 addition & 0 deletions config/locales/client.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
9 changes: 8 additions & 1 deletion lib/new_post_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,17 @@ def perform
# 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
)
Expand Down
8 changes: 7 additions & 1 deletion spec/requests/posts_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,10 @@
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)
Expand All @@ -822,6 +825,9 @@
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
Expand Down

0 comments on commit f1d547c

Please sign in to comment.