Skip to content

A platform for community discussion. Free, open, simple.

UX: reviewable refresh design and functionality improvements (#35841)

Krisd5cf6ce1e395
diff --git a/app/assets/stylesheets/admin/admin_config_area.scss b/app/assets/stylesheets/admin/admin_config_area.scss
index 52498e2a3ef..0cbf3859d33 100644
--- a/app/assets/stylesheets/admin/admin_config_area.scss
+++ b/app/assets/stylesheets/admin/admin_config_area.scss
@@ -82,7 +82,7 @@
&__aside {
/* use for help inset */
- flex: 0 1 30%;
+ flex: 0 1 20%;
padding: var(--space-2);
@media (max-width: $mobile-breakpoint) {
diff --git a/app/assets/stylesheets/common/base/review.scss b/app/assets/stylesheets/common/base/review.scss
index 546a4215fdb..fb95c1eba48 100644
--- a/app/assets/stylesheets/common/base/review.scss
+++ b/app/assets/stylesheets/common/base/review.scss
@@ -1,30 +1,12 @@
@use "lib/viewport";
:root {
- --d-review-reason-spam-bg: #fee2e2;
- --d-review-reason-spam-text: #b91c1c;
- --d-review-reason-spam-count-bg: #b91c1c;
- --d-review-reason-spam-count-text: #fee2e2;
- --d-review-reason-off-topic-bg: #fff7dc;
- --d-review-reason-off-topic-text: #5e450c;
- --d-review-reason-off-topic-count-bg: #5e450c;
- --d-review-reason-off-topic-count-text: #fff7dc;
- --d-review-reason-illegal-bg: #fff5f5;
- --d-review-reason-illegal-text: #4b0000;
- --d-review-reason-illegal-count-bg: #4b0000;
- --d-review-reason-illegal-count-text: #fff5f5;
- --d-review-reason-inappropriate-bg: #ffedd5;
- --d-review-reason-inappropriate-text: #c2410c;
- --d-review-reason-inappropriate-count-bg: #c2410c;
- --d-review-reason-inappropriate-count-text: #ffedd5;
- --d-review-reason-other-bg: #dee7f1;
- --d-review-reason-other-text: #334155;
- --d-review-reason-other-count-bg: #334155;
- --d-review-reason-other-count-text: #dee7f1;
- --d-review-reason-custom-bg: #fef3c7;
- --d-review-reason-custom-text: #92400e;
- --d-review-reason-custom-count-bg: #92400e;
- --d-review-reason-custom-count-text: #fef3c7;
+ --d-review-reason-spam-text: light-dark(#7c3aed, #a78bfa);
+ --d-review-reason-off-topic-text: light-dark(#059669, #6ee7b7);
+ --d-review-reason-illegal-text: light-dark(#dc2626, #f87171);
+ --d-review-reason-inappropriate-text: light-dark(#ea580c, #fb923c);
+ --d-review-reason-other-text: light-dark(#4b5563, #9ca3af);
+ --d-review-reason-custom-text: light-dark(#c026d3, #e879f9);
}
.review-item {
@@ -41,7 +23,7 @@
&__primary-content {
position: relative;
- flex: 0 1 70%;
+ flex: 0 1 75%;
min-width: 0;
@include viewport.from(sm) {
@@ -53,20 +35,33 @@
}
}
+ .reviewable-created-date {
+ font-size: var(--font-down-1);
+ color: var(--primary-medium);
+ white-space: nowrap;
+ align-self: baseline;
+ padding-block: var(--space-1);
+ line-height: var(--line-height-small);
+ }
+
.reviewable-permalink-copy {
position: relative;
- top: -0.35em;
right: calc(var(--space-2) * -1);
- margin-left: calc(var(--space-4) * -1);
+ padding-block: 0.15em;
+ align-self: center;
.post-action-feedback-alert {
top: -1rem;
- left: 40%;
+ left: 60%;
+ }
+
+ > .d-icon {
+ margin-right: 0;
}
}
&__aside {
- flex: 0 1 30%;
+ flex: 0 1 25%;
min-width: 0;
position: sticky;
top: var(--header-offset);
@@ -97,6 +92,7 @@
&-title {
line-height: var(--line-height-medium);
+ text-wrap: pretty;
}
}
@@ -106,7 +102,7 @@
&__header {
display: grid;
- grid-template-columns: 1fr auto auto;
+ grid-template-columns: 1fr auto auto auto;
gap: var(--space-2);
align-items: start;
background-color: var(--primary-very-low);
@@ -133,7 +129,12 @@
&__flag-badges {
display: flex;
flex-wrap: wrap;
- gap: var(--space-1);
+ gap: 0;
+
+ .review-item__flag-reason:not(:last-child)::after {
+ content: ",";
+ margin-right: var(--space-1);
+ }
}
&__meta {
@@ -165,6 +166,17 @@
display: flex;
gap: var(--space-2);
+ .deleted-user {
+ display: flex;
+ align-items: center;
+ gap: var(--space-2);
+
+ .d-icon {
+ font-size: var(--font-down-2);
+ color: var(--primary-high);
+ }
+ }
+
.names {
display: inline-block;
@@ -180,17 +192,23 @@
padding: var(--space-4);
&-content-wrapper {
- padding-top: var(--space-4);
- border-top: 4px solid var(--primary-low);
width: 100%;
}
&-content {
+ box-sizing: border-box;
+ width: 100%;
max-height: 300px;
overflow: auto;
scrollbar-color: var(--primary-low) transparent;
transition: scrollbar-color 0.25s ease-in-out;
transition-delay: 0.5s;
+ background: var(--primary-very-low);
+ padding: var(--space-4);
+
+ .lightbox-wrapper img {
+ display: block;
+ }
pre,
code {
@@ -215,6 +233,10 @@
p:first-of-type {
margin-top: 0;
}
+
+ p:last-of-type {
+ margin-bottom: 0;
+ }
}
}
@@ -248,17 +270,25 @@
.reviewable-claimed-topic {
flex-direction: column;
align-items: stretch;
+ white-space: nowrap;
+
+ .d-button-label {
+ @include ellipsis;
+ }
}
&__assigned {
display: flex;
- justify-content: center;
align-items: center;
gap: var(--space-2);
.d-icon {
color: var(--primary-high);
}
+
+ .created-by {
+ @include ellipsis;
+ }
}
}
@@ -288,7 +318,6 @@
.review-item__flag-reason {
display: inline-flex;
align-items: center;
- gap: var(--space-1);
line-height: 1;
&.--spam {
@@ -319,43 +348,7 @@
.review-item__flag-count {
display: inline-flex;
- align-items: center;
- justify-content: center;
- border-radius: 999px;
- min-width: 1rem;
- padding: var(--space-1) var(--space-half);
- font-size: var(--font-down-3);
-
- &.--spam {
- background-color: var(--d-review-reason-spam-count-bg);
- color: var(--d-review-reason-spam-count-text);
- }
-
- &.--off-topic {
- background-color: var(--d-review-reason-off-topic-count-bg);
- color: var(--d-review-reason-off-topic-count-text);
- }
-
- &.--illegal {
- background-color: var(--d-review-reason-illegal-count-bg);
- color: var(--d-review-reason-illegal-count-text);
- }
-
- &.--inappropriate {
- background-color: var(--d-review-reason-inappropriate-count-bg);
- color: var(--d-review-reason-inappropriate-count-text);
- }
-
- &.--other,
- &.--needs-approval {
- background-color: var(--d-review-reason-other-count-bg);
- color: var(--d-review-reason-other-count-text);
- }
-
- &.--custom {
- background-color: var(--d-review-reason-custom-count-bg);
- color: var(--d-review-reason-custom-count-text);
- }
+ margin-left: var(--space-1);
}
.review-insight {
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index 7248891a221..1d1003fae5c 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -401,7 +401,7 @@ en:
joined: "Joined"
admin_title: "Admin"
show_more: "show more"
- show_help: "options"
+ show_help: "Options"
links: "Links"
links_lowercase:
one: "link"
@@ -780,7 +780,7 @@ en:
topic: "Topic:"
filtered_topic: "You have filtered to reviewable content in a single topic."
filtered_user: "User"
- filtered_reviewed_by: "Reviewed By"
+ filtered_reviewed_by: "Reviewed by"
show_all_topics: "show all topics"
deleted_post: "(post deleted)"
deleted_user: "(user deleted)"
@@ -831,7 +831,7 @@ en:
replies:
one: "%{count} reply"
other: "%{count} replies"
- edit: "Edit"
+ edit: "Edit Post"
save: "Save"
cancel: "Cancel"
new_topic: "Approving this item will create a new topic"
@@ -855,7 +855,7 @@ en:
created_at_asc: "Created At (reverse)"
priority:
- title: "Minimum Priority"
+ title: "Minimum priority"
any: "(any)"
low: "Low"
medium: "Medium"
@@ -927,6 +927,7 @@ en:
post_flagged_as: "Post flagged as"
chat_flagged_as: "Chat flagged as"
queued_post_label: "Queued post"
+ queued_topic_label: "Queued topic"
user_label: "User"
assigned_to: "Assigned to"
moderator_actions: "Moderator actions"
@@ -951,7 +952,7 @@ en:
chars_remaining: "%{count} characters remaining"
delete_note: "Delete this note"
delete: "Delete"
- new_topic_label: "New topic"
+ topic_label: "Topic"
queued_user: "Queued user"
posted_in: "Posted in"
flagged_user: "Flagged user"
@@ -967,9 +968,11 @@ en:
flagged_by_users:
one: "Flagged by %{count} unique user"
other: "Flagged by %{count} unique users"
- similar_posts: "Similar past posts"
- flagged_in_timeframe: "%{count} flagged previously"
- user_activity: "User activity"
+ similar_posts: "Past violations"
+ flagged_in_timeframe:
+ one: "%{count} confirmed flag"
+ other: "%{count} confirmed flags"
+ user_activity: "User info"
activities:
new_account: "new account"
trust_level: "trust level: %{trustLevelName}"
diff --git a/frontend/discourse/app/components/modal/revise-and-reject-post-reviewable.gjs b/frontend/discourse/app/components/modal/revise-and-reject-post-reviewable.gjs
index 323e0f1d7b3..542867bb52c 100644
--- a/frontend/discourse/app/components/modal/revise-and-reject-post-reviewable.gjs
+++ b/frontend/discourse/app/components/modal/revise-and-reject-post-reviewable.gjs
@@ -18,7 +18,7 @@ const OTHER_REASON = "other_reason";
export default class ReviseAndRejectPostReviewable extends Component {
@service siteSettings;
- @tracked reason;
+ @tracked reason = OTHER_REASON;
@tracked customReason;
@tracked feedback;
@tracked submitting = false;
diff --git a/frontend/discourse/app/components/reviewable-item.gjs b/frontend/discourse/app/components/reviewable-item.gjs
index bf0413f5f81..87d45e0c14e 100644
--- a/frontend/discourse/app/components/reviewable-item.gjs
+++ b/frontend/discourse/app/components/reviewable-item.gjs
@@ -662,7 +662,6 @@ export default class ReviewableItem extends Component {
{{#if this.reviewable.can_edit}}
<DButton
@disabled={{this.disabled}}
- @icon="pencil"
@action={{this.edit}}
@label="review.edit"
class="reviewable-action btn-default edit"
diff --git a/frontend/discourse/app/components/reviewable-refresh/created-by.gjs b/frontend/discourse/app/components/reviewable-refresh/created-by.gjs
index 195cdbf5cfb..9463ff72c85 100644
--- a/frontend/discourse/app/components/reviewable-refresh/created-by.gjs
+++ b/frontend/discourse/app/components/reviewable-refresh/created-by.gjs
@@ -2,6 +2,7 @@ import ReviewableCreatedByName from "discourse/components/reviewable-created-by-
import UserLink from "discourse/components/user-link";
import avatar from "discourse/helpers/avatar";
import icon from "discourse/helpers/d-icon";
+import { i18n } from "discourse-i18n";
/**
* Displays the creator information for a reviewable item.
@@ -22,7 +23,10 @@ import icon from "discourse/helpers/d-icon";
<UserLink @user={{@user}}>{{avatar @user imageSize="small"}}</UserLink>
<ReviewableCreatedByName @user={{@user}} />
{{else}}
- {{icon "trash-can" class="deleted-user-avatar"}}
+ <div class="deleted-user">
+ {{icon "trash-can" class="deleted-user-avatar"}}
+ <span class="deleted-user-name">{{i18n "review.deleted_user"}}</span>
+ </div>
{{/if}}
</div>
</template>
diff --git a/frontend/discourse/app/components/reviewable-refresh/flag-reason.gjs b/frontend/discourse/app/components/reviewable-refresh/flag-reason.gjs
index e2d56ea72a7..7ea6b39adc3 100644
--- a/frontend/discourse/app/components/reviewable-refresh/flag-reason.gjs
+++ b/frontend/discourse/app/components/reviewable-refresh/flag-reason.gjs
@@ -39,9 +39,9 @@ export default class ReviewableFlagReason extends Component {
<template>
<span class="review-item__flag-reason --{{this.scoreCSSClass}}">
{{@score.title}}
- {{#if (gt @score.count 0)}}
+ {{#if (gt @score.count 1)}}
<span class="review-item__flag-count --{{this.scoreCSSClass}}">
- {{@score.count}}
+ x{{@score.count}}
</span>
{{/if}}
</span>
diff --git a/frontend/discourse/app/components/reviewable-refresh/item.gjs b/frontend/discourse/app/components/reviewable-refresh/item.gjs
index 583fce28b95..563fc275ccb 100644
--- a/frontend/discourse/app/components/reviewable-refresh/item.gjs
+++ b/frontend/discourse/app/components/reviewable-refresh/item.gjs
@@ -26,6 +26,7 @@ import concatClass from "discourse/helpers/concat-class";
import icon from "discourse/helpers/d-icon";
import dasherizeHelper from "discourse/helpers/dasherize";
import editableValue from "discourse/helpers/editable-value";
+import formatDate from "discourse/helpers/format-date";
import { newReviewableStatus } from "discourse/helpers/reviewable-status";
import { ajax } from "discourse/lib/ajax";
import { popupAjaxError } from "discourse/lib/ajax-error";
@@ -186,10 +187,13 @@ export default class ReviewableItem extends Component {
@discourseComputed(
"siteSettings.reviewable_claiming",
"topicId",
- "reviewable.claimed_by.automatic"
+ "reviewable.claimed_by.automatic",
+ "reviewable.status"
)
- claimEnabled(claimMode, topicId, autoClaimed) {
- return (claimMode !== "disabled" || autoClaimed) && !!topicId;
+ claimEnabled(claimMode, topicId, autoClaimed, status) {
+ return (
+ (claimMode !== "disabled" || autoClaimed) && !!topicId && status === 0
+ );
}
@discourseComputed("siteSettings.reviewable_claiming", "claimEnabled")
@@ -307,8 +311,12 @@ export default class ReviewableItem extends Component {
return Object.values(scoreData);
}
- @discourseComputed("reviewable.type", "reviewable.created_from_flag")
- reviewableTypeLabel(type, createdFromFlag) {
+ @discourseComputed(
+ "reviewable.type",
+ "reviewable.created_from_flag",
+ "reviewable.topic_id"
+ )
+ reviewableTypeLabel(type, createdFromFlag, topicId) {
// handle plugin types
if (reviewableTypeLabels[type]) {
return reviewableTypeLabels[type];
@@ -320,7 +328,8 @@ export default class ReviewableItem extends Component {
}
if (type === "ReviewableQueuedPost") {
- return "review.queued_post_label";
+ // if topic_id is null it's a new topic
+ return topicId ? "review.queued_post_label" : "review.queued_topic_label";
}
if (type === "ReviewableChatMessage") {
@@ -706,10 +715,6 @@ export default class ReviewableItem extends Component {
{{/each}}
</div>
</div>
- {{newReviewableStatus
- this.reviewable.status
- this.reviewable.type
- }}
<button
type="button"
@@ -719,6 +724,16 @@ export default class ReviewableItem extends Component {
>
{{icon "d-post-share"}}
</button>
+
+ {{newReviewableStatus
+ this.reviewable.status
+ this.reviewable.type
+ }}
+
+ <span class="reviewable-created-date">
+ {{formatDate this.reviewable.created_at format="tiny"}}
+ </span>
+
</div>
{{#if this.editing}}
<div class="editable-fields">
diff --git a/frontend/discourse/app/components/reviewable-refresh/post.gjs b/frontend/discourse/app/components/reviewable-refresh/post.gjs
index 3cc53820c64..d6634265917 100644
--- a/frontend/discourse/app/components/reviewable-refresh/post.gjs
+++ b/frontend/discourse/app/components/reviewable-refresh/post.gjs
@@ -1,13 +1,19 @@
import Component from "@glimmer/component";
+import { service } from "@ember/service";
+import { htmlSafe } from "@ember/template";
+import DecoratedHtml from "discourse/components/decorated-html";
import PluginOutlet from "discourse/components/plugin-outlet";
import ReviewablePostEdits from "discourse/components/reviewable-post-edits";
import ReviewableCreatedBy from "discourse/components/reviewable-refresh/created-by";
import ReviewableTopicLink from "discourse/components/reviewable-refresh/topic-link";
import lazyHash from "discourse/helpers/lazy-hash";
-import highlightWatchedWords from "discourse/lib/highlight-watched-words";
+import { bind } from "discourse/lib/decorators";
+import highlightHTML from "discourse/lib/highlight-html";
import { i18n } from "discourse-i18n";
export default class ReviewablePost extends Component {
+ @service appEvents;
+
get metaLabel() {
return this.args.metaLabel || i18n("review.posted_in");
}
@@ -20,6 +26,33 @@ export default class ReviewablePost extends Component {
return this.args.pluginOutletName || "after-reviewable-post-body";
}
+ @bind
+ decorate(element, helper) {
+ const reviewable = this.args.reviewable;
+ if (reviewable?.reviewable_scores) {
+ const words = reviewable.reviewable_scores
+ .map((rs) => {
+ return rs.reason_type === "watched_word" ? rs.reason_data : [];
+ })
+ .flat();
+
+ if (words.length > 0) {
+ words.forEach((word) => {
+ highlightHTML(element, word, {
+ nodeName: "mark",
+ className: "watched-word-highlight",
+ });
+ });
+ }
+ }
+
+ this.appEvents.trigger(
+ "decorate-non-stream-cooked-element",
+ element,
+ helper
+ );
+ }
+
<template>
<div class="review-item__meta-content">
<div class="review-item__meta-label">{{this.metaLabel}}</div>
@@ -38,23 +71,28 @@ export default class ReviewablePost extends Component {
<div class="review-item__post">
<div class="review-item__post-content-wrapper">
- <div class="review-item__post-content">
- {{#if @reviewable.blank_post}}
+ {{#if @reviewable.blank_post}}
+ <div class="review-item__post-content">
<p>{{i18n "review.deleted_post"}}</p>
- {{else}}
- {{highlightWatchedWords @reviewable.cooked @reviewable}}
- {{/if}}
-
- <span>
- <PluginOutlet
- @name={{this.pluginOutletName}}
- @connectorTagName="div"
- @outletArgs={{lazyHash model=@reviewable}}
- />
- </span>
-
- {{yield}}
- </div>
+ </div>
+ {{else}}
+ <DecoratedHtml
+ @className="review-item__post-content"
+ @html={{htmlSafe @reviewable.cooked}}
+ @decorate={{this.decorate}}
+ @model={{@reviewable}}
+ />
+ {{/if}}
+
+ <span>
+ <PluginOutlet
+ @name={{this.pluginOutletName}}
+ @connectorTagName="div"
+ @outletArgs={{lazyHash model=@reviewable}}
+ />
+ </span>
+
+ {{yield}}
</div>
</div>
</template>
diff --git a/frontend/discourse/app/components/reviewable-refresh/queued-post.gjs b/frontend/discourse/app/components/reviewable-refresh/queued-post.gjs
index dd6188813d0..3db9e57b17c 100644
--- a/frontend/discourse/app/components/reviewable-refresh/queued-post.gjs
+++ b/frontend/discourse/app/components/reviewable-refresh/queued-post.gjs
@@ -1,11 +1,9 @@
import Component from "@glimmer/component";
-import { tracked } from "@glimmer/tracking";
import { hash } from "@ember/helper";
import { on } from "@ember/modifier";
import { action } from "@ember/object";
import { service } from "@ember/service";
import CookText from "discourse/components/cook-text";
-import DButton from "discourse/components/d-button";
import RawEmailModal from "discourse/components/modal/raw-email";
import PluginOutlet from "discourse/components/plugin-outlet";
import ReviewableCreatedBy from "discourse/components/reviewable-refresh/created-by";
@@ -20,11 +18,6 @@ import { i18n } from "discourse-i18n";
export default class ReviewableQueuedPost extends Component {
@service modal;
- @tracked isCollapsed = false;
- @tracked isLongPost = false;
- @tracked postBodyHeight = 0;
- maxPostHeight = 300;
-
@action
showRawEmail(event) {
event?.preventDefault();
@@ -35,47 +28,13 @@ export default class ReviewableQueuedPost extends Component {
});
}
- @action
- toggleContent() {
- this.isCollapsed = !this.isCollapsed;
- }
-
- get collapseButtonProps() {
- if (this.isCollapsed) {
- return {
- label: "review.show_more",
- icon: "chevron-down",
- };
- }
- return {
- label: "review.show_less",
- icon: "chevron-up",
- };
- }
-
- @action
- setPostBodyHeight(offsetHeight) {
- this.postBodyHeight = offsetHeight;
-
- if (this.postBodyHeight > this.maxPostHeight) {
- this.isCollapsed = true;
- this.isLongPost = true;
- } else {
- this.isCollapsed = false;
- this.isLongPost = false;
- }
- }
-
<template>
<div class="review-item__meta-content">
- <div class="review-item__meta-label">{{i18n
- "review.new_topic_label"
- }}</div>
+ <div class="review-item__meta-label">{{i18n "review.topic_label"}}</div>
<div class="review-item__meta-topic-title">
<ReviewableTopicLink @reviewable={{@reviewable}} @tagName="">
<div class="title-text">
- {{icon "square-plus" title="review.new_topic"}}
{{highlightWatchedWords @reviewable.payload.title @reviewable}}
</div>
{{categoryBadge @reviewable.category}}
@@ -88,7 +47,7 @@ export default class ReviewableQueuedPost extends Component {
</ReviewableTopicLink>
</div>
- <div class="review-item__meta-label">{{i18n "review.queued_user"}}</div>
+ <div class="review-item__meta-label">{{i18n "review.review_user"}}</div>
<div class="review-item__meta-flagged-user">
<ReviewableCreatedBy @user={{@reviewable.target_created_by}} />
@@ -98,24 +57,14 @@ export default class ReviewableQueuedPost extends Component {
<div class="review-item__post">
<div class="review-item__post-content">
<CookText
- class="post-body{{if this.isCollapsed ' is-collapsed'}}"
+ class="post-body"
@rawText={{highlightWatchedWords @reviewable.payload.raw @reviewable}}
@categoryId={{@reviewable.category_id}}
@topicId={{@reviewable.topic_id}}
@paintOneboxes={{true}}
@opts={{hash removeMissing=true}}
- @onOffsetHeightCalculated={{this.setPostBodyHeight}}
/>
- {{#if this.isLongPost}}
- <DButton
- @action={{this.toggleContent}}
- @label={{this.collapseButtonProps.label}}
- @icon={{this.collapseButtonProps.icon}}
- class="btn-default btn-icon post-body__toggle-btn"
- />
- {{/if}}
-
<span>
<PluginOutlet
@name="after-reviewable-queued-post-body"
diff --git a/frontend/discourse/app/components/reviewable-refresh/timeline.gjs b/frontend/discourse/app/components/reviewable-refresh/timeline.gjs
index 9eb0b148e00..6f3387587a6 100644
--- a/frontend/discourse/app/components/reviewable-refresh/timeline.gjs
+++ b/frontend/discourse/app/components/reviewable-refresh/timeline.gjs
@@ -15,6 +15,7 @@ import icon from "discourse/helpers/d-icon";
import formatDate from "discourse/helpers/format-date";
import { ajax } from "discourse/lib/ajax";
import { popupAjaxError } from "discourse/lib/ajax-error";
+import escape from "discourse/lib/escape";
import { i18n } from "discourse-i18n";
/**
@@ -81,9 +82,9 @@ export default class ReviewableTimeline extends Component {
// Build description for flagged event
let flaggedDescription = "";
if (score.reason || score.context) {
- flaggedDescription = `<p>${score.reason ?? ""}</p><p>${
- score.context ?? ""
- }</p>`;
+ flaggedDescription = `<p>${score.reason ?? ""}</p><p>${escape(
+ score.context
+ )}</p>`;
}
// Add conversation message if available
@@ -93,9 +94,9 @@ export default class ReviewableTimeline extends Component {
score.reviewable_conversation.conversation_posts.length > 0
) {
const firstPost = score.reviewable_conversation.conversation_posts[0];
- flaggedDescription += `<p>${firstPost.excerpt} (<a href="${
+ flaggedDescription += `<p>${escape(firstPost.excerpt)} (<a href="${escape(
score.reviewable_conversation.permalink
- }">${i18n("review.timeline.view_conversation")}</a>)</p>`;
+ )}">${i18n("review.timeline.view_conversation")}</a>)</p>`;
}
events.push({
@@ -159,7 +160,7 @@ export default class ReviewableTimeline extends Component {
user: note.user,
icon: "far-pen-to-square",
titleKey: "review.timeline.note_added_by",
- description: htmlSafe(`<p>${note.content}</p>`),
+ description: htmlSafe(`<p>${escape(note.content)}</p>`),
noteId: note.id,
canDelete:
this.currentUser &&
@@ -247,9 +248,11 @@ export default class ReviewableTimeline extends Component {
</Placeholder>
</InterpolatedTranslation>
</div>
- <div class="timeline-event__description">
- {{event.description}}
- </div>
+ {{#if event.description}}
+ <div class="timeline-event__description">
+ {{htmlSafe event.description}}
+ </div>
+ {{/if}}
</div>
{{#if (and (eq event.type "note") event.canDelete)}}
diff --git a/frontend/discourse/tests/integration/components/reviewable-refresh/flag-reason-test.gjs b/frontend/discourse/tests/integration/components/reviewable-refresh/flag-reason-test.gjs
index 449b84765fb..1b93e7add04 100644
--- a/frontend/discourse/tests/integration/components/reviewable-refresh/flag-reason-test.gjs
+++ b/frontend/discourse/tests/integration/components/reviewable-refresh/flag-reason-test.gjs
@@ -29,12 +29,13 @@ module(
.exists("renders the flag count element");
assert
.dom(".review-item__flag-count")
- .containsText("3", "displays the count value");
+ .containsText("x3", "displays the count value formatted as xN");
});
test("does not render count when invalid", async function (assert) {
const countScenarios = [
{ count: 0, title: "Zero count", description: "count is 0" },
+ { count: 1, title: "Single count", description: "count is 1" },
{
count: undefined,
title: "Undefined count",
@@ -76,7 +77,7 @@ module(
for (const { type, expectedClass } of flagTypes) {
const typeDescription = type || "undefined";
- const score = { type, title: "Test content", count: 1 };
+ const score = { type, title: "Test content", count: 2 };
await render(
<template><ReviewableFlagReason @score={{score}} /></template>
@@ -98,7 +99,7 @@ module(
});
test("renders title even when empty string", async function (assert) {
- const score = { type: "spam", title: "", count: 1 };
+ const score = { type: "spam", title: "", count: 2 };
await render(
<template><ReviewableFlagReason @score={{score}} /></template>
@@ -109,7 +110,7 @@ module(
.exists("renders the flag reason container");
assert
.dom(".review-item__flag-reason")
- .hasText("1", "only shows the count when title is empty");
+ .hasText("x2", "shows the count when title is empty");
});
}
);
diff --git a/spec/system/page_objects/components/review/flag_reason.rb b/spec/system/page_objects/components/review/flag_reason.rb
index 63f7cd7d989..701761b35d7 100644
--- a/spec/system/page_objects/components/review/flag_reason.rb
+++ b/spec/system/page_objects/components/review/flag_reason.rb
@@ -28,11 +28,22 @@ module PageObjects
def has_flag_reason?(reviewable, css_class:, type:, count: 1)
within_reviewable_item(reviewable) do
+ expected_text =
+ if count > 1
+ "#{ReviewableScore.type_title(type)} x#{count}"
+ else
+ ReviewableScore.type_title(type).to_s
+ end
+
expect(find(".review-item__flag-reason.--#{css_class}").text.gsub(/\s+/, " ")).to eq(
- "#{ReviewableScore.type_title(type)} #{count}",
+ expected_text,
)
- expect(page).to have_css(".review-item__flag-count.--#{css_class}")
+ if count > 1
+ expect(page).to have_css(".review-item__flag-count.--#{css_class}")
+ else
+ expect(page).to have_no_css(".review-item__flag-count.--#{css_class}")
+ end
end
end