Skip to content

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

UX: update new reviewable style, add permalink, nav, link posts (#35768)

Kris891a50ef656f
diff --git a/app/assets/stylesheets/common/base/review.scss b/app/assets/stylesheets/common/base/review.scss
index 49c5b1e764b..2f7d8d34501 100644
--- a/app/assets/stylesheets/common/base/review.scss
+++ b/app/assets/stylesheets/common/base/review.scss
@@ -42,6 +42,7 @@
&__primary-content {
position: relative;
flex: 0 1 70%;
+ min-width: 0;
@include viewport.from(sm) {
border: 1px solid var(--content-border-color);
@@ -52,6 +53,18 @@
}
}
+ .reviewable-permalink-copy {
+ position: relative;
+ top: -0.35em;
+ right: calc(var(--space-2) * -1);
+ margin-left: calc(var(--space-4) * -1);
+
+ .post-action-feedback-alert {
+ top: -1rem;
+ left: 40%;
+ }
+ }
+
&__aside {
flex: 0 1 30%;
min-width: 0;
@@ -94,7 +107,7 @@
&__header {
display: grid;
- grid-template-columns: 1fr auto;
+ grid-template-columns: 1fr auto auto;
gap: var(--space-2);
align-items: start;
background-color: var(--primary-very-low);
@@ -105,6 +118,7 @@
display: flex;
gap: var(--space-1);
align-items: baseline;
+ flex-wrap: wrap;
}
&__flag-label,
@@ -113,6 +127,10 @@
text-align: left;
}
+ &__meta-label {
+ font-weight: bold;
+ }
+
&__flag-badges {
display: flex;
flex-wrap: wrap;
@@ -149,11 +167,10 @@
.names {
display: inline-block;
- font-weight: bold;
padding-left: var(--space-1);
span a {
- color: var(--primary);
+ color: var(--tertiary);
}
}
}
@@ -213,6 +230,12 @@
&__meta-topic-title {
display: flex;
gap: 0 var(--space-2);
+
+ .edits {
+ .btn .d-icon {
+ font-size: var(--font-down-2);
+ }
+ }
}
&__insights {
@@ -234,6 +257,7 @@
padding: var(--space-1) var(--space-2) var(--space-1) var(--space-3);
font-size: var(--font-down-1);
line-height: 1;
+ background: var(--primary-low);
&.--pending {
background-color: var(--primary-very-high);
@@ -336,13 +360,6 @@
}
}
- &__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;
@@ -454,7 +471,7 @@
}
&__title {
- color: var(--primary);
+ color: var(--primary-high);
margin: 0;
display: flex;
align-items: center;
diff --git a/app/assets/stylesheets/common/base/reviewables.scss b/app/assets/stylesheets/common/base/reviewables.scss
index bda0ae07216..ea8faaddc0f 100644
--- a/app/assets/stylesheets/common/base/reviewables.scss
+++ b/app/assets/stylesheets/common/base/reviewables.scss
@@ -201,11 +201,14 @@
}
.reviewable-user-details {
- border-bottom: 1px solid var(--content-border-color);
padding-bottom: 0.25em;
display: flex;
margin-bottom: 0.5em;
+ &:not(:last-child) {
+ border-bottom: 1px solid var(--content-border-color);
+ }
+
.name {
width: 8em;
font-weight: bold;
@@ -373,10 +376,6 @@
}
}
- .names {
- font-weight: bold;
- }
-
.post-contents-wrapper {
width: 100%;
margin-top: 1em;
@@ -554,6 +553,10 @@
}
}
+ &__meta-label {
+ font-weight: bold;
+ }
+
.reviewable-contents {
display: flex;
flex-wrap: wrap;
diff --git a/app/assets/stylesheets/common/post-action-feedback.scss b/app/assets/stylesheets/common/post-action-feedback.scss
index 2765ae29f31..a186a56dd13 100644
--- a/app/assets/stylesheets/common/post-action-feedback.scss
+++ b/app/assets/stylesheets/common/post-action-feedback.scss
@@ -4,36 +4,34 @@
}
}
-.post-controls {
- .post-action-feedback-button {
- position: relative;
- height: 100%;
+.post-action-feedback-button {
+ position: relative;
+ height: 100%;
- &.--activated,
- &.--activated:hover {
- .d-icon-d-post-share {
- color: var(--success);
- }
+ &.--activated,
+ &.--activated:hover {
+ .d-icon-d-post-share {
+ color: var(--success);
}
}
+}
- .post-action-feedback-svg {
- position: absolute;
- bottom: 0;
- right: 0;
- width: 20px;
- height: 20px;
- display: block;
- stroke: var(--success);
- opacity: 0;
+.post-action-feedback-svg {
+ position: absolute;
+ bottom: 0;
+ right: 0;
+ width: 20px;
+ height: 20px;
+ display: block;
+ stroke: var(--success);
+ opacity: 0;
- path {
- stroke: var(--success);
- stroke-width: 4;
- stroke-dasharray: 100;
- stroke-dashoffset: 100;
- animation: draw 1s forwards;
- }
+ path {
+ stroke: var(--success);
+ stroke-width: 4;
+ stroke-dasharray: 100;
+ stroke-dashoffset: 100;
+ animation: draw 1s forwards;
}
}
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index dc0c4dd002c..0fac7217b0e 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -950,6 +950,8 @@ en:
review_user: "User"
need_help: "Need help?"
copy_link: "Copy link"
+ copy_permalink_title: "copy a link to this reviewable item to clipboard"
+ copy_link_feedback: "Link copied"
view_source: "View source"
insights:
title: "Insights"
diff --git a/frontend/discourse/app/components/reviewable-post-edits.gjs b/frontend/discourse/app/components/reviewable-post-edits.gjs
index d8280d8af8d..eafa0fb84f8 100644
--- a/frontend/discourse/app/components/reviewable-post-edits.gjs
+++ b/frontend/discourse/app/components/reviewable-post-edits.gjs
@@ -1,12 +1,11 @@
/* eslint-disable ember/no-classic-components */
import Component from "@ember/component";
-import { on } from "@ember/modifier";
import { action } from "@ember/object";
import { gt } from "@ember/object/computed";
import { service } from "@ember/service";
+import DButton from "discourse/components/d-button";
import HistoryModal from "discourse/components/modal/history";
import { historyHeat } from "discourse/components/post/meta-data/edits-indicator";
-import icon from "discourse/helpers/d-icon";
import discourseComputed from "discourse/lib/decorators";
import { longDate } from "discourse/lib/formatter";
import { i18n } from "discourse-i18n";
@@ -16,6 +15,11 @@ export default class ReviewablePostEdits extends Component {
@gt("reviewable.post_version", 1) hasEdits;
+ @discourseComputed("reviewable.post_version")
+ editCount(postVersion) {
+ return postVersion - 1;
+ }
+
@discourseComputed("reviewable.post_updated_at")
historyClass(updatedAt) {
return historyHeat(this.siteSettings, new Date(updatedAt));
@@ -26,6 +30,11 @@ export default class ReviewablePostEdits extends Component {
return longDate(updatedAt);
}
+ @discourseComputed("reviewable.post_updated_at")
+ editedTitle(updatedAt) {
+ return i18n("post.last_edited_on", { dateTime: longDate(updatedAt) });
+ }
+
@action
showEditHistory(event) {
event?.preventDefault();
@@ -44,14 +53,15 @@ export default class ReviewablePostEdits extends Component {
<template>
{{#if this.hasEdits}}
- <a
- href
- {{on "click" this.showEditHistory}}
- class="has-edits {{this.historyClass}}"
- title={{i18n "post.last_edited_on" dateTime=this.editedDate}}
- >
- {{icon "pencil"}}
- </a>
+ <div class="post-info edits">
+ <DButton
+ @action={{this.showEditHistory}}
+ @icon="pencil"
+ @translatedLabel={{this.editCount}}
+ @translatedTitle={{this.editedTitle}}
+ class="btn-icon-text btn-flat {{this.historyClass}}"
+ />
+ </div>
{{/if}}
</template>
}
diff --git a/frontend/discourse/app/components/reviewable-refresh/insights.gjs b/frontend/discourse/app/components/reviewable-refresh/insights.gjs
index 1f7658c09b0..7631d034bef 100644
--- a/frontend/discourse/app/components/reviewable-refresh/insights.gjs
+++ b/frontend/discourse/app/components/reviewable-refresh/insights.gjs
@@ -1,5 +1,5 @@
import Component from "@glimmer/component";
-import icon from "discourse/helpers/d-icon";
+import { htmlSafe } from "@ember/template";
import { i18n } from "discourse-i18n";
/**
@@ -56,15 +56,24 @@ export default class ReviewableInsights extends Component {
);
}
}
- activities.push(
- i18n("review.insights.activities.posts", {
- count: user?.post_count || 0,
- })
- );
+
+ const postCount = user?.post_count || 0;
+ const postsText = i18n("review.insights.activities.posts", {
+ count: postCount,
+ });
+
+ if (postCount > 0 && user?.username) {
+ activities.push(
+ `<a href="/u/${user.username}/activity">${postsText}</a>`
+ );
+ } else {
+ activities.push(postsText);
+ }
+
insights.push({
icon: "users",
label: i18n("review.insights.user_activity"),
- description: activities.join(", "),
+ description: htmlSafe(activities.join(", ")),
});
// Visibility insight
@@ -83,14 +92,11 @@ export default class ReviewableInsights extends Component {
<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 class="review-insight__description">
+ {{insight.description}}
+ </div>
</div>
</div>
{{/each}}
diff --git a/frontend/discourse/app/components/reviewable-refresh/item.gjs b/frontend/discourse/app/components/reviewable-refresh/item.gjs
index ab7d713485f..2e91b790ea1 100644
--- a/frontend/discourse/app/components/reviewable-refresh/item.gjs
+++ b/frontend/discourse/app/components/reviewable-refresh/item.gjs
@@ -28,7 +28,10 @@ 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 { getAbsoluteURL } from "discourse/lib/get-url";
import optionalService from "discourse/lib/optional-service";
+import { showAlert } from "discourse/lib/post-action-feedback";
+import { clipboardCopy } from "discourse/lib/utilities";
import Category from "discourse/models/category";
import Composer from "discourse/models/composer";
import Topic from "discourse/models/topic";
@@ -645,6 +648,34 @@ export default class ReviewableItem extends Component {
}
}
+ get permalink() {
+ return getAbsoluteURL(`/review/${this.reviewable.id}`);
+ }
+
+ @action
+ async copyPermalink(event) {
+ const button = event.currentTarget;
+
+ // cmd/ctrl+click or middle-click to open in new tab
+ if (event.metaKey || event.ctrlKey || event.button === 1) {
+ window.open(this.permalink, "_blank");
+ return;
+ }
+
+ try {
+ await clipboardCopy(this.permalink);
+ showAlert(
+ this.reviewable.id,
+ "reviewable-permalink-copy",
+ "review.copy_link_feedback",
+ { actionBtn: button }
+ );
+ } catch (error) {
+ // eslint-disable-next-line no-console
+ console.error("Failed to copy to clipboard:", error);
+ }
+ }
+
<template>
<div class="review-container">
@@ -666,11 +697,19 @@ export default class ReviewableItem extends Component {
{{/each}}
</div>
</div>
-
{{newReviewableStatus
this.reviewable.status
this.reviewable.type
}}
+
+ <button
+ type="button"
+ {{on "click" this.copyPermalink}}
+ title={{i18n "review.copy_permalink_title"}}
+ class="btn btn-transparent reviewable-permalink-copy"
+ >
+ {{icon "d-post-share"}}
+ </button>
</div>
{{#let
diff --git a/frontend/discourse/app/templates/review/settings.gjs b/frontend/discourse/app/templates/review/settings.gjs
index a71614801fd..c1db397c582 100644
--- a/frontend/discourse/app/templates/review/settings.gjs
+++ b/frontend/discourse/app/templates/review/settings.gjs
@@ -1,9 +1,22 @@
import { fn } from "@ember/helper";
import DButton from "discourse/components/d-button";
+import NavItem from "discourse/components/nav-item";
import { i18n } from "discourse-i18n";
import ComboBox from "select-kit/components/combo-box";
export default <template>
+ <ul class="nav nav-pills reviewable-title">
+ <NavItem @route="review.index" @label="review.view_all" />
+ <NavItem @route="review.topics" @label="review.grouped_by_topic" />
+ {{#if @controller.currentUser.admin}}
+ <NavItem
+ @route="review.settings"
+ @label="review.settings.title"
+ @icon="wrench"
+ />
+ {{/if}}
+ </ul>
+
<div class="reviewable-settings">
<h4>{{i18n "review.settings.priorities.title"}}</h4>
diff --git a/frontend/discourse/app/templates/review/topics.gjs b/frontend/discourse/app/templates/review/topics.gjs
index 8c378b54307..734ac75c082 100644
--- a/frontend/discourse/app/templates/review/topics.gjs
+++ b/frontend/discourse/app/templates/review/topics.gjs
@@ -1,5 +1,6 @@
import { fn, hash } from "@ember/helper";
import { LinkTo } from "@ember/routing";
+import NavItem from "discourse/components/nav-item";
import ReviewableClaimedTopic from "discourse/components/reviewable-claimed-topic";
import TopicStatus from "discourse/components/topic-status";
import icon from "discourse/helpers/d-icon";
@@ -7,6 +8,18 @@ import replaceEmoji from "discourse/helpers/replace-emoji";
import { i18n } from "discourse-i18n";
export default <template>
+ <ul class="nav nav-pills reviewable-title">
+ <NavItem @route="review.index" @label="review.view_all" />
+ <NavItem @route="review.topics" @label="review.grouped_by_topic" />
+ {{#if @controller.currentUser.admin}}
+ <NavItem
+ @route="review.settings"
+ @label="review.settings.title"
+ @icon="wrench"
+ />
+ {{/if}}
+ </ul>
+
{{#if @controller.reviewableTopics.content}}
<table class="reviewable-topics">
<thead>