DEV: Include context question for chat reviewables (#23332)
Chat review queue flags were missing the context message above the actions. This is probably because the (reasonably complex) logic was somewhat hard-coded to posts. After some investigation I concluded we can reuse this logic with some small amendments.
This commit is contained in:
parent
29c3f1557a
commit
d1253bc3af
|
@ -66,12 +66,10 @@
|
|||
{{/if}}
|
||||
</div>
|
||||
|
||||
{{#if (eq this.reviewable.type "ReviewableFlaggedPost")}}
|
||||
{{#if (eq this.reviewable.status 0)}}
|
||||
<h3 class="reviewable-item__context-question">
|
||||
{{this.reviewable.flaggedPostContextQuestion}}
|
||||
</h3>
|
||||
{{/if}}
|
||||
{{#if this.displayContextQuestion}}
|
||||
<h3 class="reviewable-item__context-question">
|
||||
{{this.reviewable.flaggedReviewableContextQuestion}}
|
||||
</h3>
|
||||
{{/if}}
|
||||
|
||||
<div class="reviewable-actions">
|
||||
|
|
|
@ -58,6 +58,11 @@ export default Component.extend({
|
|||
return classes;
|
||||
},
|
||||
|
||||
@discourseComputed("reviewable.created_from_flag", "reviewable.status")
|
||||
displayContextQuestion(createdFromFlag, status) {
|
||||
return createdFromFlag && status === 0;
|
||||
},
|
||||
|
||||
@discourseComputed(
|
||||
"reviewable.topic",
|
||||
"reviewable.topic_id",
|
||||
|
|
|
@ -35,14 +35,23 @@ const Reviewable = RestModel.extend({
|
|||
return "-" + dasherize(humanType);
|
||||
},
|
||||
|
||||
@discourseComputed
|
||||
flaggedPostContextQuestion() {
|
||||
@discourseComputed("resolvedType")
|
||||
humanNoun(resolvedType) {
|
||||
return I18n.t(`review.types.${underscore(resolvedType)}.noun`, {
|
||||
defaultValue: "reviewable",
|
||||
});
|
||||
},
|
||||
|
||||
@discourseComputed("humanNoun")
|
||||
flaggedReviewableContextQuestion(humanNoun) {
|
||||
const uniqueReviewableScores =
|
||||
this.reviewable_scores.uniqBy("score_type.type");
|
||||
|
||||
if (uniqueReviewableScores.length === 1) {
|
||||
if (uniqueReviewableScores[0].score_type.type === "notify_moderators") {
|
||||
return I18n.t("review.context_question.something_else_wrong");
|
||||
return I18n.t("review.context_question.something_else_wrong", {
|
||||
reviewable_type: humanNoun,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -55,6 +64,7 @@ const Reviewable = RestModel.extend({
|
|||
|
||||
return I18n.t("review.context_question.is_this_post", {
|
||||
reviewable_human_score_types: listOfQuestions,
|
||||
reviewable_type: humanNoun,
|
||||
});
|
||||
},
|
||||
|
||||
|
|
|
@ -4,6 +4,10 @@ class ReviewableFlaggedPostSerializer < ReviewableSerializer
|
|||
target_attributes :cooked, :raw, :reply_count, :reply_to_post_number
|
||||
attributes :blank_post, :post_updated_at, :post_version
|
||||
|
||||
def created_from_flag?
|
||||
true
|
||||
end
|
||||
|
||||
def post_version
|
||||
object.target&.version
|
||||
end
|
||||
|
|
|
@ -16,6 +16,7 @@ class ReviewableSerializer < ApplicationSerializer
|
|||
:score,
|
||||
:version,
|
||||
:target_created_by_trust_level,
|
||||
:created_from_flag?,
|
||||
)
|
||||
|
||||
attribute :status_for_database, key: :status
|
||||
|
@ -96,6 +97,10 @@ class ReviewableSerializer < ApplicationSerializer
|
|||
end
|
||||
end
|
||||
|
||||
def created_from_flag?
|
||||
false
|
||||
end
|
||||
|
||||
def topic_tags
|
||||
object.topic.tags.map(&:name)
|
||||
end
|
||||
|
|
|
@ -618,24 +618,27 @@ en:
|
|||
title: "Everything"
|
||||
|
||||
context_question:
|
||||
is_this_post: "Is this post %{reviewable_human_score_types}?"
|
||||
is_this_post: "Is this %{reviewable_type} %{reviewable_human_score_types}?"
|
||||
delimiter: "or"
|
||||
something_else_wrong: "Is there something wrong with this post?"
|
||||
something_else_wrong: "Is there something wrong with this %{reviewable_type}?"
|
||||
|
||||
types:
|
||||
reviewable_flagged_post:
|
||||
title: "Flagged Post"
|
||||
flagged_by: "Flagged By"
|
||||
noun: "post"
|
||||
reviewable_queued_topic:
|
||||
title: "Queued Topic"
|
||||
noun: "topic"
|
||||
reviewable_queued_post:
|
||||
title: "Queued Post"
|
||||
noun: "post"
|
||||
reviewable_user:
|
||||
title: "User"
|
||||
noun: "user"
|
||||
reviewable_post:
|
||||
title: "Post"
|
||||
reviewable_chat_message:
|
||||
title: "Flagged chat message"
|
||||
noun: "post"
|
||||
approval:
|
||||
title: "Post Needs Approval"
|
||||
description: "We've received your new post but it needs to be approved by a moderator before it will appear. Please be patient."
|
||||
|
|
|
@ -10,6 +10,10 @@ module Chat
|
|||
|
||||
has_one :chat_channel, serializer: Chat::ChannelSerializer, root: false, embed: :objects
|
||||
|
||||
def created_from_flag?
|
||||
true
|
||||
end
|
||||
|
||||
def chat_channel
|
||||
object.chat_message.chat_channel
|
||||
end
|
||||
|
|
|
@ -637,6 +637,9 @@ en:
|
|||
types:
|
||||
chat_reviewable_message:
|
||||
title: "Flagged Chat Message"
|
||||
reviewable_chat_message:
|
||||
title: "Flagged chat message"
|
||||
noun: "chat message"
|
||||
keyboard_shortcuts_help:
|
||||
chat:
|
||||
title: "Chat"
|
||||
|
|
|
@ -11,6 +11,7 @@ RSpec.describe ReviewableFlaggedPostSerializer do
|
|||
expect(json[:cooked]).to eq(p0.cooked)
|
||||
expect(json[:raw]).to eq(p0.raw)
|
||||
expect(json[:target_url]).to eq(Discourse.base_url + p0.url)
|
||||
expect(json[:created_from_flag]).to eq(true)
|
||||
end
|
||||
|
||||
it "works when the topic is deleted" do
|
||||
|
|
|
@ -15,6 +15,7 @@ RSpec.describe ReviewableSerializer do
|
|||
expect(json[:can_edit]).to eq(true)
|
||||
expect(json[:version]).to eq(0)
|
||||
expect(json[:removed_topic_id]).to be_nil
|
||||
expect(json[:created_from_flag]).to eq(false)
|
||||
end
|
||||
|
||||
it "Includes the removed topic id when the topis was deleted" do
|
||||
|
|
Loading…
Reference in New Issue