A platform for community discussion. Free, open, simple.
UX: switch default reviewable refresh tab to timeline, adjust spacing (#35945)
Kris23c8821d0ece
diff --git a/app/assets/stylesheets/common/base/review.scss b/app/assets/stylesheets/common/base/review.scssindex fb95c1eba48..f5a969e0364 100644--- a/app/assets/stylesheets/common/base/review.scss+++ b/app/assets/stylesheets/common/base/review.scss@@ -37,7 +37,7 @@.reviewable-created-date {font-size: var(--font-down-1);- color: var(--primary-medium);+ color: var(--primary-high);white-space: nowrap;align-self: baseline;padding-block: var(--space-1);@@ -51,13 +51,19 @@align-self: center;.post-action-feedback-alert {- top: -1rem;+ top: -1.25rem;left: 60%;}- > .d-icon {+ .d-icon {margin-right: 0;}++ .post-action-feedback-svg {+ right: unset;+ left: -0.5em;+ top: 0.05em;+ }}&__aside {@@ -193,6 +199,10 @@&-content-wrapper {width: 100%;++ .review-item__post-content .transcript {+ margin: var(--space-2) 0 0;+ }}&-content {@@ -205,6 +215,7 @@transition-delay: 0.5s;background: var(--primary-very-low);padding: var(--space-4);+ border-radius: var(--d-border-radius);.lightbox-wrapper img {display: block;@@ -262,7 +273,8 @@&__insights {padding-inline: var(--space-4);- .nav-pills {+ .nav-pills.action-list {+ margin-bottom: 0;border-bottom: 1px solid var(--content-border-color);}}@@ -355,6 +367,7 @@display: flex;flex-direction: column;gap: var(--space-3);+ margin-top: var(--space-2);&__item {display: grid;@@ -362,6 +375,7 @@column-gap: var(--space-2);align-items: start;padding-bottom: var(--space-3);+ padding-inline: var(--space-4);&:not(:last-child) {border-bottom: 1px solid var(--content-border-color);@@ -395,6 +409,7 @@button {justify-content: left;+ text-align: left;}}@@ -427,7 +442,6 @@.timeline-events {display: flex;flex-direction: column;- gap: var(--space-4);}.timeline-event {@@ -436,6 +450,7 @@align-items: flex-start;gap: var(--space-3);background: var(--secondary);+ padding-block: var(--space-4);&:not(:last-child) {border-bottom: 1px solid var(--content-border-color);@@ -454,9 +469,9 @@align-items: flex-start;justify-content: center;width: 2.5rem;- height: 2.5rem;font-size: 1.1rem;flex-shrink: 0;+ padding-left: var(--space-2);padding-top: 0.2em;color: var(--primary-medium);}@@ -492,7 +507,14 @@&__description {color: var(--primary-high);font-size: var(--font-down-1);- line-height: var(--line-height-medium);++ :first-child {+ margin-top: 0;+ }++ :last-child {+ margin-bottom: 0;+ }}&__actions {@@ -528,14 +550,14 @@}.timeline-empty {- text-align: center;- padding: var(--space-6) var(--space-4);+ padding: var(--space-4);color: var(--primary-medium);+ display: flex;+ justify-content: center;+ gap: var(--space-2);&__icon {- font-size: 2rem;- margin-bottom: var(--space-3);- opacity: 0.5;+ color: var(--primary-low-mid);}&__message {@@ -548,24 +570,17 @@// Reviewable Note Form Styles.reviewable-note-form {background-color: var(--primary-very-low);- border: 1px solid var(--content-border-color);- border-radius: var(--d-border-radius);+ border-radius: 0 0 var(--d-border-radius) var(--d-border-radius);padding: var(--space-4);margin-bottom: var(--space-4);- &__form {- gap: var(--space-2);+ &__textarea-wrapper {+ width: 100%;}textarea {- resize: vertical;- }-- @include viewport.between(sm, lg) {- // prevents textarea from squishing controls after resizing window- .form-kit__field .form-kit__container-content.--full {- max-width: 40vw;- }+ margin-bottom: 0;+ resize: none;}}diff --git a/config/locales/client.en.yml b/config/locales/client.en.ymlindex 30838a34977..7a44556e934 100644--- a/config/locales/client.en.yml+++ b/config/locales/client.en.yml@@ -946,7 +946,7 @@ en: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_description: "Add a note to provide context to other moderators."add_note_button: "Add note"placeholder: "Write your note here..."chars_remaining: "%{count} characters remaining"diff --git a/frontend/discourse/app/components/reviewable-refresh/item.gjs b/frontend/discourse/app/components/reviewable-refresh/item.gjsindex 563fc275ccb..5482b373786 100644--- a/frontend/discourse/app/components/reviewable-refresh/item.gjs+++ b/frontend/discourse/app/components/reviewable-refresh/item.gjs@@ -100,7 +100,7 @@ export default class ReviewableItem extends Component {@optionalService adminTools;@tracked disabled = false;- @tracked activeTab = "insights";+ @tracked activeTab = "timeline";@alias("reviewable.claimed_by.automatic") autoClaimed;@@ -776,30 +776,30 @@ export default class ReviewableItem extends Component {><liclass={{concatClass- "insights"- (if (eq this.activeTab "insights") "active")+ "timeline"+ (if (eq this.activeTab "timeline") "active")}}><ahref="#"- class={{if (eq this.activeTab "insights") "active"}}- {{on "click" (fn this.switchTab "insights")}}+ class={{if (eq this.activeTab "timeline") "active"}}+ {{on "click" (fn this.switchTab "timeline")}}>- {{i18n "review.insights.title"}}+ {{i18n "review.timeline_and_notes"}}</a></li><liclass={{concatClass- "timeline"- (if (eq this.activeTab "timeline") "active")+ "insights"+ (if (eq this.activeTab "insights") "active")}}><ahref="#"- class={{if (eq this.activeTab "timeline") "active"}}- {{on "click" (fn this.switchTab "timeline")}}+ class={{if (eq this.activeTab "insights") "active"}}+ {{on "click" (fn this.switchTab "insights")}}>- {{i18n "review.timeline_and_notes"}}+ {{i18n "review.insights.title"}}</a></li></HorizontalOverflowNav>diff --git a/frontend/discourse/app/components/reviewable-refresh/note-form.gjs b/frontend/discourse/app/components/reviewable-refresh/note-form.gjsindex d1bf053bb29..3f96070a6b9 100644--- a/frontend/discourse/app/components/reviewable-refresh/note-form.gjs+++ b/frontend/discourse/app/components/reviewable-refresh/note-form.gjs@@ -1,7 +1,8 @@import Component from "@glimmer/component";-import { hash } from "@ember/helper";+import { fn, hash } from "@ember/helper";import { action } from "@ember/object";import { service } from "@ember/service";+import ExpandingTextArea from "discourse/components/expanding-text-area";import Form from "discourse/components/form";import PluginOutlet from "discourse/components/plugin-outlet";import lazyHash from "discourse/helpers/lazy-hash";@@ -30,6 +31,11 @@ export default class ReviewableNoteForm extends Component {this.formApi = api;}+ @action+ handleInput(setFn, event) {+ setFn(event.target.value);+ }+/*** Handles form submission from Form component.*@@ -88,24 +94,28 @@ export default class ReviewableNoteForm extends Component {as |field|><div class="reviewable-note-form__textarea-wrapper">- <field.Textarea- placeholder={{i18n "review.notes.placeholder"}}- class="reviewable-note-form__textarea"- rows="4"+ <field.Custom>+ <ExpandingTextArea+ @value={{field.value}}+ @input={{fn this.handleInput field.set}}+ @name={{field.name}}+ placeholder={{i18n "review.notes.placeholder"}}+ class="reviewable-note-form__textarea"+ rows="1"+ />+ </field.Custom>+ <PluginOutlet+ @name="reviewable-note-form-after-note"+ @connectorTagName="div"+ @outletArgs={{lazyHash form=form reviewable=@reviewable}}/></div></form.Field>- <PluginOutlet- @name="reviewable-note-form-after-note"- @connectorTagName="div"- @outletArgs={{lazyHash form=form}}- />-<form.Actions><form.Submit@label="review.notes.add_note_button"- class="btn-primary"+ class="btn-small btn-primary"/></form.Actions></Form>diff --git a/frontend/discourse/app/components/reviewable-refresh/timeline.gjs b/frontend/discourse/app/components/reviewable-refresh/timeline.gjsindex 6f3387587a6..ff16e6b3c0a 100644--- a/frontend/discourse/app/components/reviewable-refresh/timeline.gjs+++ b/frontend/discourse/app/components/reviewable-refresh/timeline.gjs@@ -71,7 +71,7 @@ export default class ReviewableTimeline extends Component {type: "target_created",date: this.reviewablePost.created_at,user: this.args.reviewable.target_created_by,- icon: "clock",+ icon: "pen-to-square",titleKey: "review.timeline.target_created_by",});}@@ -81,10 +81,13 @@ export default class ReviewableTimeline extends Component {this.args.reviewable.reviewable_scores.forEach((score) => {// Build description for flagged eventlet flaggedDescription = "";- if (score.reason || score.context) {- flaggedDescription = `<p>${score.reason ?? ""}</p><p>${escape(- score.context- )}</p>`;+ if (score.reason) {+ // generated by the server+ flaggedDescription += `<p>${score.reason}</p>`;+ }+ if (score.context) {+ // user input+ flaggedDescription += `<p>${escape(score.context)}</p>`;}// Add conversation message if available@@ -141,7 +144,9 @@ export default class ReviewableTimeline extends Component {user: score.reviewed_by,icon: reviewIcon,titleKey: "review.timeline.reviewed_by",- description: score.reason,+ description: score.reason+ ? htmlSafe(`<p>${score.reason}</p>`)+ : undefined,};events.push(reviewedEvent);@@ -169,7 +174,7 @@ export default class ReviewableTimeline extends Component {});});- return events.sort((a, b) => Date.parse(b.date) - Date.parse(a.date));+ return events.sort((a, b) => Date.parse(a.date) - Date.parse(b.date));}/**@@ -211,10 +216,6 @@ export default class ReviewableTimeline extends Component {<template><div class="reviewable-timeline">- <ReviewableNoteForm- @reviewable={{@reviewable}}- @onNoteCreated={{this.onNoteCreated}}- />{{#if this.timelineEvents}}<div class="timeline-events">@@ -281,6 +282,10 @@ export default class ReviewableTimeline extends Component {</p></div>{{/if}}+ <ReviewableNoteForm+ @reviewable={{@reviewable}}+ @onNoteCreated={{this.onNoteCreated}}+ /></div></template>}diff --git a/plugins/chat/assets/javascripts/discourse/components/reviewable-refresh/chat-message.gjs b/plugins/chat/assets/javascripts/discourse/components/reviewable-refresh/chat-message.gjsindex 38b1828058b..104ec9cb6d1 100644--- a/plugins/chat/assets/javascripts/discourse/components/reviewable-refresh/chat-message.gjs+++ b/plugins/chat/assets/javascripts/discourse/components/reviewable-refresh/chat-message.gjs@@ -65,7 +65,7 @@ export default class ReviewableRefreshChatMessage extends Component {<LinkTo@route="topic"@models={{array "-" @reviewable.payload.transcript_topic_id}}- class="btn btn-small"+ class="btn btn-default btn-small">{{i18n "review.transcript.view"}}</LinkTo>diff --git a/plugins/discourse-user-notes/assets/javascripts/discourse/connectors/reviewable-note-form-after-note/copy-reviewable-note-to-user-option.gjs b/plugins/discourse-user-notes/assets/javascripts/discourse/connectors/reviewable-note-form-after-note/copy-reviewable-note-to-user-option.gjsindex 817eddfa177..1de1657be01 100644--- a/plugins/discourse-user-notes/assets/javascripts/discourse/connectors/reviewable-note-form-after-note/copy-reviewable-note-to-user-option.gjs+++ b/plugins/discourse-user-notes/assets/javascripts/discourse/connectors/reviewable-note-form-after-note/copy-reviewable-note-to-user-option.gjs@@ -6,16 +6,20 @@ export default class CopyReviewableNoteToUserOption extends Component {return siteSettings.user_notes_enabled && currentUser?.staff;}+ get username() {+ return (+ this.args.outletArgs?.reviewable?.target_created_by?.username || "user"+ );+ }+<template>- <@form.CheckboxGroup as |group|>- <group.Field- @name="copy_note_to_user"- @title={{i18n "user_notes.copy_reviewable_note"}}- @format="full"- as |field|- >- <field.Checkbox />- </group.Field>- </@form.CheckboxGroup>+ <@form.Field+ @name="copy_note_to_user"+ @title={{i18n "user_notes.copy_reviewable_note" username=this.username}}+ @format="full"+ as |field|+ >+ <field.Checkbox />+ </@form.Field></template>}diff --git a/plugins/discourse-user-notes/config/locales/client.en.yml b/plugins/discourse-user-notes/config/locales/client.en.ymlindex e4e2aa3a13e..43610ac799b 100644--- a/plugins/discourse-user-notes/config/locales/client.en.yml+++ b/plugins/discourse-user-notes/config/locales/client.en.yml@@ -8,4 +8,4 @@ en:show: "User Notes (%{count})"delete_confirm: "Are you sure you want to delete that user note?"show_post: "Show Post"- copy_reviewable_note: "Copy note to user profile?"+ copy_reviewable_note: "Copy note to %{username}'s profile?"diff --git a/spec/system/page_objects/components/form_kit.rb b/spec/system/page_objects/components/form_kit.rbindex e22a68f04ee..276c0c806e6 100644--- a/spec/system/page_objects/components/form_kit.rb+++ b/spec/system/page_objects/components/form_kit.rb@@ -90,6 +90,8 @@ module PageObjectsif component.has_css?(".multi-select")"multi-select"+ elsif component.has_css?("textarea")+ "textarea"elseraise "Unknown custom control"enddiff --git a/spec/system/page_objects/components/review/flag_reason.rb b/spec/system/page_objects/components/review/flag_reason.rbindex 701761b35d7..ab39ee46278 100644--- a/spec/system/page_objects/components/review/flag_reason.rb+++ b/spec/system/page_objects/components/review/flag_reason.rb@@ -35,14 +35,16 @@ module PageObjectsReviewableScore.type_title(type).to_send- expect(find(".review-item__flag-reason.--#{css_class}").text.gsub(/\s+/, " ")).to eq(- expected_text,- )-- 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}")+ within(".review-item__header") do+ expect(find(".review-item__flag-reason.--#{css_class}").text.gsub(/\s+/, " ")).to eq(+ expected_text,+ )++ 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}")+ endendendenddiff --git a/spec/system/page_objects/components/review_note_form.rb b/spec/system/page_objects/components/review_note_form.rbindex af2e3d75990..4fcc4b5597b 100644--- a/spec/system/page_objects/components/review_note_form.rb+++ b/spec/system/page_objects/components/review_note_form.rb@@ -4,7 +4,7 @@ module PageObjectsmodule Componentsclass ReviewNoteForm < PageObjects::Components::Basedef add_note(note)- form.fill_in("note", with: note)+ form.fill_in("content", with: note)form.submitend