A platform for community discussion. Free, open, simple.
DEV: First pass of review queue redesign
Ella E.38194c2aec62
diff --git a/app/assets/javascripts/discourse/app/components/reviewable-refresh/created-by.gjs b/app/assets/javascripts/discourse/app/components/reviewable-refresh/created-by.gjsnew file mode 100644index 00000000000..9f889e394aa--- /dev/null+++ b/app/assets/javascripts/discourse/app/components/reviewable-refresh/created-by.gjs@@ -0,0 +1,15 @@+import ReviewableCreatedByName from "discourse/components/reviewable-created-by-name";+import UserLink from "discourse/components/user-link";+import avatar from "discourse/helpers/avatar";+import icon from "discourse/helpers/d-icon";++<template>+ <div class="created-by">+ {{#if @user}}+ <UserLink @user={{@user}}>{{avatar @user imageSize="small"}}</UserLink>+ <ReviewableCreatedByName @user={{@user}} />+ {{else}}+ {{icon "trash-can" class="deleted-user-avatar"}}+ {{/if}}+ </div>+</template>diff --git a/app/assets/javascripts/discourse/app/components/reviewable-refresh/flag-reason.gjs b/app/assets/javascripts/discourse/app/components/reviewable-refresh/flag-reason.gjsnew file mode 100644index 00000000000..aad58082537--- /dev/null+++ b/app/assets/javascripts/discourse/app/components/reviewable-refresh/flag-reason.gjs@@ -0,0 +1,12 @@+import { gt } from "truth-helpers";++<template>+ <span class="review-item__flag-reason --{{@score.type}}">+ {{#if (gt @score.count 0)}}+ <span class="review-item__flag-count --{{@score.type}}">+ {{@score.count}}+ </span>+ {{/if}}+ {{@score.title}}+ </span>+</template>diff --git a/app/assets/javascripts/discourse/app/components/reviewable-refresh/flagged-post.gjs b/app/assets/javascripts/discourse/app/components/reviewable-refresh/flagged-post.gjsnew file mode 100644index 00000000000..30d39648f1d--- /dev/null+++ b/app/assets/javascripts/discourse/app/components/reviewable-refresh/flagged-post.gjs@@ -0,0 +1,12 @@+import ReviewablePost from "discourse/components/reviewable-refresh/post";+import { i18n } from "discourse-i18n";++<template>+ <ReviewablePost+ @reviewable={{@reviewable}}+ @userLabel={{i18n "review.flagged_user"}}+ @pluginOutletName="after-reviewable-flagged-post-body"+ >+ {{yield}}+ </ReviewablePost>+</template>diff --git a/app/assets/javascripts/discourse/app/components/reviewable-refresh/insights.gjs b/app/assets/javascripts/discourse/app/components/reviewable-refresh/insights.gjsnew file mode 100644index 00000000000..520cbb73c5c--- /dev/null+++ b/app/assets/javascripts/discourse/app/components/reviewable-refresh/insights.gjs@@ -0,0 +1,95 @@+import Component from "@glimmer/component";+import icon from "discourse/helpers/d-icon";+import { i18n } from "discourse-i18n";++/**+ * Displays contextual insights about a reviewable item, including AI confidence,+ * flag volume, user history, and moderation actions. Only shows relevant insights+ * based on available data.+ *+ * @component ReviewableInsights+ *+ * @param {Reviewable} reviewable - The reviewable object containing all review data+ */+export default class ReviewableInsights extends Component {+ /**+ * Returns array of review insight objects to display+ * @returns {Array<Object>} Array of insight configuration objects+ */+ get reviewInsights() {+ const insights = [];+ const reviewable = this.args.reviewable;+ const user = this.args.reviewable.target_created_by;++ // Flag volume insight+ insights.push({+ icon: "triangle-exclamation",+ label: i18n("review.insights.flag_volume"),+ description: i18n("review.insights.flagged_by_users", {+ count: reviewable?.reviewable_scores?.length || 0,+ }),+ });++ // Similar posts insight+ if (user.flags_agreed) {+ insights.push({+ icon: "clock-rotate-left",+ label: i18n("review.insights.similar_posts"),+ description: i18n("review.insights.flagged_in_timeframe", {+ count: user.user_stat.flags_agreed,+ }),+ });+ }++ // User activity insight+ const activities = [];++ if (Date.now() - Date.parse(user.created_at) < 7 * 24 * 60 * 60 * 1000) {+ activities.push(i18n("review.insights.activities.new_account"));+ }+ activities.push(+ i18n("review.insights.activities.trust_level", {+ trustLevelName: user.trustLevel.name,+ })+ );+ activities.push(+ i18n("review.insights.activities.posts", {+ count: user.post_count,+ })+ );+ insights.push({+ icon: "users",+ label: i18n("review.insights.user_activity"),+ description: activities.join(", "),+ });++ // Visibility insight+ if (!reviewable?.topic?.visible) {+ insights.push({+ icon: "far-eye-slash",+ label: i18n("review.insights.visibility"),+ description: i18n("review.insights.topic_unlisted"),+ });+ }++ return insights;+ }++ <template>+ <div class="review-insight">+ {{#each this.reviewInsights as |insight|}}+ <div class="review-insight__item">+ <div class="review-insight__icon">+ {{icon insight.icon}}+ </div>+ <div class="review-insight__content">+ <div class="review-insight__label">{{insight.label}}</div>+ <div+ class="review-insight__description"+ >{{insight.description}}</div>+ </div>+ </div>+ {{/each}}+ </div>+ </template>+}diff --git a/app/assets/javascripts/discourse/app/components/reviewable-refresh/item.gjs b/app/assets/javascripts/discourse/app/components/reviewable-refresh/item.gjsnew file mode 100644index 00000000000..8b4cb50a5cc--- /dev/null+++ b/app/assets/javascripts/discourse/app/components/reviewable-refresh/item.gjs@@ -0,0 +1,770 @@+import { tracked } from "@glimmer/tracking";+import Component from "@ember/component";+import { fn } from "@ember/helper";+import { on } from "@ember/modifier";+import { action, set } from "@ember/object";+import { alias } from "@ember/object/computed";+import { getOwner } from "@ember/owner";+import { service } from "@ember/service";+import { classify, dasherize } from "@ember/string";+import { tagName } from "@ember-decorators/component";+import { eq } from "truth-helpers";+import DButton from "discourse/components/d-button";+import HorizontalOverflowNav from "discourse/components/horizontal-overflow-nav";+import ExplainReviewableModal from "discourse/components/modal/explain-reviewable";+import RejectReasonReviewableModal from "discourse/components/modal/reject-reason-reviewable";+import ReviseAndRejectPostReviewable from "discourse/components/modal/revise-and-reject-post-reviewable";+import ReviewableBundledAction from "discourse/components/reviewable-bundled-action";+import ReviewableClaimedTopic from "discourse/components/reviewable-claimed-topic";+import ReviewableCreatedBy from "discourse/components/reviewable-created-by";+import ReviewableFlagReason from "discourse/components/reviewable-refresh/flag-reason";+import ReviewableInsights from "discourse/components/reviewable-refresh/insights";+import ReviewableTimeline from "discourse/components/reviewable-refresh/timeline";+import icon from "discourse/helpers/d-icon";+import { newReviewableStatus } from "discourse/helpers/reviewable-status";+import { ajax } from "discourse/lib/ajax";+import { popupAjaxError } from "discourse/lib/ajax-error";+import discourseComputed, { bind } from "discourse/lib/decorators";+import optionalService from "discourse/lib/optional-service";+import Category from "discourse/models/category";+import Composer from "discourse/models/composer";+import Topic from "discourse/models/topic";+import { i18n } from "discourse-i18n";++// const IpLookup = optionalRequire("admin/components/ip-lookup");++let _components = {};++const pluginReviewableParams = {};++// The mappings defined here are default core mappings, and cannot be overridden+// by plugins.+const defaultActionModalClassMap = {+ revise_and_reject_post: ReviseAndRejectPostReviewable,+};+const actionModalClassMap = { ...defaultActionModalClassMap };++export function addPluginReviewableParam(reviewableType, param) {+ pluginReviewableParams[reviewableType]+ ? pluginReviewableParams[reviewableType].push(param)+ : (pluginReviewableParams[reviewableType] = [param]);+}++export function registerReviewableActionModal(actionName, modalClass) {+ if (Object.keys(defaultActionModalClassMap).includes(actionName)) {+ throw new Error(+ `Cannot override default action modal class for ${actionName} (mapped to ${defaultActionModalClassMap[actionName].name})!`+ );+ }+ actionModalClassMap[actionName] = modalClass;+}++function lookupComponent(context, name) {+ return getOwner(context).resolveRegistration(`component:${name}`);+}++@tagName("")+export default class ReviewableItem extends Component {+ @service dialog;+ @service modal;+ @service siteSettings;+ @service currentUser;+ @service composer;+ @service store;+ @service toasts;+ @service messageBus;+ @optionalService adminTools;++ @tracked disabled = false;+ @tracked activeTab = "insights";++ @alias("reviewable.claimed_by.automatic") autoClaimed;++ updating = null;+ editing = false;+ _updates = null;++ constructor() {+ super(...arguments);+ this.messageBus.subscribe("/reviewable_claimed", this._updateClaimedBy);+ this.messageBus.subscribe("/reviewable_action", this._updateStatus);+ }++ willDestroy() {+ super.willDestroy(...arguments);+ this.messageBus.unsubscribe("/reviewable_claimed", this._updateClaimedBy);+ this.messageBus.unsubscribe("/reviewable_action", this._updateStatus);+ }++ @discourseComputed(+ "reviewable.type",+ "reviewable.last_performing_username",+ "siteSettings.blur_tl0_flagged_posts_media",+ "reviewable.target_created_by_trust_level",+ "reviewable.deleted_at"+ )+ customClasses(+ type,+ lastPerformingUsername,+ blurEnabled,+ trustLevel,+ deletedAt+ ) {+ let classes = dasherize(type);++ if (lastPerformingUsername) {+ classes = `${classes} reviewable-stale`;+ }++ if (blurEnabled && trustLevel === 0) {+ classes = `${classes} blur-images`;+ }++ if (deletedAt) {+ classes = `${classes} reviewable-deleted`;+ }++ return classes;+ }++ @discourseComputed(+ "reviewable.created_from_flag",+ "reviewable.status",+ "claimOptional",+ "claimRequired",+ "reviewable.claimed_by"+ )+ displayContextQuestion(+ createdFromFlag,+ status,+ claimOptional,+ claimRequired,+ claimedBy+ ) {+ return (+ createdFromFlag &&+ status === 0 &&+ (claimOptional || (claimRequired && claimedBy !== null))+ );+ }++ @discourseComputed(+ "reviewable.topic",+ "reviewable.topic_id",+ "reviewable.removed_topic_id"+ )+ topicId(topic, topicId, removedTopicId) {+ return (topic && topic.id) || topicId || removedTopicId;+ }++ @discourseComputed(+ "siteSettings.reviewable_claiming",+ "topicId",+ "reviewable.claimed_by.automatic"+ )+ claimEnabled(claimMode, topicId, autoClaimed) {+ return (claimMode !== "disabled" || autoClaimed) && !!topicId;+ }++ @discourseComputed("siteSettings.reviewable_claiming", "claimEnabled")+ claimOptional(claimMode, claimEnabled) {+ return !claimEnabled || claimMode === "optional";+ }++ @discourseComputed("siteSettings.reviewable_claiming", "claimEnabled")+ claimRequired(claimMode, claimEnabled) {+ return claimEnabled && claimMode === "required";+ }++ @discourseComputed(+ "claimEnabled",+ "siteSettings.reviewable_claiming",+ "reviewable.claimed_by"+ )+ canPerform(claimEnabled, claimMode, claimedBy) {+ if (!claimEnabled) {+ return true;+ }++ if (claimedBy) {+ return claimedBy.user.id === this.currentUser.id;+ }++ return claimMode !== "required";+ }++ @discourseComputed(+ "siteSettings.reviewable_claiming",+ "reviewable.claimed_by"+ )+ claimHelp(claimMode, claimedBy) {+ if (claimedBy) {+ if (claimedBy.user.id === this.currentUser.id) {+ return i18n("review.claim_help.claimed_by_you");+ } else if (claimedBy.automatic) {+ return i18n("review.claim_help.automatically_claimed_by", {+ username: claimedBy.user.username,+ });+ } else {+ return i18n("review.claim_help.claimed_by_other", {+ username: claimedBy.user.username,+ });+ }+ }++ return claimMode === "optional"+ ? i18n("review.claim_help.optional")+ : i18n("review.claim_help.required");+ }++ // Find a component to render, if one exists. For example:+ // `ReviewableUser` will return `reviewable/user` or `reviewable-user`.+ // The former is the new reviewable component, so will only be returned if it exists.+ @discourseComputed("reviewable.type")+ reviewableComponent(type) {+ if (_components[type] !== undefined) {+ return _components[type];+ }++ const owner = getOwner(this);+ const dasherized = dasherize(type);+ const componentNames = [+ dasherized.replace("reviewable-", "reviewable-refresh/"),+ dasherized,+ ];++ for (const componentName of componentNames) {+ const componentExists =+ owner.hasRegistration(`component:${componentName}`) ||+ owner.hasRegistration(`template:components/${componentName}`);+ if (componentExists) {+ _components[type] = componentName;+ break;+ }+ }+ return _components[type] || null;+ }++ @discourseComputed("_updates.category_id", "reviewable.category.id")+ tagCategoryId(updatedCategoryId, categoryId) {+ return updatedCategoryId || categoryId;+ }++ @discourseComputed("reviewable.type", "reviewable.target_created_by")+ showIpLookup(reviewableType) {+ return (+ reviewableType !== "ReviewableUser" &&+ this.currentUser.staff &&+ this.reviewable.target_created_by+ );+ }++ @discourseComputed("reviewable.reviewable_scores")+ scoreSummary(scores) {+ const scoreData = scores.reduce((acc, score) => {+ if (!acc[score.score_type.type]) {+ acc[score.score_type.type] = {+ title: score.score_type.title,+ type: score.score_type.type,+ count: 0,+ };+ }++ acc[score.score_type.type].count += 1;+ return acc;+ }, {});++ return Object.values(scoreData);+ }++ @bind+ _updateClaimedBy(data) {+ const user = data.user ? this.store.createRecord("user", data.user) : null;++ if (data.topic_id === this.reviewable.topic.id) {+ if (user) {+ this.reviewable.set("claimed_by", { user, automatic: data.automatic });+ } else {+ this.reviewable.set("claimed_by", null);+ }+ }+ }++ @bind+ _updateStatus(data) {+ if (data.remove_reviewable_ids.includes(this.reviewable.id)) {+ delete data.remove_reviewable_ids;+ this._performResult(data, {}, this.reviewable);+ }+ }++ @bind+ async _performConfirmed(performableAction, additionalData = {}) {+ let reviewable = this.reviewable;++ let performAction = async () => {+ this.disabled = true;++ let version = reviewable.get("version");+ this.set("updating", true);++ const data = {+ send_email: reviewable.sendEmail,+ reject_reason: reviewable.rejectReason,+ ...additionalData,+ };++ (pluginReviewableParams[reviewable.type] || []).forEach((param) => {+ if (reviewable[param]) {+ data[param] = reviewable[param];+ }+ });++ return ajax(+ `/review/${reviewable.id}/perform/${performableAction.server_action}?version=${version}`,+ {+ type: "PUT",+ dataType: "json",+ data,+ }+ )+ .then((result) =>+ this._performResult(+ result.reviewable_perform_result,+ performableAction,+ reviewable+ )+ )+ .catch(popupAjaxError)+ .finally(() => {+ this.set("updating", false);+ this.disabled = false;+ });+ };++ if (performableAction.client_action) {+ let actionMethod =+ this[`client${classify(performableAction.client_action)}`];+ if (actionMethod) {+ if (await this.#claimReviewable()) {+ await actionMethod.call(this, reviewable, performAction);+ }+ } else {+ // eslint-disable-next-line no-console+ console.error(+ `No handler for ${performableAction.client_action} found`+ );+ }+ } else {+ await performAction();+ }++ return this.#unclaimAutomaticReviewable();+ }++ _performResult(result, performableAction, reviewable) {+ // "fast track" to update the current user's reviewable count before the message bus finds out.+ if (result.reviewable_count !== undefined) {+ this.currentUser.updateReviewableCount(result.reviewable_count);+ }++ if (result.unseen_reviewable_count !== undefined) {+ this.currentUser.set(+ "unseen_reviewable_count",+ result.unseen_reviewable_count+ );+ }++ if (performableAction.completed_message) {+ this.toasts.success({+ data: { message: performableAction.completed_message },+ });+ }++ if (this.remove && result.remove_reviewable_ids) {+ this.remove(result.remove_reviewable_ids);+ } else {+ return this.store.find("reviewable", reviewable.id);+ }+ }++ clientSuspend(reviewable, performAction) {+ return this._penalize("showSuspendModal", reviewable, performAction);+ }++ clientSilence(reviewable, performAction) {+ return this._penalize("showSilenceModal", reviewable, performAction);+ }++ async clientEdit(reviewable, performAction) {+ if (!this.currentUser) {+ return this.dialog.alert(i18n("post.controls.edit_anonymous"));+ }+ const post = await this.store.find("post", reviewable.post_id);+ const topic_json = await Topic.find(post.topic_id, {});++ const topic = Topic.create(topic_json);+ post.set("topic", topic);++ if (!post.can_edit) {+ return false;+ }++ const opts = {+ post,+ action: Composer.EDIT,+ draftKey: post.get("topic.draft_key"),+ draftSequence: post.get("topic.draft_sequence"),+ skipJumpOnSave: true,+ };++ this.composer.open(opts);++ return performAction();+ }++ _penalize(adminToolMethod, reviewable, performAction) {+ let adminTools = this.adminTools;+ if (adminTools) {+ let createdBy = reviewable.get("target_created_by");+ let postId = reviewable.get("post_id");+ let postEdit = reviewable.get("raw");++ return adminTools[adminToolMethod](createdBy, {+ postId,+ postEdit,+ before: performAction,+ });+ }+ }++ async #claimReviewable() {+ if (!this.reviewable.topic) {+ // We can't claim a reviewable without a topic, so treat it as claimed+ return true;+ }++ if (!this.reviewable.claimed_by) {+ const claim = this.store.createRecord("reviewable-claimed-topic");++ try {+ await claim.save({+ topic_id: this.reviewable.topic.id,+ automatic: true,+ });+ this.reviewable.set("claimed_by", {+ user: this.currentUser,+ automatic: true,+ });+ } catch (e) {+ popupAjaxError(e);+ return false;+ }+ }++ return this.reviewable.claimed_by?.user?.id === this.currentUser.id;+ }++ async #unclaimAutomaticReviewable() {+ if (!this.reviewable.topic || !this.reviewable.claimed_by?.automatic) {+ return;+ }++ try {+ await ajax(`/reviewable_claimed_topics/${this.reviewable.topic.id}`, {+ type: "DELETE",+ data: { automatic: true },+ });+ this.reviewable.set("claimed_by", null);+ } catch (e) {+ popupAjaxError(e);+ }+ }++ @action+ explainReviewable(reviewable, event) {+ event.preventDefault();+ this.modal.show(ExplainReviewableModal, {+ model: { reviewable },+ });+ }++ @action+ switchTab(tabName, event) {+ event.preventDefault();+ this.activeTab = tabName;+ }++ @action+ edit() {+ this.set("editing", true);+ this.set("_updates", { payload: {} });+ }++ @action+ cancelEdit() {+ this.set("editing", false);+ }++ @action+ saveEdit() {+ let updates = this._updates;++ // Remove empty objects+ Object.keys(updates).forEach((name) => {+ let attr = updates[name];+ if (typeof attr === "object" && Object.keys(attr).length === 0) {+ delete updates[name];+ }+ });++ this.set("updating", true);+ return this.reviewable+ .update(updates)+ .then(() => this.set("editing", false))+ .catch(popupAjaxError)+ .finally(() => this.set("updating", false));+ }++ @action+ categoryChanged(categoryId) {+ let category = Category.findById(categoryId);++ if (!category) {+ category = Category.findUncategorized();+ }++ set(this._updates, "category_id", category.id);+ }++ @action+ valueChanged(fieldId, event) {+ set(this._updates, fieldId, event.target.value);+ }++ @action+ async perform(performableAction) {+ if (this.updating) {+ return;+ }++ const message = performableAction.get("confirm_message");+ const requireRejectReason = performableAction.get("require_reject_reason");+ const actionModalClass = requireRejectReason+ ? RejectReasonReviewableModal+ : actionModalClassMap[performableAction.server_action];++ if (message) {+ if (await this.#claimReviewable()) {+ this.dialog.confirm({+ message,+ didConfirm: () => this._performConfirmed(performableAction),+ });+ }+ } else if (actionModalClass) {+ if (await this.#claimReviewable()) {+ this.modal.show(actionModalClass, {+ model: {+ reviewable: this.reviewable,+ performConfirmed: this._performConfirmed,+ action: performableAction,+ },+ });+ }+ } else {+ return this._performConfirmed(performableAction);+ }+ }++ <template>+ <div class="review-container">++ <div+ data-reviewable-id={{this.reviewable.id}}+ class="review-item {{this.customClasses}}"+ >+ <div class="review-item__primary-content">+ <div class="review-item__flag-summary">+ <div class="review-item__header">+ <div class="review-item__label-badges">+ <span class="review-item__flag-label">{{i18n+ "review.flagged_as"+ }}</span>++ <div class="review-item__flag-badges">+ {{#each this.scoreSummary as |score|}}+ <ReviewableFlagReason @score={{score}} />+ {{/each}}+ </div>+ </div>++ {{newReviewableStatus+ this.reviewable.status+ this.reviewable.type+ }}+ </div>++ {{#let+ (lookupComponent this this.reviewableComponent)+ as |ReviewableComponent|+ }}+ <ReviewableComponent+ @reviewable={{this.reviewable}}+ @tagName=""+ />+ {{/let}}+ </div>++ <div class="review-item__insights">+ <div class="d-nav-submenu">+ <HorizontalOverflowNav+ @ariaLabel="Review tabs"+ class="d-nav-submenu__tabs"+ >+ <li class={{if (eq this.activeTab "insights") "active"}}>+ <a+ href="#"+ class={{if (eq this.activeTab "insights") "active"}}+ {{on "click" (fn this.switchTab "insights")}}+ >+ {{i18n "review.insights.title"}}+ </a>+ </li>+ <li class={{if (eq this.activeTab "timeline") "active"}}>+ <a+ href="#"+ class={{if (eq this.activeTab "timeline") "active"}}+ {{on "click" (fn this.switchTab "timeline")}}+ >+ {{i18n "review.timeline_and_notes"}}+ </a>+ </li>+ </HorizontalOverflowNav>+ </div>++ {{#if (eq this.activeTab "insights")}}+ <ReviewableInsights @reviewable={{this.reviewable}} />+ {{else if (eq this.activeTab "timeline")}}+ <ReviewableTimeline @reviewable={{this.reviewable}} />+ {{/if}}+ </div>+ </div>++ <div class="review-item__aside">+ {{#if this.reviewable.claimed_by}}+ <div class="review-item__assigned">+ {{icon "user-plus"}}+ {{i18n "review.assigned_to"}}+ <ReviewableCreatedBy @user={{this.reviewable.claimed_by.user}} />+ </div>+ {{/if}}++ {{#unless this.reviewable.last_performing_username}}+ {{#if this.canPerform}}+ <div class="review-item__moderator-actions">+ <h3 class="review-item__aside-title">{{i18n+ "review.moderator_actions"+ }}</h3>+ {{#if this.editing}}+ <DButton+ @disabled={{this.disabled}}+ @icon="check"+ @action={{this.saveEdit}}+ @label="review.save"+ class="btn-primary reviewable-action save-edit"+ />+ <DButton+ @disabled={{this.disabled}}+ @icon="xmark"+ @action={{this.cancelEdit}}+ @label="review.cancel"+ class="btn-danger reviewable-action cancel-edit"+ />+ {{else}}+ {{#each this.reviewable.bundled_actions as |bundle|}}+ <ReviewableBundledAction+ @bundle={{bundle}}+ @performAction={{this.perform}}+ @reviewableUpdating={{this.disabled}}+ />+ {{/each}}++ {{#if this.reviewable.can_edit}}+ <DButton+ @disabled={{this.disabled}}+ @icon="pencil"+ @action={{this.edit}}+ @label="review.edit"+ class="reviewable-action btn-default edit"+ />+ {{/if}}+ {{/if}}+ </div>+ {{/if}}+ {{/unless}}++ <div class="review-item__moderator-actions --extra">+ {{#if this.claimEnabled}}+ <ReviewableClaimedTopic+ @topicId={{this.topicId}}+ @claimedBy={{this.reviewable.claimed_by}}+ @onClaim={{fn (mut this.reviewable.claimed_by)}}+ />+ {{/if}}+ <DButton+ @label="review.copy_link"+ @icon="link"+ class="btn-secondary"+ />+ <DButton+ @label="review.view_source"+ @icon="code"+ class="btn-secondary"+ />+ </div>++ <div class="review-item__resources">+ <h3 class="review-item__aside-title">{{i18n+ "review.need_help"+ }}</h3>+ <ul class="review-resources__list">+ <li class="review-resources__item">+ <span class="review-resources__icon">+ {{icon "book"}}+ </span>+ <a+ href={{this.siteSettings.moderation_guide_url}}+ class="review-resources__link"+ >+ {{i18n "review.help.moderation_guide"}}+ </a>+ </li>+ <li class="review-resources__item">+ <span class="review-resources__icon">+ {{icon "book"}}+ </span>+ <a+ href={{this.siteSettings.flag_priorities_url}}+ class="review-resources__link"+ >+ {{i18n "review.help.flag_priorities"}}+ </a>+ </li>+ <li class="review-resources__item">+ <span class="review-resources__icon">+ {{icon "book"}}+ </span>+ <a+ href={{this.siteSettings.spam_detection_url}}+ class="review-resources__link"+ >+ {{i18n "review.help.spam_detection"}}+ </a>+ </li>+ </ul>+ </div>+ </div>+ </div>+ </div>+ </template>+}diff --git a/app/assets/javascripts/discourse/app/components/reviewable-refresh/note-form.gjs b/app/assets/javascripts/discourse/app/components/reviewable-refresh/note-form.gjsnew file mode 100644index 00000000000..5182e0961e5--- /dev/null+++ b/app/assets/javascripts/discourse/app/components/reviewable-refresh/note-form.gjs@@ -0,0 +1,195 @@+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 { not } from "truth-helpers";+import Form from "discourse/components/form";+import PluginOutlet from "discourse/components/plugin-outlet";+import lazyHash from "discourse/helpers/lazy-hash";+import { ajax } from "discourse/lib/ajax";+import { popupAjaxError } from "discourse/lib/ajax-error";+import { i18n } from "discourse-i18n";++/**+ * A form component for adding notes to Reviewable items.+ *+ * @component ReviewableNoteForm+ *+ * @param {Reviewable} reviewable - The Reviewable that the note will be attached to.+ * @param {Function} [onNoteCreated] - Callback function called when a note is successfully created.+ */+export default class ReviewableNoteForm extends Component {+ @service appEvents;+ @service currentUser;++ /**+ * Whether the form is currently being submitted.+ *+ * @type {boolean}+ */+ @tracked isSubmitting = false;++ /**+ * Registers the Form API reference.+ *+ * @param {Object} api - The Form API object, with form helper methods.+ */+ @action+ registerApi(api) {+ this.formApi = api;+ }++ /**+ * Handles form submission from Form component.+ *+ * @param {Object} data - Form data from Form component+ */+ @action+ async onSubmit(data) {+ if (!data.content?.trim()) {+ return;+ }++ this.isSubmitting = true;++ try {+ const response = await ajax(+ `/reviewables/${this.args.reviewable.id}/notes`,+ {+ type: "POST",+ data: {+ reviewable_note: {+ content: data.content.trim(),+ },+ },+ }+ );++ // Clear the submitted content+ await this.formApi.set("content", "");++ // Notify any interested plugins that a note has been created.+ this.appEvents.trigger(+ "reviewablenote:created",+ data,+ this.args.reviewable,+ this.formApi+ );++ // Notify parent component+ if (this.args.onNoteCreated) {+ this.args.onNoteCreated(response);+ }+ } catch (error) {+ popupAjaxError(error);+ } finally {+ this.isSubmitting = false;+ }+ }++ /**+ * Handles keyboard shortcuts in the textarea+ *+ * @param {KeyboardEvent} event - Keyboard event+ */+ @action+ onKeyDown(event) {+ // Ctrl/Cmd + Enter to submit+ if ((event.ctrlKey || event.metaKey) && event.key === "Enter") {+ event.preventDefault();+ this.formApi.submit();+ }+ }++ /**+ * Whether the form has valid content to submit+ *+ * @returns {boolean} True if content is not empty after trimming+ */+ get isValid() {+ const content = this.formApi.get("content") || "";+ return content.trim().length > 0;+ }++ /**+ * Number of characters remaining before hitting the limit+ *+ * @returns {number} Characters remaining out of 2000 max+ */+ get remainingChars() {+ const maxLength = 2000;+ const content = this.formApi.get("content") || "";+ return maxLength - content.trim().length;+ }++ /**+ * Whether the user is approaching the character limit+ *+ * @returns {boolean} True if less than 100 characters remaining+ */+ get isNearLimit() {+ return this.remainingChars < 100;+ }++ <template>+ <div class="reviewable-note-form">+ <Form+ @data={{hash content=""}}+ @onSubmit={{this.onSubmit}}+ @onRegisterApi={{this.registerApi}}+ class="reviewable-note-form__form"+ as |form data|+ >+ <form.Field+ @name="content"+ @title={{i18n "review.notes.add_note_description"}}+ @format="full"+ @validation="required"+ as |field|+ >+ <div class="reviewable-note-form__textarea-wrapper">+ <field.Textarea+ {{on "keydown" this.onKeyDown}}+ placeholder={{i18n "review.notes.placeholder"}}+ class="reviewable-note-form__textarea"+ rows="4"+ maxlength="2000"+ disabled={{this.isSubmitting}}+ />++ {{#if data.content}}+ <div+ class="reviewable-note-form__char-count{{if+ this.isNearLimit+ ' warning'+ }}"+ >+ {{i18n+ "review.notes.chars_remaining"+ count=this.remainingChars+ }}+ </div>+ {{/if}}+ </div>+ </form.Field>++ <PluginOutlet+ @name="reviewable-note-form-after-note"+ @connectorTagName="div"+ @outletArgs={{lazyHash form=form}}+ />++ <form.Actions>+ <form.Submit+ @disabled={{not this.isValid}}+ @isLoading={{this.isSubmitting}}+ @label="review.notes.add_note_button"+ class="btn-primary"+ />+ </form.Actions>+ </Form>+ </div>+ </template>+}diff --git a/app/assets/javascripts/discourse/app/components/reviewable-refresh/post.gjs b/app/assets/javascripts/discourse/app/components/reviewable-refresh/post.gjsnew file mode 100644index 00000000000..b7d0617a390--- /dev/null+++ b/app/assets/javascripts/discourse/app/components/reviewable-refresh/post.gjs@@ -0,0 +1,111 @@+import Component from "@glimmer/component";+import { tracked } from "@glimmer/tracking";+import { action } from "@ember/object";+import didInsert from "@ember/render-modifiers/modifiers/did-insert";+import DButton from "discourse/components/d-button";+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 { bind } from "discourse/lib/decorators";+import highlightWatchedWords from "discourse/lib/highlight-watched-words";+import { i18n } from "discourse-i18n";++export default class ReviewablePost extends Component {+ @tracked isCollapsed = false;+ @tracked isLongPost = false;+ maxPostHeight = 300;++ @action+ toggleContent() {+ this.isCollapsed = !this.isCollapsed;+ }++ @bind+ calculatePostBodySize(element) {+ if (element?.offsetHeight > this.maxPostHeight) {+ this.isCollapsed = true;+ this.isLongPost = true;+ } else {+ this.isCollapsed = false;+ this.isLongPost = false;+ }+ }++ get collapseButtonProps() {+ if (this.isCollapsed) {+ return {+ label: "review.show_more",+ icon: "chevron-down",+ };+ }+ return {+ label: "review.show_less",+ icon: "chevron-up",+ };+ }++ get metaLabel() {+ return this.args.metaLabel || i18n("review.posted_in");+ }++ get userLabel() {+ return this.args.userLabel || i18n("review.review_user");+ }++ get pluginOutletName() {+ return this.args.pluginOutletName || "after-reviewable-post-body";+ }++ <template>+ <div class="review-item__meta-content">+ <div class="review-item__meta-label">{{this.metaLabel}}</div>++ <div class="review-item__meta-topic-title">+ <ReviewableTopicLink @reviewable={{@reviewable}} @tagName="" />+ <ReviewablePostEdits @reviewable={{@reviewable}} @tagName="" />+ </div>++ <div class="review-item__meta-label">{{this.userLabel}}</div>++ <div class="review-item__meta-flagged-user">+ <ReviewableCreatedBy @user={{@reviewable.target_created_by}} />+ </div>+ </div>++ <div class="review-item__post">+ <div class="review-item__post-content">+ <div+ class="post-body{{if this.isCollapsed ' is-collapsed'}}"+ {{didInsert this.calculatePostBodySize @reviewable}}+ >+ {{#if @reviewable.blank_post}}+ <p>{{i18n "review.deleted_post"}}</p>+ {{else}}+ {{highlightWatchedWords @reviewable.cooked @reviewable}}+ {{/if}}+ </div>++ {{#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={{this.pluginOutletName}}+ @connectorTagName="div"+ @outletArgs={{lazyHash model=@reviewable}}+ />+ </span>++ {{yield}}+ </div>+ </div>+ </template>+}diff --git a/app/assets/javascripts/discourse/app/components/reviewable-refresh/queued-post.gjs b/app/assets/javascripts/discourse/app/components/reviewable-refresh/queued-post.gjsnew file mode 100644index 00000000000..dd6188813d0--- /dev/null+++ b/app/assets/javascripts/discourse/app/components/reviewable-refresh/queued-post.gjs@@ -0,0 +1,131 @@+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";+import ReviewableTopicLink from "discourse/components/reviewable-refresh/topic-link";+import ReviewableTags from "discourse/components/reviewable-tags";+import categoryBadge from "discourse/helpers/category-badge";+import icon from "discourse/helpers/d-icon";+import lazyHash from "discourse/helpers/lazy-hash";+import highlightWatchedWords from "discourse/lib/highlight-watched-words";+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();+ this.modal.show(RawEmailModal, {+ model: {+ rawEmail: this.args.reviewable.payload.raw_email,+ },+ });+ }++ @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-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}}+ <ReviewableTags @tags={{@reviewable.payload.tags}} @tagName="" />+ {{#if @reviewable.payload.via_email}}+ <a href {{on "click" this.showRawEmail}} class="show-raw-email">+ {{icon "envelope" title="post.via_email"}}+ </a>+ {{/if}}+ </ReviewableTopicLink>+ </div>++ <div class="review-item__meta-label">{{i18n "review.queued_user"}}</div>++ <div class="review-item__meta-flagged-user">+ <ReviewableCreatedBy @user={{@reviewable.target_created_by}} />+ </div>+ </div>++ <div class="review-item__post">+ <div class="review-item__post-content">+ <CookText+ class="post-body{{if this.isCollapsed ' is-collapsed'}}"+ @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"+ @connectorTagName="div"+ @outletArgs={{lazyHash model=@reviewable}}+ />+ </span>++ {{yield}}+ </div>+ </div>+ </template>+}diff --git a/app/assets/javascripts/discourse/app/components/reviewable-refresh/timeline.gjs b/app/assets/javascripts/discourse/app/components/reviewable-refresh/timeline.gjsnew file mode 100644index 00000000000..a6c7ae3bcf7--- /dev/null+++ b/app/assets/javascripts/discourse/app/components/reviewable-refresh/timeline.gjs@@ -0,0 +1,284 @@+import Component from "@glimmer/component";+import { tracked } from "@glimmer/tracking";+import { fn } from "@ember/helper";+import { action } from "@ember/object";+import { service } from "@ember/service";+import { htmlSafe } from "@ember/template";+import { and, eq } from "truth-helpers";+import DButton from "discourse/components/d-button";+import InterpolatedTranslation from "discourse/components/interpolated-translation";+import ReviewableFlagReason from "discourse/components/reviewable-refresh/flag-reason";+import ReviewableNoteForm from "discourse/components/reviewable-refresh/note-form";+import UserLink from "discourse/components/user-link";+import avatar from "discourse/helpers/avatar";+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 { i18n } from "discourse-i18n";++/**+ * Timeline component for reviewable items that displays chronological events+ * including flags, reviews, notes, and target post creation.+ *+ * @component ReviewableTimeline+ */+export default class ReviewableTimeline extends Component {+ @service currentUser;+ @service store;++ /**+ * The post being reviewed (if applicable)+ *+ * @type {Post}+ */+ @tracked reviewablePost;++ /**+ * Array of notes associated with the reviewable+ *+ * @type {Array<ReviewableNote>}+ */+ @tracked reviewableNotes = [];++ constructor() {+ super(...arguments);++ this.reviewableNotes = this.args.reviewable.reviewable_notes || [];++ // If we have a post_id but no post, we need to grab it from the store.+ if (this.args.reviewable.post_id && !this.reviewablePost) {+ this.store+ .find("post", this.args.reviewable.post_id)+ .then((post) => (this.reviewablePost = post));+ }+ }++ /**+ * Combines all timeline events from reviewable scores, histories, and the reviewable itself+ * and sorts them chronologically.+ *+ * @returns {Array<Object>} Array of timeline event objects sorted by date (newest first)+ */+ get timelineEvents() {+ const events = [];+ const reviewedEvents = new Map(); // Track reviewed events to prevent duplicates++ // Add target post creation event (when the original post was created)+ if (this.reviewablePost) {+ events.push({+ type: "target_created",+ date: this.reviewablePost.created_at,+ user: this.args.reviewable.target_created_by,+ icon: "clock",+ titleKey: "review.timeline.target_created_by",+ });+ }++ // Add flagging events from reviewable scores+ if (this.args.reviewable.reviewable_scores) {+ this.args.reviewable.reviewable_scores.forEach((score) => {+ // Build description for flagged event+ let flaggedDescription = "";+ if (score.reason || score.context) {+ flaggedDescription = `<p>${score.reason ?? ""}</p><p>${+ score.context ?? ""+ }</p>`;+ }++ // Add conversation message if available+ if (+ score.reviewable_conversation &&+ score.reviewable_conversation.conversation_posts &&+ score.reviewable_conversation.conversation_posts.length > 0+ ) {+ const firstPost = score.reviewable_conversation.conversation_posts[0];+ flaggedDescription += `<p>${firstPost.excerpt} (<a href="${+ score.reviewable_conversation.permalink+ }">${i18n("review.timeline.view_conversation")}</a>)</p>`;+ }++ events.push({+ type: "flagged",+ date: score.created_at,+ user: score.user,+ icon: "flag",+ titleKey: "review.timeline.flagged_as_by",+ description: htmlSafe(flaggedDescription),+ score: {+ count: 0,+ type: score.score_type.type,+ title: score.score_type.title,+ },+ });++ // Add separate reviewed event if both reviewed_by and reviewed_at are present+ if (score.reviewed_by && score.reviewed_at) {+ // Create a unique key for this reviewed event to prevent duplicates+ const reviewedKey = `${score.reviewed_by.id}-${score.reviewed_at}`;++ if (!reviewedEvents.has(reviewedKey)) {+ // Determine icon based on score status+ let reviewIcon;+ switch (score.status) {+ case 1: // approved+ reviewIcon = "check";+ break;+ case 2: // rejected+ reviewIcon = "times";+ break;+ case 3: // ignored+ reviewIcon = "far-eye-slash";+ break;+ default:+ reviewIcon = "check"; // fallback+ }++ const reviewedEvent = {+ type: "reviewed",+ date: score.reviewed_at,+ user: score.reviewed_by,+ icon: reviewIcon,+ titleKey: "review.timeline.reviewed_by",+ description: score.reason,+ };++ events.push(reviewedEvent);+ reviewedEvents.set(reviewedKey, reviewedEvent);+ }+ }+ });+ }++ // Add notes events+ this.reviewableNotes.forEach((note) => {+ const date = note.created_at;+ events.push({+ type: "note",+ date,+ user: note.user,+ icon: "far-pen-to-square",+ titleKey: "review.timeline.note_added_by",+ description: note.content,+ noteId: note.id,+ canDelete:+ this.currentUser &&+ note.user &&+ (this.currentUser.id === note.user.id || this.currentUser.admin),+ });+ });++ return events.sort((a, b) => Date.parse(b.date) - Date.parse(a.date));+ }++ /**+ * Handles creation of a new note.+ *+ * @param {Object} noteData - The created note data from the server+ */+ @action+ onNoteCreated(noteData) {+ // Ensure the note has a user object (fallback to current user if missing)+ if (!noteData.user && this.currentUser) {+ noteData.user = this.currentUser;+ }++ this.reviewableNotes = [...this.reviewableNotes, noteData];+ }++ /**+ * Handles deletion of a note.+ *+ * @param {number} noteId - ID of the note to delete+ */+ @action+ async deleteNote(noteId) {+ try {+ await ajax(`/reviewables/${this.args.reviewable.id}/notes/${noteId}`, {+ type: "DELETE",+ });++ // Remove the note from the local array+ this.reviewableNotes = this.reviewableNotes.filter(+ (note) => note.id !== noteId+ );+ } catch (error) {+ popupAjaxError(error);+ }+ }++ <template>+ <div class="reviewable-timeline">+ {{#if this.currentUser.staff}}+ <ReviewableNoteForm+ @reviewable={{@reviewable}}+ @onNoteCreated={{this.onNoteCreated}}+ />+ {{/if}}++ {{#if this.timelineEvents}}+ <div class="timeline-events">+ {{#each this.timelineEvents as |event|}}+ <div class="timeline-event">+ <div class="timeline-event__icon">+ {{icon event.icon}}+ </div>++ <div class="timeline-event__content">+ <div class="timeline-event__main">+ <div class="timeline-event__text">+ <div class="timeline-event__title">+ <InterpolatedTranslation+ @key={{event.titleKey}}+ as |Placeholder|+ >+ <Placeholder @name="flagReason">+ <ReviewableFlagReason @score={{event.score}} />+ </Placeholder>++ <Placeholder @name="username">+ {{avatar event.user imageSize="tiny"}}+ <UserLink+ @user={{event.user}}+ >{{event.user.username}}</UserLink>+ </Placeholder>++ <Placeholder @name="relativeDate">+ {{formatDate event.date format="medium"}}+ </Placeholder>+ </InterpolatedTranslation>+ </div>+ <div class="timeline-event__description">+ {{event.description}}+ </div>+ </div>++ {{#if (and (eq event.type "note") event.canDelete)}}+ <div class="timeline-event__actions">+ <DButton+ @icon="trash-can"+ @title="review.notes.delete_note"+ @action={{fn this.deleteNote event.noteId}}+ class="timeline-event__delete-note btn-transparent"+ />+ </div>+ {{/if}}+ </div>++ </div>+ </div>+ {{/each}}+ </div>+ {{else}}+ <div class="timeline-empty">+ <div class="timeline-empty__icon">+ {{icon "clock"}}+ </div>+ <p class="timeline-empty__message">+ {{i18n "review.timeline.no_events"}}+ </p>+ </div>+ {{/if}}+ </div>+ </template>+}diff --git a/app/assets/javascripts/discourse/app/components/reviewable-refresh/topic-link.gjs b/app/assets/javascripts/discourse/app/components/reviewable-refresh/topic-link.gjsnew file mode 100644index 00000000000..8282043e0a3--- /dev/null+++ b/app/assets/javascripts/discourse/app/components/reviewable-refresh/topic-link.gjs@@ -0,0 +1,37 @@+import { array } from "@ember/helper";+import { LinkTo } from "@ember/routing";+import ReviewableTags from "discourse/components/reviewable-tags";+import TopicStatus from "discourse/components/topic-status";+import categoryBadge from "discourse/helpers/category-badge";+import highlightWatchedWords from "discourse/lib/highlight-watched-words";+import { i18n } from "discourse-i18n";++<template>+ <div class="post-topic">+ {{#if this.reviewable.topic}}+ <TopicStatus+ @topic={{this.reviewable.topic}}+ @showPrivateMessageIcon={{true}}+ />+ <a+ href={{this.reviewable.target_url}}+ class="title-text"+ >{{highlightWatchedWords+ this.reviewable.topic.fancyTitle+ this.reviewable+ }}</a>+ {{categoryBadge this.reviewable.category}}+ <ReviewableTags @tags={{this.reviewable.topic_tags}} @tagName="" />+ {{else if (has-block)}}+ {{yield}}+ {{else}}+ <span class="title-text">+ {{i18n "review.topics.deleted"}}+ <LinkTo+ @route="topic"+ @models={{array "-" this.reviewable.removed_topic_id}}+ >{{i18n "review.topics.original"}}</LinkTo>+ </span>+ {{/if}}+ </div>+</template>diff --git a/app/assets/javascripts/discourse/app/helpers/reviewable-status.js b/app/assets/javascripts/discourse/app/helpers/reviewable-status.jsindex f49534c5b78..abd0c27e644 100644--- a/app/assets/javascripts/discourse/app/helpers/reviewable-status.js+++ b/app/assets/javascripts/discourse/app/helpers/reviewable-status.js@@ -65,6 +65,28 @@ function dataFor(status, type) {}}+/**+ * Returns a safe HTML string for a reviewable item status, given its status and type+ *+ * @param {number} status - The status of the reviewable item+ * @param {string} type - The type of the reviewable item+ * @returns {string} HTML for the reviewable item status+ */+export function newReviewableStatus(status, type) {+ let data = dataFor(status, type);+ if (!data) {+ return;+ }++ const html = `+ <div class="review-item__status --${data.cssClass || data.name}">+ ${i18n("review.statuses." + data.name + ".title")}+ </div>+ `;++ return htmlSafe(html);+}+export function htmlStatus(status, type) {let data = dataFor(status, type);if (!data) {@@ -81,6 +103,7 @@ export function htmlStatus(status, type) {`;}+// TODO (reviewable-refresh): Replace with newReviewableStatusexport default function (status, type) {return htmlSafe(htmlStatus(status, type));}diff --git a/app/assets/javascripts/discourse/app/templates/review-show.gjs b/app/assets/javascripts/discourse/app/templates/review-show.gjsindex 9e133febde0..1020318efee 100644--- a/app/assets/javascripts/discourse/app/templates/review-show.gjs+++ b/app/assets/javascripts/discourse/app/templates/review-show.gjs@@ -1,6 +1,74 @@+import Component from "@glimmer/component";+import { getOwner } from "@ember/owner";+import { service } from "@ember/service";+import { dasherize } from "@ember/string";import RouteTemplate from "ember-route-template";import ReviewableItem from "discourse/components/reviewable-item";+import ReviewableItemRefresh from "discourse/components/reviewable-refresh/item";export default RouteTemplate(- <template><ReviewableItem @reviewable={{@controller.reviewable}} /></template>+ class extends Component {+ @service currentUser;+ @service site;++ /**+ * Checks if a refreshed reviewable component exists for the current reviewable type.+ *+ * @returns {boolean} True if the refreshed component exists, false otherwise+ */+ get refreshedReviewableComponentExists() {+ const owner = getOwner(this);+ const dasherized = dasherize(+ this.args.controller.reviewable.type+ ).replace("reviewable-", "reviewable-refresh/");++ return owner.hasRegistration(`component:${dasherized}`);+ }++ /**+ * Determines if the current user can use the refreshed reviewable UI.+ *+ * @returns {boolean} True if the current user can access the refreshed UI, false otherwise+ */+ get canUseRefreshUI() {+ if (!this.currentUser) {+ return false;+ }++ const allowedGroupIds =+ this.args.controller.siteSettings.reviewable_ui_refresh;+ if (!allowedGroupIds) {+ return false;+ }++ // Convert comma-separated string to array of numbers+ const groupIds = allowedGroupIds+ .toString()+ .split(",")+ .map((id) => parseInt(id.trim(), 10))+ .filter((id) => !isNaN(id));++ // Check if current user is in any of the specified groups+ return this.currentUser.groups.some((userGroup) =>+ groupIds.includes(userGroup.id)+ );+ }++ /**+ * Determines whether to use the refreshed reviewable UI component.+ *+ * @returns {boolean} True if both conditions are met: user has permission and component exists+ */+ get shouldUseRefreshUI() {+ return this.canUseRefreshUI && this.refreshedReviewableComponentExists;+ }++ <template>+ {{#if this.shouldUseRefreshUI}}+ <ReviewableItemRefresh @reviewable={{@controller.reviewable}} />+ {{else}}+ <ReviewableItem @reviewable={{@controller.reviewable}} />+ {{/if}}+ </template>+ });diff --git a/app/assets/stylesheets/common/base/_index.scss b/app/assets/stylesheets/common/base/_index.scssindex def830cf593..ca192170cfd 100644--- a/app/assets/stylesheets/common/base/_index.scss+++ b/app/assets/stylesheets/common/base/_index.scss@@ -42,6 +42,7 @@@import "popup-menu";@import "redirection";@import "reorder-categories";+@import "review";@import "reviewables";@import "revise-and-reject-post-reviewable";@import "rtl";diff --git a/app/assets/stylesheets/common/base/review.scss b/app/assets/stylesheets/common/base/review.scssnew file mode 100644index 00000000000..a5540740223--- /dev/null+++ b/app/assets/stylesheets/common/base/review.scss@@ -0,0 +1,460 @@+: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-offtopic-bg: #dbeafe;+ --d-review-reason-offtopic-text: #1d4ed8;+ --d-review-reason-offtopic-count-bg: #1d4ed8;+ --d-review-reason-offtopic-count-text: #dbeafe;+ --d-review-reason-illegal-bg: #d1fae5;+ --d-review-reason-illegal-text: #065f46;+ --d-review-reason-illegal-count-bg: #065f46;+ --d-review-reason-illegal-count-text: #d1fae5;+ --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;+}++.review-item {+ display: flex;+ flex-wrap: nowrap;+ gap: var(--space-4);+ align-items: flex-start;++ &__primary-content {+ position: relative;+ flex: 0 1 70%;+ }++ &__aside {+ flex: 0 1 30%;+ padding: var(--space-4);++ > * {+ padding-top: var(--space-2);+ padding-bottom: var(--space-4);+ margin-bottom: var(--space-3);++ &:not(:last-child) {+ border-bottom: 1px solid var(--primary-low);+ }+ }+ }++ &__flag-summary {+ border-radius: var(--d-border-radius);+ border: 1px solid var(--primary-low);+ margin-bottom: var(--space-6);+ }++ &__header {+ display: grid;+ grid-template-columns: 1fr auto;+ gap: var(--space-2);+ align-items: start;+ background-color: var(--primary-very-low);+ padding: var(--space-5) var(--space-4);+ }++ &__label-badges {+ display: grid;+ grid-template-columns: auto 1fr;+ gap: var(--space-2);+ align-items: start;+ }++ &__flag-label,+ &__meta-label {+ white-space: nowrap;+ text-align: left;+ }++ &__flag-badges {+ display: flex;+ flex-wrap: wrap;+ gap: var(--space-1);+ }++ &__meta {+ display: grid;+ grid-template-columns: 10ch 1fr;+ column-gap: var(--space-3);+ row-gap: var(--space-3);+ align-items: start;+ padding: var(--space-5) var(--space-4);+ border-bottom: 1px solid var(--primary-low);+ }++ &__meta-content {+ display: grid;+ grid-template-columns: auto auto;+ padding: var(--space-4);++ .badge-category__wrapper {+ display: block;+ }++ .created-by {+ display: flex;++ .names {+ display: inline-block;+ font-weight: bold;+ padding-left: var(--space-1);++ span a {+ color: var(--primary);+ }+ }+ }+ }++ &__post {+ padding: var(--space-4);++ &-content {+ max-height: 200px;+ overflow: hidden;+ position: relative;+ }+ }++ &__toggle-post {+ margin-top: 0.5em;+ background: none;+ border: none;+ color: var(--primary);+ cursor: pointer;+ }+}++.review-item__status {+ white-space: nowrap;+ align-self: start;+ display: inline-flex;+ align-items: center;+ justify-content: center;+ border-radius: 999px;+ padding: var(--space-1) var(--space-2) var(--space-1) var(--space-3);+ font-size: var(--font-down-1);+ line-height: 1;++ &.--pending {+ background-color: var(--primary-very-high);+ color: var(--secondary);+ }++ &.--resolved {+ background-color: var(--success);+ color: var(--secondary);+ }+}++.review-item__flag-reason {+ display: inline-flex;+ align-items: center;+ gap: var(--space-1);+ background: var(--primary-very-low);+ border-radius: 999px;+ padding: var(--space-1) var(--space-2);+ font-size: var(--font-down-1);+ line-height: 1;++ &.--spam {+ background-color: var(--d-review-reason-spam-bg);+ color: var(--d-review-reason-spam-text);+ }++ &.--offtopic {+ background-color: var(--d-review-reason-offtopic-bg);+ color: var(--d-review-reason-offtopic-text);+ }++ &.--illegal {+ background-color: var(--d-review-reason-illegal-bg);+ color: var(--d-review-reason-illegal-text);+ }++ &.--inappropriate {+ background-color: var(--d-review-reason-inappropriate-bg);+ color: var(--d-review-reason-inappropriate-text);+ }++ &.--other,+ &.--needs_approval {+ background-color: var(--d-review-reason-other-bg);+ color: var(--d-review-reason-other-text);+ }++ &.--custom {+ background-color: var(--d-review-reason-custom-bg);+ color: var(--d-review-reason-custom-text);+ }+}++.review-item__flag-count {+ display: inline-flex;+ align-items: center;+ justify-content: center;+ border-radius: 999px;+ min-width: 1rem;+ padding: var(--space-1);+ font-size: var(--font-down-2);++ &.--spam {+ background-color: var(--d-review-reason-spam-count-bg);+ color: var(--d-review-reason-spam-count-text);+ }++ &.--offtopic {+ background-color: var(--d-review-reason-offtopic-count-bg);+ color: var(--d-review-reason-offtopic-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 {+ 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);+ }+}++.review-insight {+ display: flex;+ flex-direction: column;+ gap: var(--space-3);+ padding-top: var(--space-3);+ margin-bottom: var(--space-6);++ &__item {+ display: grid;+ grid-template-columns: auto 1fr;+ column-gap: var(--space-2);+ align-items: start;+ padding-bottom: var(--space-3);++ &:not(:last-child) {+ border-bottom: 1px solid var(--primary-low);+ }+ }++ &__icon {+ font-size: 1.2rem;+ line-height: 1;+ color: var(--primary-medium);+ margin-top: 0.2em; // optical alignment tweak+ }++ &__content {+ display: flex;+ flex-direction: column;+ gap: 0.25rem;+ }++ &__label {+ font-weight: bold;+ }++ &__description {+ font-size: var(--font-down-1);+ color: var(--primary-high);+ }+}++.review-item__moderator-actions {+ display: flex;+ flex-direction: column;+ gap: var(--space-2);++ label {+ display: block;+ }+}++.review-resources {+ &__list {+ list-style: none;+ padding: 0;+ margin: 0;+ display: flex;+ flex-direction: column;+ gap: var(--space-2);+ }++ &__item {+ display: flex;+ align-items: flex-start;+ gap: var(--space-1);+ }++ &__icon {+ font-size: 1rem;+ color: var(--primary-medium);+ flex-shrink: 0;+ line-height: 1.2;+ }+}++// Timeline Component Styles+.reviewable-timeline {+ .timeline-events {+ display: flex;+ flex-direction: column;+ gap: var(--space-4);+ }++ .timeline-event {+ position: relative;+ display: flex;+ align-items: flex-start;+ gap: var(--space-3);+ padding: var(--space-4);+ background: var(--secondary);++ &:not(:last-child) {+ border-bottom: 1px solid var(--primary-low);+ }++ &__icon {+ display: flex;+ align-items: flex-start;+ justify-content: center;+ width: 2.5rem;+ height: 2.5rem;+ font-size: 1.1rem;+ flex-shrink: 0;+ padding-top: 0.2em;+ color: var(--primary-medium);+ }++ &__content {+ flex: 1;+ min-width: 0;+ }++ &__main {+ display: flex;+ align-items: flex-start;+ justify-content: space-between;+ gap: var(--space-3);+ }++ &__text {+ flex: 1;+ display: flex;+ flex-direction: column;+ gap: var(--space-1);+ }++ &__title {+ color: var(--primary);+ margin: 0;+ display: flex;+ align-items: center;+ gap: var(--space-1);+ flex-wrap: wrap;+ }++ &__description {+ color: var(--primary-high);+ font-size: var(--font-down-1);+ margin: 0;+ line-height: var(--line-height-medium);+ }++ &__actions {+ display: flex;+ align-items: center;+ gap: var(--space-2);+ margin-left: auto;+ }++ &__delete-note {+ display: flex;+ align-items: center;+ justify-content: center;+ width: 2rem;+ height: 2rem;+ border-radius: var(--d-border-radius);+ color: var(--primary-medium);+ background: transparent;+ border: none;+ cursor: pointer;+ transition: all 0.15s ease;++ &:hover {+ background: var(--danger-low);+ color: var(--danger);+ }++ .d-icon {+ font-size: var(--font-down-1);+ }+ }+ }++ .timeline-empty {+ text-align: center;+ padding: var(--space-6) var(--space-4);+ color: var(--primary-medium);++ &__icon {+ font-size: 2rem;+ margin-bottom: var(--space-3);+ opacity: 0.5;+ }++ &__message {+ margin: 0;+ font-style: italic;+ }+ }+}++// Reviewable Note Form Styles+.reviewable-note-form {+ background-color: var(--primary-very-low);+ border: 1px solid var(--primary-low);+ border-radius: var(--d-border-radius);+ padding: var(--space-4);+ margin-bottom: var(--space-4);++ textarea {+ resize: vertical;+ }++ &__char-count {+ position: absolute;+ right: var(--space-2);+ font-size: var(--font-down-2);+ color: var(--primary-medium);++ &.warning {+ color: var(--danger);+ font-weight: 500;+ }+ }+}diff --git a/app/serializers/flagged_user_serializer.rb b/app/serializers/flagged_user_serializer.rbindex ed98e77ac12..321512a00c6 100644--- a/app/serializers/flagged_user_serializer.rb+++ b/app/serializers/flagged_user_serializer.rb@@ -9,7 +9,11 @@ class FlaggedUserSerializer < BasicUserSerializer:custom_fields,:flags_agreed,:flags_disagreed,- :flags_ignored+ :flags_ignored,+ :created_at,+ :custom_fields,+ :post_count,+ :trust_leveldef can_delete_all_postsscope.can_delete_all_posts?(object)@@ -43,4 +47,20 @@ class FlaggedUserSerializer < BasicUserSerializerresultend++ def include_created_at?+ scope.can_see_reviewable_ui_refresh?+ end++ def include_custom_fields?+ scope.can_see_reviewable_ui_refresh?+ end++ def include_post_count?+ scope.can_see_reviewable_ui_refresh?+ end++ def include_trust_level?+ scope.can_see_reviewable_ui_refresh?+ endenddiff --git a/app/serializers/reviewable_serializer.rb b/app/serializers/reviewable_serializer.rbindex bac1fc60970..a37dd550fb8 100644--- a/app/serializers/reviewable_serializer.rb+++ b/app/serializers/reviewable_serializer.rb@@ -23,7 +23,7 @@ class ReviewableSerializer < ApplicationSerializerattribute :status_for_database, key: :statushas_one :created_by, serializer: UserWithCustomFieldsSerializer, root: "users"- has_one :target_created_by, serializer: UserWithCustomFieldsSerializer, root: "users"+ has_one :target_created_by, root: "users"has_one :topic, serializer: ListableTopicSerializerhas_many :editable_fields, serializer: ReviewableEditableFieldSerializer, embed: :objectshas_many :reviewable_scores, serializer: ReviewableScoreSerializer@@ -141,4 +141,13 @@ class ReviewableSerializer < ApplicationSerializerdef target_created_by_trust_levelobject&.target_created_by&.trust_levelend++ def target_created_by+ user = object.target_created_by+ return nil unless user++ serializer_class =+ scope.can_see_reviewable_ui_refresh? ? FlaggedUserSerializer : UserWithCustomFieldsSerializer+ serializer_class.new(user, scope: scope, root: false)+ endenddiff --git a/config/locales/client.en.yml b/config/locales/client.en.ymlindex b293a31c571..297d230edae 100644--- a/config/locales/client.en.yml+++ b/config/locales/client.en.yml@@ -806,6 +806,61 @@ en:reviewable_post:title: "Post"noun: "post"+ flagged_as: "Flagged as"+ assigned_to: "Assigned to"+ moderator_actions: "Moderator actions"+ timeline_and_notes: "Timeline & notes"+ timeline:+ target_created: "Post created"+ target_created_by: "Post created by %{username} · %{relativeDate}"+ flagged: "Flagged"+ flagged_as_by: "Flagged as %{flagReason} by %{username} · %{relativeDate}"+ claimed: "Claimed"+ claimed_by: "Claimed by %{username} · %{relativeDate}"+ reviewed: "Reviewed"+ reviewed_by: "Reviewed by %{username} · %{relativeDate}"+ view_conversation: "view PM"+ note_added: "Moderator note"+ note_added_by: "Moderator note by %{username} · %{relativeDate}"+ no_events: "No timeline events to display"+ notes:+ add_note_description: "Visible only to moderators. Use this note to add context or decisions about the review."+ add_note_button: "Add note"+ placeholder: "Write your note here..."+ chars_remaining: "%{count} characters remaining"+ delete_note: "Delete this note"+ delete: "Delete"+ new_topic_label: "New topic"+ queued_user: "Queued user"+ posted_in: "Posted in"+ flagged_user: "Flagged user"+ review_user: "User"+ need_help: "Need help?"+ copy_link: "Copy link"+ view_source: "View source"+ insights:+ title: "Insights"+ flag_volume: "Flag volume"+ 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"+ activities:+ new_account: "new account"+ trust_level: "trust level: %{trustLevelName}"+ posts:+ one: "%{count} post"+ other: "%{count} posts"+ solution_marked: "Solution marked"+ topic_has_solution: "This topic has a solution"+ visibility: "Visibility"+ topic_unlisted: "This topic is unlisted. Only accessible via direct link — not public."+ help:+ moderation_guide: "Discourse moderation guide"+ flag_priorities: "Managing user reputation and flag priorities"+ spam_detection: "Spam detection"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."diff --git a/config/locales/server.en.yml b/config/locales/server.en.ymlindex fdcf9b90702..1a6ec2ec58c 100644--- a/config/locales/server.en.yml+++ b/config/locales/server.en.yml@@ -2731,6 +2731,7 @@ en:view_raw_email_allowed_groups: "Groups which can view the raw email content of a post if it was created by an incoming email. This includes email headers and other technical information."rich_editor: "Enable the rich editor so all users can switch between the current Markdown mode and the new rich text editor for more intuitive and user-friendly composition. The rich text editor is under active development, so not all features are supported yet — <a href='https://meta.discourse.org/t/test-our-new-composer/352347' target='_blank'>see Meta for more details</a>."viewport_based_mobile_mode: "EXPERIMENTAL: Disable the user-agent-based mobile/desktop modes and use viewport width instead."+ reviewable_ui_refresh: "Groups that can use the experimental new UI in the review queue."content_localization_enabled: "Displays localized content for users based on their browser or user language preferences. Such content may include categories, tags, posts, and topics. Supported locales are set in 'content localization supported locales'."content_localization_supported_locales: "List of supported locales that user content can be translated to. Requires 'content localization enabled'."diff --git a/config/site_settings.yml b/config/site_settings.ymlindex 251c90ff074..9dea3d1fdc3 100644--- a/config/site_settings.yml+++ b/config/site_settings.yml@@ -4048,6 +4048,10 @@ experimental:rich_editor:client: truedefault: false+ reviewable_ui_refresh:+ client: true+ type: group_list+ default: ""experimental_system_themes:type: listdefault: "horizon"diff --git a/lib/guardian.rb b/lib/guardian.rbindex 8888c52d4ae..7f6bf1ba1aa 100644--- a/lib/guardian.rb+++ b/lib/guardian.rb@@ -659,6 +659,11 @@ class Guardian@user.in_any_groups?(SiteSetting.lazy_load_categories_groups_map)end+ def can_see_reviewable_ui_refresh?+ SiteSetting.reviewable_ui_refresh_map.include?(Group::AUTO_GROUPS[:everyone]) ||+ @user.in_any_groups?(SiteSetting.reviewable_ui_refresh_map)+ end+def is_me?(other)other && authenticated? && other.is_a?(User) && @user == otherend