Skip to content

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

UX: Simplify the blog preview links, publication panel and editor list (#45470)

David Battersby201b62a65d9f
diff --git a/db/structure.sql b/db/structure.sql
index e01ed4944ce..3dd7bdb66e0 100644
--- a/db/structure.sql
+++ b/db/structure.sql
@@ -2297,7 +2297,8 @@ CREATE TABLE public.blog_reviews (
revoked_at timestamp(6) without time zone,
created_at timestamp(6) without time zone NOT NULL,
updated_at timestamp(6) without time zone NOT NULL,
- token character varying(64)
+ token character varying(64),
+ revoked_by_publish boolean DEFAULT false NOT NULL
);
@@ -26508,6 +26509,7 @@ ALTER TABLE ONLY public.ad_plugin_house_ads_groups
SET search_path TO "$user", public;
INSERT INTO "schema_migrations" (version) VALUES
+('20261102174233'),
('20261030180958'),
('20261029021723'),
('20261028093149'),
diff --git a/migrations/tooling/config/schema/plugin_manifest.yml b/migrations/tooling/config/schema/plugin_manifest.yml
index 1195096d80d..daee4c52278 100644
--- a/migrations/tooling/config/schema/plugin_manifest.yml
+++ b/migrations/tooling/config/schema/plugin_manifest.yml
@@ -275,7 +275,7 @@ plugins:
plugin_checksums:
automation: d168107063ed75d7e568f1c1250866f8
boards: b1410e9ce903ab8c722282afd4cf5b9f
- blog: 'f6e06ba7d5ee1897dc70e295096cd65b'
+ blog: '4cf722e384ecd08dd933aac624df7805'
chat: dfdf8b56a5fcd06326c693011990c36a
discourse-adplugin: 9e52419decf1099c5bc301a90e6cc91a
discourse-affiliate: '08c6e1a851441a082e9be9ddddc63910'
diff --git a/plugins/blog/app/controllers/blog/review_reader_controller.rb b/plugins/blog/app/controllers/blog/review_reader_controller.rb
index 4e7dd2b7366..bc7be4568b4 100644
--- a/plugins/blog/app/controllers/blog/review_reader_controller.rb
+++ b/plugins/blog/app/controllers/blog/review_reader_controller.rb
@@ -7,12 +7,20 @@ module ::Blog
:check_xhr,
:redirect_to_login_if_required,
:redirect_to_profile_if_required
+ # Reviewers are always anonymous, and without a user core's refresh would
+ # delete the signed-in editor's cookie when the reader shares the forum host.
+ skip_after_action :perform_refresh_session
prepend_before_action :prepare_review_request
- before_action :find_review, except: :csrf
+ before_action :find_review, except: :csrf, unless: :review_page?
layout "blog_review"
rescue_from Discourse::NotFound, ActiveRecord::RecordNotFound do
- render plain: I18n.t("blog.review.unavailable"), status: :not_found
+ published_url = request.format.json? && Review.published_article_url(params[:review_token])
+ if published_url
+ render json: { published_url: published_url }, status: :not_found
+ else
+ render plain: I18n.t("blog.review.unavailable"), status: :not_found
+ end
end
rescue_from ActiveRecord::RecordInvalid do |error|
@@ -25,7 +33,8 @@ module ::Blog
def show
respond_to do |format|
- format.html { render "default/empty" }
+ # The app boots either way, so an expired or revoked link explains itself.
+ format.html { render "default/empty", status: review_available? ? :ok : :not_found }
format.json do
render json: @review.as_json(only: %i[title cooked post_version created_at expires_at])
end
@@ -54,5 +63,15 @@ module ::Blog
def find_review
@review = Review.find_by_token!(params[:review_token])
end
+
+ def review_page?
+ action_name == "show" && request.format.html?
+ end
+
+ def review_available?
+ find_review.present?
+ rescue Discourse::NotFound
+ false
+ end
end
end
diff --git a/plugins/blog/app/controllers/blog/reviews_controller.rb b/plugins/blog/app/controllers/blog/reviews_controller.rb
index 7c2debaeb50..8f423ec9428 100644
--- a/plugins/blog/app/controllers/blog/reviews_controller.rb
+++ b/plugins/blog/app/controllers/blog/reviews_controller.rb
@@ -48,15 +48,8 @@ module ::Blog
end
def topic_feedback
- records =
- ReviewFeedback
- .joins(:review)
- .where(blog_reviews: { topic_id: @topic.id })
- .includes(:review)
- .order(id: :desc)
- .offset(page * 30)
- .limit(31)
- .to_a
+ scope = ReviewFeedback.joins(:review).where(blog_reviews: { topic_id: @topic.id })
+ records = scope.includes(:review).order(id: :desc).offset(page * 30).limit(31).to_a
render json: {
feedback:
records
@@ -67,6 +60,8 @@ module ::Blog
)
end,
more: records.length > 30,
+ # Feedback is paginated, so one page can't tell the client which version is newest.
+ latest_version: scope.maximum("blog_reviews.post_version"),
}
end
@@ -94,10 +89,9 @@ module ::Blog
end
def entry(review, active: review.accessible?)
- review.as_json(only: %i[id label title post_version created_at expires_at revoked_at]).merge(
- active: active,
- url: (review.url if active),
- )
+ review.as_json(
+ only: %i[id label title post_version created_at expires_at revoked_at revoked_by_publish],
+ ).merge(active: active, url: (review.url if active))
end
end
end
diff --git a/plugins/blog/app/models/blog/publication.rb b/plugins/blog/app/models/blog/publication.rb
index 0ab73a0d4bb..348bbd61852 100644
--- a/plugins/blog/app/models/blog/publication.rb
+++ b/plugins/blog/app/models/blog/publication.rb
@@ -462,7 +462,7 @@ module ::Blog
self.published = true
save!
paths.find_or_create_by!(path: path)
- Review.revoke_for_topic!(source.id)
+ Review.revoke_for_topic!(source.id, by_publish: true)
StaffActionLogger.new(user).log_custom(
"blog_publish",
topic_id: discussion_topic_id,
diff --git a/plugins/blog/app/models/blog/review.rb b/plugins/blog/app/models/blog/review.rb
index 709a033c328..5125ec48e96 100644
--- a/plugins/blog/app/models/blog/review.rb
+++ b/plugins/blog/app/models/blog/review.rb
@@ -59,6 +59,19 @@ module ::Blog
review
end
+ # Publishing closes the draft's links; the article is public by then, so its URL is safe to share.
+ def self.published_article_url(token)
+ return unless token.is_a?(String) && token.match?(TOKEN_FORMAT)
+ review = find_by(token: token, revoked_by_publish: true)
+ return unless review
+ publication =
+ Publication
+ .where(draft_topic_id: review.topic_id)
+ .or(Publication.where(topic_id: review.topic_id))
+ .first
+ publication.url if publication&.publicly_visible?
+ end
+
# The link only reaches editors, who can already read the draft and issue more links.
def url
"#{Configuration.review_url}?#{{ review_token: token }.to_query}"
@@ -112,9 +125,12 @@ module ::Blog
end
end
- def self.revoke_for_topic!(topic_id)
+ def self.revoke_for_topic!(topic_id, by_publish: false)
transaction do
- where(topic_id: topic_id, revoked_at: nil).update_all(revoked_at: Time.current)
+ where(topic_id: topic_id, revoked_at: nil).update_all(
+ revoked_at: Time.current,
+ revoked_by_publish: by_publish,
+ )
UploadReference.where(target: where(topic_id: topic_id)).delete_all
end
end
@@ -147,18 +163,19 @@ end
#
# Table name: blog_reviews
#
-# id :bigint not null, primary key
-# cooked :text not null
-# expires_at :datetime not null
-# label :string(100) default(""), not null
-# post_version :integer not null
-# revoked_at :datetime
-# title :string not null
-# token :string(64)
-# created_at :datetime not null
-# updated_at :datetime not null
-# creator_id :bigint not null
-# topic_id :bigint not null
+# id :bigint not null, primary key
+# cooked :text not null
+# expires_at :datetime not null
+# label :string(100) default(""), not null
+# post_version :integer not null
+# revoked_at :datetime
+# revoked_by_publish :boolean default(FALSE), not null
+# title :string not null
+# token :string(64)
+# created_at :datetime not null
+# updated_at :datetime not null
+# creator_id :bigint not null
+# topic_id :bigint not null
#
# Indexes
#
diff --git a/plugins/blog/assets/javascripts/discourse/components/blog-dashboard.gjs b/plugins/blog/assets/javascripts/discourse/components/blog-dashboard.gjs
index 5b968b20c5a..d0e25bf4db9 100644
--- a/plugins/blog/assets/javascripts/discourse/components/blog-dashboard.gjs
+++ b/plugins/blog/assets/javascripts/discourse/components/blog-dashboard.gjs
@@ -1,6 +1,6 @@
import Component from "@glimmer/component";
import { tracked } from "@glimmer/tracking";
-import { fn } from "@ember/helper";
+import { concat, fn } from "@ember/helper";
import { action } from "@ember/object";
import { service } from "@ember/service";
import DMenu from "discourse/float-kit/components/d-menu";
@@ -26,6 +26,34 @@ import {
STATUS_OPTIONS,
} from "discourse/plugins/blog/discourse/lib/blog-editor-filters";
+// "Changes pending" is still a live article; the edits are shown as separate pending work.
+function articleState(topic) {
+ return topic.status === "changes_pending" ? "live" : topic.status;
+}
+
+function pendingWork(topic) {
+ if (topic.awaiting_approval) {
+ return i18n(
+ topic.published
+ ? "blog.editor_table.edits_need_approval"
+ : "blog.panel.needs_approval"
+ );
+ }
+ if (topic.status === "changes_pending") {
+ return i18n("blog.editor_table.edits_pending");
+ }
+}
+
+const PendingWork = <template>
+ {{#let (pendingWork @topic) as |pending|}}
+ {{#if pending}}
+ <span class="status-label blog-dashboard__pending">
+ <span class="status-label-text">{{pending}}</span>
+ </span>
+ {{/if}}
+ {{/let}}
+</template>;
+
export default class BlogDashboard extends Component {
@service composer;
@service currentUser;
@@ -249,9 +277,9 @@ export default class BlogDashboard extends Component {
<th class="d-table__header-cell">{{i18n
"blog.editor_table.article"
}}</th>
- <th class="d-table__header-cell">{{i18n
- "blog.editor_table.status"
- }}</th>
+ <th
+ class="d-table__header-cell blog-dashboard__status-column"
+ >{{i18n "blog.editor_table.status"}}</th>
<th class="d-table__header-cell">{{i18n
"blog.editor_table.published"
}}</th>
@@ -269,29 +297,35 @@ export default class BlogDashboard extends Component {
>
<td class="d-table__cell --overview">
{{#if topic.live}}
- <a
- class="d-table__overview-link"
- href={{or topic.discussion_url topic.url}}
- >
- <div class="d-table__overview-name">{{or
- topic.public_title
- topic.title
- }}</div>
- </a>
+ <div class="blog-dashboard__title-row">
+ <a
+ class="d-table__overview-link"
+ href={{or topic.discussion_url topic.url}}
+ >
+ <div class="d-table__overview-name">{{or
+ topic.public_title
+ topic.title
+ }}</div>
+ </a>
+ <PendingWork @topic={{topic}} />
+ </div>
{{#if topic.public_excerpt}}
<p
class="blog-dashboard__excerpt"
>{{topic.public_excerpt}}</p>
{{/if}}
{{else}}
- <a
- class="d-table__overview-link"
- href={{topic.topic_url}}
- >
- <div
- class="d-table__overview-name"
- >{{topic.title}}</div>
- </a>
+ <div class="blog-dashboard__title-row">
+ <a
+ class="d-table__overview-link"
+ href={{topic.topic_url}}
+ >
+ <div
+ class="d-table__overview-name"
+ >{{topic.title}}</div>
+ </a>
+ <PendingWork @topic={{topic}} />
+ </div>
{{#if topic.excerpt}}
<p
class="blog-dashboard__excerpt"
@@ -299,39 +333,27 @@ export default class BlogDashboard extends Component {
{{/if}}
{{/if}}
</td>
- <td class="d-table__cell --detail">
+ <td
+ class="d-table__cell --detail blog-dashboard__status-column"
+ >
<div class="d-table__mobile-label">{{i18n
"blog.editor_table.status"
}}</div>
- <div class="blog-dashboard__statuses">
+ {{#let (articleState topic) as |state|}}
<div
class={{dConcatClass
"status-label"
"blog-dashboard__status"
- (if topic.live "--success")
- (unless (or topic.live topic.draft) "--inactive")
+ (if (eq state "live") "--success")
+ (if (eq state "unpublished") "--inactive")
}}
>
<div class="status-label-indicator"></div>
- <div class="status-label-text">{{#if
- topic.draft
- }}{{i18n "blog.private_draft"}}{{else if
- topic.live
- }}{{i18n "blog.published"}}{{else}}{{i18n
- "blog.not_published"
- }}{{/if}}</div>
+ <div class="status-label-text">{{i18n
+ (concat "blog.panel.badge." state)
+ }}</div>
</div>
- {{#if topic.scheduled_at}}
- <span class="blog-dashboard__scheduled">{{i18n
- "blog.editor_table.scheduled"
- }}</span>
- {{/if}}
- {{#if topic.draft_correction}}
- <span class="blog-dashboard__correction">{{i18n
- "blog.draft_correction"
- }}</span>
- {{/if}}
- </div>
+ {{/let}}
</td>
<td
class="d-table__cell --detail blog-dashboard__published"
diff --git a/plugins/blog/assets/javascripts/discourse/components/blog-publication-panel.gjs b/plugins/blog/assets/javascripts/discourse/components/blog-publication-panel.gjs
index 58778d5a600..764d7eda418 100644
--- a/plugins/blog/assets/javascripts/discourse/components/blog-publication-panel.gjs
+++ b/plugins/blog/assets/javascripts/discourse/components/blog-publication-panel.gjs
@@ -17,10 +17,33 @@ import DDropdownMenu from "discourse/ui-kit/d-dropdown-menu";
import DFlashMessage from "discourse/ui-kit/d-flash-message";
import DInterpolatedTranslation from "discourse/ui-kit/d-interpolated-translation";
import dAgeWithTooltip from "discourse/ui-kit/helpers/d-age-with-tooltip";
+import dIcon from "discourse/ui-kit/helpers/d-icon";
import { i18n } from "discourse-i18n";
import BlogReviews from "./modal/blog-reviews.gjs";
import BlogSchedule from "./modal/blog-schedule.gjs";
+const FeedbackEntry = <template>
+ <li class="blog-publication-panel__feedback-entry">
+ <div class="blog-publication-panel__feedback-meta">
+ <strong>{{or @entry.name (i18n "blog.review.anonymous")}}</strong>
+ {{#if @entry.email}}
+ <span
+ class="blog-publication-panel__feedback-email"
+ >{{@entry.email}}</span>
+ {{/if}}
+ <span aria-hidden="true" class="blog-publication-panel__sep">·</span>
+ {{dAgeWithTooltip @entry.created_at}}
+ <span aria-hidden="true" class="blog-publication-panel__sep">·</span>
+ <span class="blog-publication-panel__feedback-review">{{if
+ @entry.review.label
+ @entry.review.label
+ (i18n "blog.review.untitled")
+ }}</span>
+ </div>
+ <p class="blog-publication-panel__feedback-message">{{@entry.message}}</p>
+ </li>
+</template>;
+
export default class BlogPublicationPanel extends Component {
@service appEvents;
@service dialog;
@@ -31,8 +54,10 @@ export default class BlogPublicationPanel extends Component {
@tracked diff;
@tracked diffOpen = false;
@tracked feedback;
+ @tracked feedbackLatestVersion;
@tracked feedbackMore = false;
@tracked feedbackOpen = false;
+ @tracked olderFeedbackOpen = false;
@tracked settingsOpen = false;
// The settings form keeps its own snapshot so state changes do not discard edits in progress.
@tracked settingsData;
@@ -45,12 +70,14 @@ export default class BlogPublicationPanel extends Component {
constructor() {
super(...arguments);
this.appEvents.on("composer:edited-post", this, this.refresh);
+ this.appEvents.on("blog:topic-edited", this, this.refreshTopic);
this.settingsData = this.#settingsSnapshot();
}
willDestroy() {
super.willDestroy(...arguments);
this.appEvents.off("composer:edited-post", this, this.refresh);
+ this.appEvents.off("blog:topic-edited", this, this.refreshTopic);
}
get publication() {
@@ -77,6 +104,9 @@ export default class BlogPublicationPanel extends Component {
}
get badge() {
+ if (this.publication.awaiting_approval) {
+ return i18n("blog.panel.needs_approval");
+ }
return i18n(`blog.panel.badge.${this.status}`);
}
@@ -89,8 +119,21 @@ export default class BlogPublicationPanel extends Component {
return i18n(`blog.panel.headline.${this.status}`);
}
+ // On the forum's own host the path is enough; a separate blog domain is worth showing.
get displayUrl() {
- return this.publication.url.replace(/^https?:\/\//, "");
+ const url = new URL(this.publication.url, window.location.origin);
+ return url.host === window.location.host
+ ? url.pathname
+ : `${url.host}${url.pathname}`;
+ }
+
+ // Always relative ("6 days ago"); the exact time is in the tooltip.
+ get lastUpdatedAgo() {
+ return moment(this.publication.draft_updated_at).fromNow();
+ }
+
+ get lastUpdatedDate() {
+ return longDate(new Date(this.publication.draft_updated_at));
}
get publishedDate() {
@@ -102,9 +145,12 @@ export default class BlogPublicationPanel extends Component {
}
get changedFields() {
- return this.publication.changes
+ // A pending submission is shown as "Needs approval", not as a changed field.
+ const fields = this.publication.changes
+ .filter((field) => field !== "revision")
.map((field) => i18n(`blog.panel.change.${field}`))
.join(", ");
+ return fields.charAt(0).toLocaleUpperCase() + fields.slice(1);
}
get hasPendingChanges() {
@@ -120,12 +166,12 @@ export default class BlogPublicationPanel extends Component {
);
}
- get pendingRevision() {
- const submitted = this.publication.submitted_revision;
- if (!submitted || submitted.id === this.publication.published_revision_id) {
- return null;
- }
- return submitted;
+ get currentFeedback() {
+ return (this.feedback ?? []).filter((entry) => !this.#isOlder(entry));
+ }
+
+ get olderFeedback() {
+ return (this.feedback ?? []).filter((entry) => this.#isOlder(entry));
}
get hasReviews() {
@@ -144,8 +190,8 @@ export default class BlogPublicationPanel extends Component {
return "blog.panel.submit";
}
return this.hasPendingChanges
- ? "blog.panel.publish_correction"
- : "blog.panel.publish";
+ ? "blog.panel.publish_changes"
+ : "blog.panel.publish_now";
}
@action
@@ -189,11 +235,23 @@ export default class BlogPublicationPanel extends Component {
this.feedbackOpen = !this.feedbackOpen;
}
+ @action
+ toggleOlderFeedback() {
+ this.olderFeedbackOpen = !this.olderFeedbackOpen;
+ }
+
@action
loadMoreFeedback() {
return this.#loadFeedback(this.#feedbackPage + 1);
}
+ @action
+ refreshTopic(topicId) {
+ if (topicId === this.args.outletArgs.model.id) {
+ return this.refresh();
+ }
+ }
+
@action
async refresh() {
if (!this.publication) {
@@ -218,8 +276,9 @@ export default class BlogPublicationPanel extends Component {
{ title: this.publication.title }
),
didConfirm: async () => {
+ const openLinks = this.publication.active_review_links;
if (await this.#mutate("/publish")) {
- this.#announcePublished();
+ this.#announcePublished(openLinks);
}
},
});
@@ -232,8 +291,9 @@ export default class BlogPublicationPanel extends Component {
return;
}
}
+ const openLinks = this.publication.active_review_links;
if (await this.#mutate("/publish", { revision_id: revision.id })) {
- this.#announcePublished();
+ this.#announcePublished(openLinks);
}
}
@@ -302,13 +362,17 @@ export default class BlogPublicationPanel extends Component {
}
@action
- shareForReview() {
+ async shareForReview() {
+ await this.#menu?.close();
const open = async () => {
- await this.modal.show(BlogReviews, {
+ const result = await this.modal.show(BlogReviews, {
model: { topicId: this.publication.source_topic_id, draft: true },
});
// Links may have been issued or revoked while the modal was open.
await this.refresh();
+ if (result?.showFeedback) {
+ await this.toggleFeedback();
+ }
};
if (this.#form?.isDirty) {
this.dialog.confirm({
@@ -347,6 +411,7 @@ export default class BlogPublicationPanel extends Component {
this.feedback = page
? [...this.feedback, ...result.feedback]
: result.feedback;
+ this.feedbackLatestVersion = result.latest_version;
this.feedbackMore = result.more;
this.#feedbackPage = page;
return true;
@@ -358,6 +423,18 @@ export default class BlogPublicationPanel extends Component {
}
}
+ // Publishing ends a review round, and so does a newer version of the draft.
+ #isOlder(entry) {
+ const publishedAt = this.publication.last_published_at;
+ if (publishedAt && new Date(entry.created_at) <= new Date(publishedAt)) {
+ return true;
+ }
+ return (
+ this.feedbackLatestVersion != null &&
+ entry.review.post_version < this.feedbackLatestVersion
+ );
+ }
+
async #mutate(suffix, data = {}, type = "POST") {
this.busy = true;
try {
@@ -383,6 +460,7 @@ export default class BlogPublicationPanel extends Component {
this.diffOpen = false;
this.feedback = null;
this.feedbackOpen = false;
+ this.olderFeedbackOpen = false;
if (!this.#form?.isDirty) {
this.settingsData = this.#settingsSnapshot();
}
@@ -397,12 +475,13 @@ export default class BlogPublicationPanel extends Component {
};
}
- #announcePublished() {
+ // Publishing closes the draft's preview links, so say so rather than leaving them looking revoked.
+ #announcePublished(closedLinks) {
this.toasts.success({
data: {
- message: i18n("blog.panel.published", {
- id: this.publication.published_revision_id,
- }),
+ message: closedLinks
+ ? i18n("blog.panel.published_closed_links", { count: closedLinks })
+ : i18n("blog.panel.published"),
},
});
}
@@ -423,39 +502,13 @@ export default class BlogPublicationPanel extends Component {
}}</span>
<p class="blog-discussion-banner__text">
{{#if this.publication.live}}
- <DInterpolatedTranslation
- @key="blog.panel.discussion.intro"
- as |Placeholder|
- >
- <Placeholder @name="article">
- <a
- href={{this.publication.url}}
- rel="noopener noreferrer"
- target="_blank"
- >{{this.displayUrl}} ↗</a>
- </Placeholder>
- </DInterpolatedTranslation>
+ {{i18n "blog.panel.discussion.intro"}}
{{else}}
{{i18n "blog.panel.discussion.intro_not_live"}}
{{/if}}
- {{#if this.publication.source_url}}
- <DInterpolatedTranslation
- @key={{if
- this.publication.draft_correction
- "blog.panel.discussion.working_copy_pending"
- "blog.panel.discussion.working_copy"
- }}
- as |Placeholder|
- >
- <Placeholder @name="link">
- <a href={{this.publication.source_url}}>{{i18n
- "blog.panel.discussion.working_copy_link"
- }}</a>
- </Placeholder>
- </DInterpolatedTranslation>
- {{else}}
+ {{#unless this.publication.source_url}}
{{i18n "blog.panel.discussion.no_working_copy"}}
- {{/if}}
+ {{/unless}}
</p>
<DButton
class="btn-default blog-discussion-banner__edit"
@@ -486,31 +539,15 @@ export default class BlogPublicationPanel extends Component {
as |Placeholder|
>
<Placeholder @name="url">
- <a
- href={{this.publication.url}}
- rel="noopener noreferrer"
- target="_blank"
- >{{this.displayUrl}}</a>
+ <span
+ class="blog-publication-panel__future-url"
+ title={{this.publication.url}}
+ >{{this.displayUrl}}</span>
</Placeholder>
</DInterpolatedTranslation>
- {{#if this.publication.draft_updated_at}}
- <span
- aria-hidden="true"
- class="blog-publication-panel__sep"
- >·</span>
- <DInterpolatedTranslation
- @key="blog.panel.saved"
- as |Placeholder|
- >
- <Placeholder @name="age">{{dAgeWithTooltip
- this.publication.draft_updated_at
- }}</Placeholder>
- </DInterpolatedTranslation>
- {{/if}}
{{else if (eq this.status "scheduled")}}
{{i18n
"blog.panel.scheduled_revision"
- id=this.publication.scheduled_revision.id
user=this.publication.scheduled_revision.approved_by
}}
<span
@@ -526,21 +563,7 @@ export default class BlogPublicationPanel extends Component {
>·</span>
{{i18n "blog.panel.unpublished_notice"}}
{{else}}
- {{i18n
- "blog.panel.published_as"
- date=this.publishedDate
- id=this.publication.published_revision_id
- }}
- <span
- aria-hidden="true"
- class="blog-publication-panel__sep"
- >·</span>
- <a
- class="blog-publication-panel__view-live"
- href={{this.publication.url}}
- rel="noopener noreferrer"
- target="_blank"
- >{{i18n "blog.panel.view_live"}}</a>
+ {{i18n "blog.panel.published_as" date=this.publishedDate}}
{{#if this.publication.edits_since_publish}}
<span
aria-hidden="true"
@@ -551,6 +574,16 @@ export default class BlogPublicationPanel extends Component {
count=this.publication.edits_since_publish
}}
{{/if}}
+ <span
+ aria-hidden="true"
+ class="blog-publication-panel__sep"
+ >·</span>
+ <a
+ class="blog-publication-panel__view-live"
+ href={{this.publication.url}}
+ rel="noopener noreferrer"
+ target="_blank"
+ >{{i18n "blog.panel.view_live"}}</a>
{{/if}}
</p>
</div>
@@ -562,10 +595,9 @@ export default class BlogPublicationPanel extends Component {
href={{this.publication.scheduled_revision.preview_url}}
rel="noopener noreferrer"
target="_blank"
- >{{i18n
- "blog.panel.preview_revision"
- id=this.publication.scheduled_revision.id
- }}</a>
+ >{{dIcon "eye"}}<span class="d-button-label">{{i18n
+ "blog.panel.preview_scheduled"
+ }}</span></a>
{{#if this.publication.can_publish}}
<DButton
class="btn-default blog-publication-panel__cancel-schedule"
@@ -589,12 +621,21 @@ export default class BlogPublicationPanel extends Component {
href={{this.publication.preview_url}}
rel="noopener noreferrer"
target="_blank"
- >{{i18n "blog.panel.preview"}}</a>
- {{#if this.publication.source_topic_id}}
+ >{{dIcon "eye"}}<span class="d-button-label">{{i18n
+ "blog.panel.preview"
+ }}</span></a>
+ {{! Publishers reach sharing through their menu; others have no menu. }}
+ {{#if
+ (and
+ this.publication.source_topic_id
+ (not this.publication.can_publish)
+ )
+ }}
<DButton
class="btn-default blog-publication-panel__share-for-review"
@action={{this.shareForReview}}
@disabled={{this.busy}}
+ @icon="share"
@label="blog.panel.share_for_review"
/>
{{/if}}
@@ -623,64 +664,74 @@ export default class BlogPublicationPanel extends Component {
@title={{i18n "blog.panel.more_options"}}
>
<DDropdownMenu as |dropdown|>
- <dropdown.item>
- <DButton
- class="btn-transparent --with-description blog-publication-panel__menu-item blog-publication-panel__menu-publish"
- @action={{this.publish}}
- >
- <span
- class="blog-publication-panel__menu-label"
- >{{i18n "blog.panel.publish_now"}}</span>
- <span
- class="blog-publication-panel__menu-hint"
- >{{i18n
- (if
- this.hasPendingChanges
- "blog.panel.publish_correction_hint"
- "blog.panel.publish_now_hint"
- )
- }}</span>
- </DButton>
- </dropdown.item>
<dropdown.item>
<DButton
class="btn-transparent --with-description blog-publication-panel__menu-item blog-publication-panel__menu-schedule"
@action={{this.openSchedule}}
+ @icon="calendar-days"
>
- <span
- class="blog-publication-panel__menu-label"
- >{{i18n "blog.panel.schedule"}}</span>
- <span
- class="blog-publication-panel__menu-hint"
- >{{i18n "blog.panel.schedule_hint"}}</span>
+ <span class="blog-publication-panel__menu-text">
+ <span
+ class="blog-publication-panel__menu-label"
+ >{{i18n "blog.panel.schedule"}}</span>
+ <span
+ class="blog-publication-panel__menu-hint"
+ >{{i18n "blog.panel.schedule_hint"}}</span>
+ </span>
</DButton>
</dropdown.item>
<dropdown.item>
<DButton
class="btn-transparent --with-description blog-publication-panel__menu-item blog-publication-panel__menu-submit"
@action={{this.submit}}
+ @icon="user-check"
>
- <span
- class="blog-publication-panel__menu-label"
- >{{i18n "blog.panel.submit"}}</span>
- <span
- class="blog-publication-panel__menu-hint"
- >{{i18n "blog.panel.submit_hint"}}</span>
+ <span class="blog-publication-panel__menu-text">
+ <span
+ class="blog-publication-panel__menu-label"
+ >{{i18n "blog.panel.submit"}}</span>
+ <span
+ class="blog-publication-panel__menu-hint"
+ >{{i18n "blog.panel.submit_hint"}}</span>
+ </span>
</DButton>
</dropdown.item>
+ {{#if this.publication.source_topic_id}}
+ <dropdown.item>
+ <DButton
+ class="btn-transparent --with-description blog-publication-panel__menu-item blog-publication-panel__share-for-review"
+ @action={{this.shareForReview}}
+ @icon="share"
+ >
+ <span class="blog-publication-panel__menu-text">
+ <span
+ class="blog-publication-panel__menu-label"
+ >{{i18n "blog.panel.share_for_review"}}</span>
+ <span
+ class="blog-publication-panel__menu-hint"
+ >{{i18n
+ "blog.panel.share_for_review_hint"
+ }}</span>
+ </span>
+ </DButton>
+ </dropdown.item>
+ {{/if}}
{{#if this.publication.published}}
<dropdown.divider />
<dropdown.item>
<DButton
class="btn-transparent --with-description blog-publication-panel__menu-item blog-publication-panel__unpublish"
@action={{this.unpublish}}
+ @icon="eye-slash"
>
- <span
- class="blog-publication-panel__menu-label"
- >{{i18n "blog.unpublish"}}</span>
- <span
- class="blog-publication-panel__menu-hint"
- >{{i18n "blog.panel.unpublish_hint"}}</span>
+ <span class="blog-publication-panel__menu-text">
+ <span
+ class="blog-publication-panel__menu-label"
+ >{{i18n "blog.unpublish"}}</span>
+ <span
+ class="blog-publication-panel__menu-hint"
+ >{{i18n "blog.panel.unpublish_hint"}}</span>
+ </span>
</DButton>
</dropdown.item>
{{/if}}
@@ -688,29 +739,54 @@ export default class BlogPublicationPanel extends Component {
</combo.Menu>
</DComboButton>
{{else if this.publication.can_publish}}
- {{! Nothing differs from the live article, so only withdrawal is offered. }}
+ {{! Nothing differs from the live article, so no publishing actions are offered. }}
<DMenu
class="btn-default blog-publication-panel__options"
@disabled={{this.busy}}
- @icon="chevron-down"
+ @icon="ellipsis-vertical"
@identifier="blog-publish-menu"
- @label={{i18n "blog.panel.options"}}
@modalForMobile={{true}}
@onRegisterApi={{this.registerMenu}}
+ @placement="bottom-end"
+ @title={{i18n "blog.panel.more_options"}}
>
<:content>
<DDropdownMenu as |dropdown|>
+ {{#if this.publication.source_topic_id}}
+ <dropdown.item>
+ <DButton
+ class="btn-transparent --with-description blog-publication-panel__menu-item blog-publication-panel__share-for-review"
+ @action={{this.shareForReview}}
+ @icon="share"
+ >
+ <span class="blog-publication-panel__menu-text">
+ <span
+ class="blog-publication-panel__menu-label"
+ >{{i18n "blog.panel.share_for_review"}}</span>
+ <span
+ class="blog-publication-panel__menu-hint"
+ >{{i18n
+ "blog.panel.share_for_review_hint"
+ }}</span>
+ </span>
+ </DButton>
+ </dropdown.item>
+ <dropdown.divider />
+ {{/if}}
<dropdown.item>
<DButton
class="btn-transparent --with-description blog-publication-panel__menu-item blog-publication-panel__unpublish"
@action={{this.unpublish}}
+ @icon="eye-slash"
>
- <span
- class="blog-publication-panel__menu-label"
- >{{i18n "blog.unpublish"}}</span>
- <span
- class="blog-publication-panel__menu-hint"
- >{{i18n "blog.panel.unpublish_hint"}}</span>
+ <span class="blog-publication-panel__menu-text">
+ <span
+ class="blog-publication-panel__menu-label"
+ >{{i18n "blog.unpublish"}}</span>
+ <span
+ class="blog-publication-panel__menu-hint"
+ >{{i18n "blog.panel.unpublish_hint"}}</span>
+ </span>
</DButton>
</dropdown.item>
</DDropdownMenu>
@@ -720,34 +796,6 @@ export default class BlogPublicationPanel extends Component {
{{/if}}
</div>
- {{#if this.pendingRevision}}
- <div class="blog-publication-panel__pending">
- <span>{{i18n
- "blog.panel.submitted"
- id=this.pendingRevision.id
- }}</span>
- <a
- href={{this.pendingRevision.preview_url}}
- rel="noopener noreferrer"
- target="_blank"
- >{{i18n
- "blog.panel.preview_revision"
- id=this.pendingRevision.id
- }}</a>
- {{#if this.publication.can_publish}}
- <DButton
- class="btn-default blog-publication-panel__approve"
- @action={{fn this.publishRevision this.pendingRevision}}
- @disabled={{this.busy}}
- @translatedLabel={{i18n
- "blog.panel.approve_and_publish"
- id=this.pendingRevision.id
- }}
- />
- {{/if}}
- </div>
- {{/if}}
-
{{#if this.hasPendingChanges}}
<div class="blog-publication-panel__changes">
<div class="blog-publication-panel__changes-header">
@@ -768,10 +816,12 @@ export default class BlogPublicationPanel extends Component {
/>
{{/if}}
</div>
- <p class="blog-publication-panel__changed">{{i18n
- "blog.panel.changed"
- fields=this.changedFields
- }}</p>
+ {{#if this.changedFields}}
+ <p class="blog-publication-panel__changed">{{i18n
+ "blog.panel.changed"
+ fields=this.changedFields
+ }}</p>
+ {{/if}}
{{#if this.diffOpen}}
{{#if this.diff.diff_error}}
<p class="blog-publication-panel__diff-error">{{i18n
@@ -795,92 +845,80 @@ export default class BlogPublicationPanel extends Component {
<div class="blog-publication-panel__reviews">
<div class="blog-publication-panel__reviews-header">
<span class="blog-publication-panel__reviews-title">
- {{#if this.publication.review_feedback_count}}
- {{i18n
- "blog.panel.feedback.count"
- count=this.publication.review_feedback_count
- }}
- {{else}}
- {{i18n "blog.panel.feedback.none"}}
- {{/if}}
- <span
- aria-hidden="true"
- class="blog-publication-panel__sep"
- >·</span>
- <span class="blog-publication-panel__reviews-links">{{#if
- this.publication.active_review_links
- }}{{i18n
- "blog.panel.feedback.active_links"
- count=this.publication.active_review_links
- }}{{else}}{{i18n
- "blog.panel.feedback.no_active_links"
- }}{{/if}}</span>
- </span>
- <span class="blog-publication-panel__reviews-actions">
{{#if this.publication.review_feedback_count}}
<DButton
aria-expanded={{if this.feedbackOpen "true" "false"}}
class="btn-flat blog-publication-panel__toggle-feedback"
@action={{this.toggleFeedback}}
@disabled={{this.busy}}
+ @icon={{if
+ this.feedbackOpen
+ "chevron-down"
+ "chevron-right"
+ }}
@label={{if
this.feedbackOpen
"blog.panel.feedback.hide"
"blog.panel.feedback.show"
}}
/>
+ {{else}}
+ {{i18n "blog.panel.feedback.none"}}
{{/if}}
- <DButton
- class="btn-flat blog-publication-panel__manage-reviews"
- @action={{this.shareForReview}}
- @disabled={{this.busy}}
- @label="blog.panel.feedback.manage_links"
- />
</span>
+ <DButton
+ class="btn-flat blog-publication-panel__manage-reviews"
+ @action={{this.shareForReview}}
+ @disabled={{this.busy}}
+ @label="blog.panel.feedback.manage_links"
+ />
</div>
{{#if this.feedbackOpen}}
- <p class="blog-publication-panel__feedback-notice">{{i18n
- "blog.review.unverified"
- }}</p>
- <ul class="blog-publication-panel__feedback">
- {{#each this.feedback key="id" as |entry|}}
- <li class="blog-publication-panel__feedback-entry">
- <div class="blog-publication-panel__feedback-meta">
- <strong>{{or
- entry.name
- (i18n "blog.review.anonymous")
- }}</strong>
- {{#if entry.email}}
- <span
- class="blog-publication-panel__feedback-email"
- >{{entry.email}}</span>
- {{/if}}
- <span
- aria-hidden="true"
- class="blog-publication-panel__sep"
- >·</span>
- {{dAgeWithTooltip entry.created_at}}
- <span
- aria-hidden="true"
- class="blog-publication-panel__sep"
- >·</span>
- <span
- class="blog-publication-panel__feedback-review"
- >{{#if entry.review.label}}{{entry.review.label}}
- <span
- aria-hidden="true"
- class="blog-publication-panel__sep"
- >·</span>{{/if}}{{i18n
- "blog.review.version"
- version=entry.review.post_version
- }}</span>
- </div>
- <p
- class="blog-publication-panel__feedback-message"
- >{{entry.message}}</p>
- </li>
- {{/each}}
- </ul>
+ {{#if this.currentFeedback.length}}
+ <p class="blog-publication-panel__feedback-notice">{{i18n
+ "blog.review.unverified"
+ }}</p>
+ {{/if}}
+ {{#if this.currentFeedback.length}}
+ <ul class="blog-publication-panel__feedback">
+ {{#each this.currentFeedback key="id" as |entry|}}
+ <FeedbackEntry @entry={{entry}} />
+ {{/each}}
+ </ul>
+ {{else}}
+ <p class="blog-publication-panel__no-new-feedback">{{i18n
+ "blog.panel.feedback.no_new"
+ }}</p>
+ {{/if}}
+ {{#if this.olderFeedback.length}}
+ <DButton
+ aria-expanded={{if this.olderFeedbackOpen "true" "false"}}
+ class="btn-flat blog-publication-panel__toggle-older-feedback"
+ @action={{this.toggleOlderFeedback}}
+ @icon={{if
+ this.olderFeedbackOpen
+ "chevron-down"
+ "chevron-right"
+ }}
+ @translatedLabel={{if
+ this.olderFeedbackOpen
+ (i18n "blog.panel.feedback.hide_older")
+ (i18n
+ "blog.panel.feedback.show_older"
+ count=this.olderFeedback.length
+ )
+ }}
+ />
+ {{#if this.olderFeedbackOpen}}
+ <ul
+ class="blog-publication-panel__feedback blog-publication-panel__older-feedback"
+ >
+ {{#each this.olderFeedback key="id" as |entry|}}
+ <FeedbackEntry @entry={{entry}} />
+ {{/each}}
+ </ul>
+ {{/if}}
+ {{/if}}
{{#if this.feedbackMore}}
<DButton
class="btn-flat blog-publication-panel__more-feedback"
@@ -903,18 +941,33 @@ export default class BlogPublicationPanel extends Component {
{{/if}}
<div class="blog-publication-panel__settings">
- <DButton
- aria-controls={{settingsId}}
- aria-expanded={{if this.settingsOpen "true" "false"}}
- class="btn-flat blog-publication-panel__settings-toggle"
- @action={{this.toggleSettings}}
- @icon={{if this.settingsOpen "chevron-down" "chevron-right"}}
- @label="blog.panel.settings"
- >
- <span class="blog-publication-panel__settings-hint">{{i18n
- "blog.panel.settings_hint"
- }}</span>
- </DButton>
+ <div class="blog-publication-panel__settings-row">
+ <DButton
+ aria-controls={{settingsId}}
+ aria-expanded={{if this.settingsOpen "true" "false"}}
+ class="btn-flat blog-publication-panel__settings-toggle"
+ @action={{this.toggleSettings}}
+ @icon={{if this.settingsOpen "chevron-down" "chevron-right"}}
+ @label="blog.panel.settings"
+ >
+ <span class="blog-publication-panel__settings-hint">{{i18n
+ "blog.panel.settings_hint"
+ }}</span>
+ </DButton>
+ {{#if
+ (and
+ (eq this.status "draft") this.publication.draft_updated_at
+ )
+ }}
+ <span
+ class="blog-publication-panel__last-updated"
+ title={{this.lastUpdatedDate}}
+ >{{i18n
+ "blog.panel.last_updated"
+ age=this.lastUpdatedAgo
+ }}</span>
+ {{/if}}
+ </div>
<div hidden={{unless this.settingsOpen true}} id={{settingsId}}>
<Form
class="blog-publication-panel__form"
diff --git a/plugins/blog/assets/javascripts/discourse/components/blog-review.gjs b/plugins/blog/assets/javascripts/discourse/components/blog-review.gjs
index 91a42f619e1..030696fac09 100644
--- a/plugins/blog/assets/javascripts/discourse/components/blog-review.gjs
+++ b/plugins/blog/assets/javascripts/discourse/components/blog-review.gjs
@@ -6,6 +6,7 @@ import Form from "discourse/components/form";
import { ajax } from "discourse/lib/ajax";
import { popupAjaxError } from "discourse/lib/ajax-error";
import DFlashMessage from "discourse/ui-kit/d-flash-message";
+import dIcon from "discourse/ui-kit/helpers/d-icon";
import { i18n } from "discourse-i18n";
export default class BlogReview extends Component {
@@ -13,7 +14,9 @@ export default class BlogReview extends Component {
@tracked unavailable = false;
get expiresAt() {
- return new Date(this.args.review.expires_at).toLocaleString();
+ return moment(this.args.review.expires_at).format(
+ i18n("dates.long_with_year_no_time")
+ );
}
get article() {
@@ -47,11 +50,16 @@ export default class BlogReview extends Component {
@type="error"
/>
{{else}}
- <p class="blog-review__notice">{{i18n
- "blog.review.reader_notice"
- }}
- {{i18n "blog.review.expires" date=this.expiresAt}}</p>
+ <div class="blog-review__banner">
+ <span class="blog-review__badge">
+ {{dIcon "file-lines"}}
+ {{i18n "blog.review.reader_badge" [email protected]_version}}
+ </span>
+ <span class="blog-review__expiry">
+ {{dIcon "clock"}}
+ {{i18n "blog.review.expires" date=this.expiresAt}}
+ </span>
+ </div>
<article>
<h1>{{@review.title}}</h1>
<div class="blog-review__article cooked">{{this.article}}</div>
diff --git a/plugins/blog/assets/javascripts/discourse/components/modal/blog-reviews.gjs b/plugins/blog/assets/javascripts/discourse/components/modal/blog-reviews.gjs
index b6e32d9a95d..c6f332cbe2c 100644
--- a/plugins/blog/assets/javascripts/discourse/components/modal/blog-reviews.gjs
+++ b/plugins/blog/assets/javascripts/discourse/components/modal/blog-reviews.gjs
@@ -1,6 +1,6 @@
import Component from "@glimmer/component";
import { tracked } from "@glimmer/tracking";
-import { fn } from "@ember/helper";
+import { concat, fn } from "@ember/helper";
import { action } from "@ember/object";
import { service } from "@ember/service";
import Form from "discourse/components/form";
@@ -8,10 +8,60 @@ import { ajax } from "discourse/lib/ajax";
import { popupAjaxError } from "discourse/lib/ajax-error";
import { clipboardCopy } from "discourse/lib/utilities";
import DButton from "discourse/ui-kit/d-button";
-import DFlashMessage from "discourse/ui-kit/d-flash-message";
import DModal from "discourse/ui-kit/d-modal";
+import dConcatClass from "discourse/ui-kit/helpers/d-concat-class";
+import dIcon from "discourse/ui-kit/helpers/d-icon";
import { i18n } from "discourse-i18n";
+function shortDate(value) {
+ const date = moment(value);
+ return date.format(
+ i18n(
+ date.isSame(moment(), "year")
+ ? "dates.long_no_year_no_time"
+ : "dates.long_with_year_no_time"
+ )
+ );
+}
+
+function reviewStatus(review) {
+ if (review.active) {
+ return {
+ key: "active",
+ icon: "clock",
+ modifier: "--success",
+ detail: i18n("blog.review.expires", {
+ date: shortDate(review.expires_at),
+ }),
+ };
+ }
+ if (review.revoked_by_publish) {
+ return {
+ key: "published",
+ detail: i18n("blog.review.closed_on", {
+ date: shortDate(review.revoked_at),
+ }),
+ };
+ }
+ if (review.revoked_at) {
+ return {
+ key: "revoked",
+ detail: i18n("blog.review.revoked_on", {
+ date: shortDate(review.revoked_at),
+ }),
+ };
+ }
+ if (new Date(review.expires_at) <= new Date()) {
+ return {
+ key: "expired",
+ detail: i18n("blog.review.expired_on", {
+ date: shortDate(review.expires_at),
+ }),
+ };
+ }
+ return { key: "inactive" };
+}
+
export default class BlogReviews extends Component {
@service dialog;
@service toasts;
@@ -19,12 +69,9 @@ export default class BlogReviews extends Component {
@tracked busy = false;
@tracked reviews = [];
@tracked more = false;
- @tracked selectedReview;
- @tracked feedback = [];
- @tracked feedbackMore = false;
+ #form;
#page = 0;
- #feedbackPage = 0;
constructor() {
super(...arguments);
@@ -35,13 +82,15 @@ export default class BlogReviews extends Component {
return `/blog-editor/publications/${this.args.model.topicId}/reviews`;
}
- formatDate(value) {
- return value ? new Date(value).toLocaleString() : "";
+ @action
+ registerForm(api) {
+ this.#form = api;
}
@action
async create(data) {
if (await this.#request(".json", { type: "POST", data })) {
+ this.#form?.reset();
this.#page = 0;
await this.#load();
}
@@ -55,7 +104,9 @@ export default class BlogReviews extends Component {
data: { message: i18n("blog.review.copied") },
});
} catch {
- this.dialog.alert({ message: i18n("blog.review.copy_failed") });
+ this.dialog.alert({
+ message: i18n("blog.review.copy_failed", { url: review.url }),
+ });
}
}
@@ -81,35 +132,8 @@ export default class BlogReviews extends Component {
}
@action
- async viewFeedback(review) {
- const result = await this.#request(`/${review.id}/feedback.json`);
- if (result) {
- this.selectedReview = review;
- if (result.total !== undefined) {
- this.reviews = this.reviews.map((entry) =>
- entry.id === review.id
- ? { ...entry, feedback_count: result.total }
- : entry
- );
- }
- this.feedback = result.feedback;
- this.feedbackMore = result.more;
- this.#feedbackPage = 0;
- }
- }
-
- @action
- async loadMoreFeedback() {
- const page = this.#feedbackPage + 1;
- const result = await this.#request(
- `/${this.selectedReview.id}/feedback.json`,
- { data: { page } }
- );
- if (result) {
- this.feedback = [...this.feedback, ...result.feedback];
- this.feedbackMore = result.more;
- this.#feedbackPage = page;
- }
+ showFeedback() {
+ this.args.closeModal({ showFeedback: true });
}
async #load(page = 0) {
@@ -146,112 +170,134 @@ export default class BlogReviews extends Component {
>
<:body>
{{#if @model.draft}}
- <DFlashMessage
- @flash={{i18n "blog.review.sharing_notice"}}
- @type="warning"
- />
- <Form
- class="blog-reviews__create"
- @onSubmit={{this.create}}
- as |form|
- >
- <form.Field
- @format="full"
- @name="label"
- @title={{i18n "blog.review.label"}}
- @type="input"
- as |field|
- ><field.Control maxlength="100" /></form.Field>
- <form.Actions><form.Submit
+ <section class="blog-reviews__new">
+ <p class="blog-reviews__intro">{{i18n "blog.review.intro"}}</p>
+ <Form
+ class="blog-reviews__create"
+ @commitOnSubmit={{false}}
+ @onRegisterApi={{this.registerForm}}
+ @onSubmit={{this.create}}
+ as |form|
+ >
+ <form.Field
+ class="blog-reviews__label-field"
+ @format="full"
+ @name="label"
+ @title={{i18n "blog.review.label"}}
+ @type="input"
+ as |field|
+ ><field.Control
+ maxlength="100"
+ placeholder={{i18n "blog.review.label_placeholder"}}
+ /></form.Field>
+ <form.Submit
@disabled={{this.busy}}
@label="blog.review.create"
- /></form.Actions>
- </Form>
+ />
+ </Form>
+ </section>
{{/if}}
- <h3>{{i18n "blog.review.links"}}</h3>
+
{{#if this.reviews}}
- <p class="blog-reviews__notice">{{i18n "blog.review.copy_notice"}}</p>
- {{/if}}
- {{#each this.reviews key="id" as |review|}}
- <section class="blog-reviews__entry" data-review-id={{review.id}}>
- <strong>{{review.label}}</strong>
- <p>{{i18n
- "blog.review.expires"
- date=(this.formatDate review.expires_at)
- }}</p>
- <p>{{i18n "blog.review.version" version=review.post_version}}
- ·
- {{#if review.active}}{{i18n "blog.review.active"}}{{else}}{{i18n
- "blog.review.inactive"
- }}{{/if}}</p>
- {{#if review.url}}
- <div class="blog-reviews__link">
- <input
- aria-label={{i18n "blog.review.link"}}
- class="blog-reviews__link-url"
- readonly
- value={{review.url}}
- />
- <DButton
- class="blog-reviews__copy"
- @action={{fn this.copy review}}
- @disabled={{this.busy}}
- @icon="copy"
- @label="blog.review.copy"
- />
- <a
- class="blog-reviews__open"
- href={{review.url}}
- rel="noopener noreferrer"
- target="_blank"
- >{{i18n "blog.review.open"}}</a>
- </div>
- {{/if}}
- <DButton
- class="blog-reviews__feedback-toggle"
- @action={{fn this.viewFeedback review}}
- @disabled={{this.busy}}
- @translatedLabel={{i18n
- "blog.review.feedback_count"
- count=review.feedback_count
- }}
- />
- {{#unless review.revoked_at}}
+ <section class="blog-reviews__list">
+ <h3 class="blog-reviews__heading">{{i18n "blog.review.links"}}</h3>
+
+ {{#each this.reviews key="id" as |review|}}
+ {{#let (reviewStatus review) as |status|}}
+ <article
+ class={{dConcatClass
+ "blog-reviews__entry"
+ (unless review.active "--inactive")
+ }}
+ data-review-id={{review.id}}
+ >
+ <header class="blog-reviews__entry-header">
+ <div class="blog-reviews__entry-summary">
+ <div class="blog-reviews__entry-heading">
+ <h4 class="blog-reviews__entry-title">{{if
+ review.label
+ review.label
+ (i18n "blog.review.untitled")
+ }}</h4>
+ <span
+ class={{dConcatClass
+ "blog-reviews__status"
+ status.modifier
+ }}
+ >{{i18n
+ (concat "blog.review.status." status.key)
+ }}</span>
+ </div>
+ <p class="blog-reviews__entry-meta">
+ {{#if status.detail}}
+ <span class="blog-reviews__detail">
+ {{#if status.icon}}{{dIcon status.icon}}{{/if}}
+ {{status.detail}}
+ </span>
+ {{/if}}
+ {{#if review.feedback_count}}
+ <DButton
+ class="btn-link blog-reviews__feedback-link"
+ @action={{this.showFeedback}}
+ @translatedLabel={{i18n
+ "blog.review.feedback_count"
+ count=review.feedback_count
+ }}
+ />
+ {{else}}
+ <span class="blog-reviews__no-feedback">{{i18n
+ "blog.review.no_feedback"
+ }}</span>
+ {{/if}}
+ </p>
+ </div>
+ {{#unless review.revoked_at}}
+ <div class="blog-reviews__entry-buttons">
+ {{#if review.url}}
+ <DButton
+ class="btn-default btn-small blog-reviews__copy"
+ @action={{fn this.copy review}}
+ @disabled={{this.busy}}
+ @icon="copy"
+ @label="blog.review.copy"
+ />
+ <a
+ class="btn btn-default btn-small blog-reviews__open"
+ href={{review.url}}
+ rel="noopener noreferrer"
+ target="_blank"
+ >{{dIcon "up-right-from-square"}}<span
+ class="d-button-label"
+ >{{i18n "blog.review.open"}}</span></a>
+ {{/if}}
+ <DButton
+ class="btn-default btn-small blog-reviews__revoke"
+ @action={{fn this.revoke review}}
+ @disabled={{this.busy}}
+ @icon="ban"
+ @label="blog.review.revoke"
+ />
+ </div>
+ {{/unless}}
+ </header>
+
+ </article>
+ {{/let}}
+ {{/each}}
+
+ {{#if this.more}}
<DButton
- class="blog-reviews__revoke"
- @action={{fn this.revoke review}}
+ class="btn-default blog-reviews__load-more"
+ @action={{this.loadMore}}
@disabled={{this.busy}}
- @label="blog.review.revoke"
+ @label="blog.load_more"
/>
- {{/unless}}
+ {{/if}}
</section>
- {{else}}<p>{{i18n "blog.review.no_links"}}</p>{{/each}}
- {{#if this.more}}<DButton
- @action={{this.loadMore}}
- @disabled={{this.busy}}
- @label="blog.load_more"
- />{{/if}}
- {{#if this.selectedReview}}
- <h3>{{i18n
- "blog.review.feedback_for"
- version=this.selectedReview.post_version
- }}</h3>
- <p>{{i18n "blog.review.unverified"}}</p>
- {{#each this.feedback key="id" as |entry|}}
- <article class="blog-reviews__feedback">
- <strong>{{or entry.name (i18n "blog.review.anonymous")}}</strong>
- <span>{{entry.email}}</span>
- <time datetime={{entry.created_at}}>{{this.formatDate
- entry.created_at
- }}</time>
- <p>{{entry.message}}</p>
- </article>
- {{else}}<p>{{i18n "blog.review.no_feedback"}}</p>{{/each}}
- {{#if this.feedbackMore}}<DButton
- @action={{this.loadMoreFeedback}}
- @disabled={{this.busy}}
- @label="blog.load_more"
- />{{/if}}
+ {{else}}
+ {{#unless @model.draft}}
+ <p class="blog-reviews__empty">{{i18n "blog.review.no_links"}}</p>
+ {{/unless}}
{{/if}}
</:body>
</DModal>
diff --git a/plugins/blog/assets/javascripts/discourse/initializers/discourse-blog.js b/plugins/blog/assets/javascripts/discourse/initializers/discourse-blog.js
index 2cd4569b300..0b5800d55f6 100644
--- a/plugins/blog/assets/javascripts/discourse/initializers/discourse-blog.js
+++ b/plugins/blog/assets/javascripts/discourse/initializers/discourse-blog.js
@@ -6,6 +6,7 @@ export default {
name: "discourse-blog",
initialize(container) {
+ const appEvents = container.lookup("service:app-events");
const settings = container.lookup("service:site-settings");
if (!settings.blog_enabled) {
return;
@@ -21,6 +22,15 @@ export default {
});
}
api.renderInOutlet("topic-above-post-stream", BlogPublicationPanel);
+ // Inline title edits don't fire an app event, so tell the panel to recheck its status.
+ api.registerBehaviorTransformer(
+ "topic-controller:finished-editing",
+ async ({ next, context }) => {
+ const result = await next();
+ appEvents.trigger("blog:topic-edited", context.model?.id);
+ return result;
+ }
+ );
});
},
};
diff --git a/plugins/blog/assets/javascripts/discourse/routes/blog-review.js b/plugins/blog/assets/javascripts/discourse/routes/blog-review.js
index 19a2f24c2ac..338195652d1 100644
--- a/plugins/blog/assets/javascripts/discourse/routes/blog-review.js
+++ b/plugins/blog/assets/javascripts/discourse/routes/blog-review.js
@@ -37,7 +37,10 @@ export default class BlogReviewRoute extends DiscourseRoute {
return { ...review, token: review_token };
} catch (error) {
if ([403, 404].includes(error.jqXHR?.status)) {
- return { unavailable: true };
+ return {
+ unavailable: true,
+ publishedUrl: error.jqXHR.responseJSON?.published_url,
+ };
}
throw error;
}
diff --git a/plugins/blog/assets/javascripts/discourse/templates/blog-review.gjs b/plugins/blog/assets/javascripts/discourse/templates/blog-review.gjs
index cf712370772..c8d9ed010ab 100644
--- a/plugins/blog/assets/javascripts/discourse/templates/blog-review.gjs
+++ b/plugins/blog/assets/javascripts/discourse/templates/blog-review.gjs
@@ -10,7 +10,20 @@ export default <template>
{{hideApplicationFooter}}
{{hideScrollableContent "above"}}
{{hideScrollableContent "below"}}
- {{#if @model.unavailable}}
+ {{#if @model.publishedUrl}}
+ <section class="blog-review__published">
+ <h1 class="blog-review__published-title">{{i18n
+ "blog.review.published_title"
+ }}</h1>
+ <p class="blog-review__published-body">{{i18n
+ "blog.review.published_body"
+ }}</p>
+ <a
+ class="btn btn-primary blog-review__published-link"
+ href={{@model.publishedUrl}}
+ >{{i18n "blog.review.read_article"}}</a>
+ </section>
+ {{else if @model.unavailable}}
<DFlashMessage @flash={{i18n "blog.review.unavailable"}} @type="error" />
{{else}}
<BlogReview @review={{@model}} />
diff --git a/plugins/blog/assets/stylesheets/blog-editor.scss b/plugins/blog/assets/stylesheets/blog-editor.scss
index feacdec2e43..8a6ba48fbd7 100644
--- a/plugins/blog/assets/stylesheets/blog-editor.scss
+++ b/plugins/blog/assets/stylesheets/blog-editor.scss
@@ -1,3 +1,5 @@
+@use "lib/viewport";
+
.blog-dashboard {
max-width: 1000px;
width: 100%;
@@ -19,18 +21,40 @@
margin-block: var(--space-4);
}
- &__statuses {
+ &__title-row {
display: flex;
- flex-wrap: wrap;
align-items: center;
- gap: 0.25em 0.75em;
+ flex-wrap: wrap;
+ gap: var(--space-1) var(--space-2);
+ margin-bottom: var(--space-1);
+
+ // The pill sits beside the title, so the table's own width cap and spacing would leave a gap.
+ .d-table__overview-link .d-table__overview-name {
+ max-width: none;
+ margin-bottom: 0;
+ }
+ }
+
+ &__status-column {
+ min-width: 6em;
+
+ @include viewport.from(md) {
+ text-align: center;
+
+ .blog-dashboard__status {
+ margin-inline: auto;
+ }
+ }
+ }
+
+ &__status,
+ &__pending {
+ white-space: nowrap;
}
- &__correction,
&__excerpt,
&__published,
- &__replies,
- &__scheduled {
+ &__replies {
color: var(--primary-high);
font-size: var(--font-down-1);
}
diff --git a/plugins/blog/assets/stylesheets/blog-publication-panel.scss b/plugins/blog/assets/stylesheets/blog-publication-panel.scss
index 07a5ec7eda5..91d876d9363 100644
--- a/plugins/blog/assets/stylesheets/blog-publication-panel.scss
+++ b/plugins/blog/assets/stylesheets/blog-publication-panel.scss
@@ -74,6 +74,7 @@
&__meta {
margin: var(--space-1) 0 0;
+ padding-inline-start: 0.6em;
color: var(--primary-high);
font-size: var(--font-down-1);
@@ -82,19 +83,27 @@
}
}
+ &__future-url {
+ display: inline-block;
+ color: var(--primary);
+ max-width: 100%;
+ vertical-align: bottom;
+
+ @include ellipsis;
+ }
+
&__sep {
margin-inline: var(--space-1);
}
&__actions {
display: flex;
- align-items: center;
+ align-items: stretch;
justify-content: flex-end;
flex-wrap: wrap;
gap: var(--space-2);
}
- &__pending,
&__changes,
&__reviews,
&__error,
@@ -121,21 +130,32 @@
font-weight: 600;
}
- &__reviews-links {
- color: var(--primary-high);
- font-weight: normal;
+ // Line the labels up with the box edge while keeping the hover background padded.
+ &__toggle-feedback,
+ &__toggle-older-feedback,
+ &__settings-toggle {
+ margin-inline-start: calc(-1 * #{$hpad});
}
- &__reviews-actions {
- display: flex;
- gap: var(--space-1);
+ &__toggle-older-feedback {
+ margin-top: var(--space-2);
}
- &__feedback-notice {
+ &__manage-reviews {
+ margin-inline-end: calc(-1 * #{$hpad});
+ }
+
+ &__feedback-notice,
+ &__no-new-feedback {
margin: var(--space-2) 0 0;
color: var(--primary-high);
}
+ // Line up with the label of the earlier-responses toggle below, past its chevron.
+ &__no-new-feedback {
+ padding-inline-start: 1.5em;
+ }
+
&__feedback {
max-height: 24em;
margin: var(--space-3) 0 0;
@@ -169,17 +189,6 @@
overflow-wrap: anywhere;
}
- &__pending {
- display: flex;
- align-items: center;
- flex-wrap: wrap;
- gap: var(--space-3);
- padding: var(--space-3) var(--space-4);
- border-radius: var(--d-border-radius);
- background: var(--tertiary-very-low);
- font-size: var(--font-down-1);
- }
-
&__changes {
padding: var(--space-3) var(--space-4);
border-radius: var(--d-border-radius);
@@ -230,8 +239,21 @@
border-top: 1px solid var(--primary-low);
}
+ &__settings-row {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ flex-wrap: wrap;
+ gap: var(--space-2);
+ }
+
+ &__last-updated {
+ color: var(--primary-high);
+ font-size: var(--font-down-1);
+ }
+
&__settings-toggle {
- padding-inline: 0;
+ font-size: var(--font-down-1);
}
&__settings-hint {
@@ -244,32 +266,15 @@
margin-block-start: var(--space-3);
}
- &__menu-item {
- display: flex;
- flex-direction: column;
- align-items: flex-start;
- width: 100%;
- text-align: start;
- }
-
&__menu-hint {
color: var(--primary-high);
font-size: var(--font-down-1);
}
- &__unpublish {
- &,
- .blog-publication-panel__menu-hint {
- color: var(--danger);
- }
- }
-
- @media (width <= 767px) {
- grid-template-columns: minmax(0, 1fr);
-
- &__actions {
- justify-content: flex-start;
- }
+ &__menu-text {
+ display: flex;
+ flex-direction: column;
+ align-items: flex-start;
}
}
diff --git a/plugins/blog/assets/stylesheets/blog-review.scss b/plugins/blog/assets/stylesheets/blog-review.scss
index c476dc51704..a03af1420bd 100644
--- a/plugins/blog/assets/stylesheets/blog-review.scss
+++ b/plugins/blog/assets/stylesheets/blog-review.scss
@@ -16,31 +16,48 @@
}
}
-.blog-reviews {
- &__notice {
- color: var(--primary-high);
+.blog-review {
+ &__published {
+ display: flex;
+ flex-direction: column;
+ align-items: flex-start;
+ gap: var(--space-3);
+ }
+
+ &__published-title,
+ &__published-body {
+ margin: 0;
}
- &__link {
+ &__banner {
display: flex;
align-items: center;
+ justify-content: space-between;
flex-wrap: wrap;
- gap: var(--space-2);
- margin-block: var(--space-2);
+ gap: var(--space-2) var(--space-4);
+ padding-bottom: var(--space-5);
+ margin-bottom: var(--space-6);
+ border-bottom: 1px solid var(--content-border-color);
+ font-size: var(--font-down-1);
}
- &__link-url {
- flex: 1 1 20em;
- min-width: 0;
- margin: 0;
+ &__badge,
+ &__expiry {
+ display: inline-flex;
+ align-items: center;
+ gap: var(--space-1);
}
-}
-.blog-review {
- &__notice {
+ &__badge {
+ padding: var(--space-1) var(--space-3);
+ border-radius: var(--space-4);
+ background: var(--primary-low);
+ color: var(--primary-high);
+ font-weight: 600;
+ }
+
+ &__expiry {
color: var(--primary-high);
- border-bottom: 1px solid var(--content-border-color);
- padding-bottom: var(--space-3);
}
&__article {
@@ -66,18 +83,134 @@
}
.blog-reviews {
- &__entry,
- &__feedback {
- padding-block: var(--space-4);
- border-bottom: 1px solid var(--content-border-color);
+ &__new,
+ &__list {
+ display: flex;
+ flex-direction: column;
+ }
+
+ &__new {
+ gap: var(--space-4);
+ }
+
+ &__list {
+ gap: var(--space-3);
+ }
+
+ &__new + .blog-reviews__list {
+ margin-top: var(--space-5);
+ padding-top: var(--space-5);
+ border-top: 1px solid var(--content-border-color);
+ }
+
+ &__intro {
+ margin: 0;
+ color: var(--primary-high);
+ }
+
+ &__create {
+ flex-direction: row;
+ flex-wrap: wrap;
+ align-items: flex-end;
+ gap: var(--space-2);
+ }
+
+ &__label-field {
+ flex: 1 1 14em;
+ min-width: 0;
+ }
+
+ &__heading {
+ margin: 0;
+ font-size: var(--font-up-1);
+ }
+
+ &__empty {
+ margin: 0;
+ color: var(--primary-high);
+ }
+
+ &__entry {
+ display: flex;
+ flex-direction: column;
+ gap: var(--space-2);
+ padding: var(--space-4);
+ border: 1px solid var(--content-border-color);
+ border-radius: var(--d-border-radius);
overflow-wrap: anywhere;
}
- &__feedback p {
- white-space: pre-wrap;
+ &__entry-header {
+ display: flex;
+ align-items: center;
+ flex-wrap: wrap;
+ gap: var(--space-2) var(--space-4);
+ }
+
+ &__entry-summary {
+ display: flex;
+ flex: 1 1 12em;
+ flex-direction: column;
+ gap: var(--space-1);
+ min-width: 0;
+ }
+
+ &__entry-heading {
+ display: flex;
+ align-items: center;
+ flex-wrap: wrap;
+ gap: var(--space-2);
+ }
+
+ &__entry-title {
+ margin: 0;
+ font-size: var(--font-0);
+ }
+
+ &__status {
+ padding: var(--space-half) var(--space-2);
+ border-radius: var(--space-4);
+ background: var(--primary-low);
+ color: var(--primary-high);
+ font-size: var(--font-down-1);
+
+ &.--success {
+ background: var(--success-low);
+ color: var(--success-hover);
+ }
+ }
+
+ &__entry-meta {
+ display: flex;
+ align-items: center;
+ flex-wrap: wrap;
+ gap: var(--space-1) var(--space-3);
+ margin: 0;
+ color: var(--primary-high);
+ font-size: var(--font-down-1);
+ }
+
+ &__detail,
+ &__no-feedback {
+ white-space: nowrap;
+ }
+
+ &__detail .d-icon {
+ margin-inline-end: var(--space-1);
+ }
+
+ &__feedback-link {
+ min-height: 0;
+ font-size: inherit;
+ }
+
+ &__entry-buttons {
+ display: flex;
+ flex-wrap: wrap;
+ gap: var(--space-2);
}
- &__open {
- margin-inline-start: var(--space-3);
+ &__load-more {
+ align-self: center;
}
}
diff --git a/plugins/blog/config/locales/client.en.yml b/plugins/blog/config/locales/client.en.yml
index ffabff19b9d..47781dc07eb 100644
--- a/plugins/blog/config/locales/client.en.yml
+++ b/plugins/blog/config/locales/client.en.yml
@@ -144,26 +144,23 @@ en:
scheduled: "Publishes %{date}"
unpublished: Removed from the blog
will_publish_to: "Will publish to %{url}"
- saved: "Saved %{age}"
- published_as: "Published %{date} as revision %{id}"
+ last_updated: "Last updated %{age}"
+ published_as: "Published on %{date}"
view_live: View live ↗
edits_since:
one: "%{count} edit since"
other: "%{count} edits since"
- scheduled_revision: "Revision %{id}, approved by %{user}"
+ scheduled_revision: "Approved by %{user}"
scheduled_notice: Edits you make now are not included unless you reschedule
last_published: "Last published %{date}"
unpublished_notice: The public discussion stays open
preview: Preview
- preview_revision: "Preview revision %{id}"
- share_for_review: Share for review
- publish: Publish
- publish_correction: Publish correction
+ preview_scheduled: Preview scheduled version
+ share_for_review: Create preview link
+ share_for_review_hint: Collect private feedback on the draft
+ publish_changes: Publish changes
publish_now: Publish now
- publish_now_hint: Copies the article to the blog immediately
- publish_correction_hint: Replaces the live article immediately
more_options: More publishing options
- options: Options
schedule: Schedule…
schedule_hint: Pick a date and time
schedule_title: Schedule publication
@@ -173,14 +170,16 @@ en:
schedule_submit: Schedule
submit: Submit for approval
submit_hint: Ask another publisher to sign off first
- submitted: "Revision %{id} submitted, awaiting approval"
- approve_and_publish: "Approve and publish revision %{id}"
+ needs_approval: Needs approval
unpublish_hint: Remove from the blog; the discussion stays public
cancel_schedule: Cancel schedule
- published: "Published — revision %{id} is live on the blog."
+ published: Published — the article is live on the blog.
+ published_closed_links:
+ one: Published — the article is live on the blog. Its preview link was closed.
+ other: Published — the article is live on the blog. Its %{count} preview links were closed.
publish_confirm: "Publish “%{title}” to the blog now? Only the article is copied; this topic and its replies stay private."
publish_correction_confirm: "Replace the live article with the current draft? The article keeps its URL and public discussion."
- changes_title: What changes on the blog
+ changes_title: What changed on the blog
changed: "Changed: %{fields}"
change:
title: title
@@ -189,7 +188,6 @@ en:
excerpt: excerpt
featured: featured flag
published_at: publication date
- revision: submitted revision
show_diff: Show diff
hide_diff: Hide diff
diff_error: The change is too large to show as a diff. Use Preview instead.
@@ -197,24 +195,19 @@ en:
settings_hint: Path, excerpt, date, featured
feedback:
none: No private feedback yet
- count:
- one: "%{count} private feedback"
- other: "%{count} private feedback"
- no_active_links: no active review links
- active_links:
- one: "%{count} active review link"
- other: "%{count} active review links"
- show: Read feedback
+ show: Show feedback
hide: Hide feedback
+ show_older:
+ one: Show %{count} earlier response
+ other: Show %{count} earlier responses
+ hide_older: Hide earlier responses
+ no_new: No new feedback since the last publish.
manage_links: Review links
discussion:
live: Live on the blog
not_live: Not on the blog
- intro: "This is the public discussion for %{article}."
+ intro: This is the public discussion, replies here will appear on the blog.
intro_not_live: This topic is not on the blog.
- working_copy: "Edits go through the %{link}."
- working_copy_pending: "Edits go through the %{link}, which has unpublished changes."
- working_copy_link: private working copy
no_working_copy: Edit privately to prepare changes in a private working copy without touching this topic.
edit_privately: Edit privately
review:
@@ -223,28 +216,36 @@ en:
expires: "Expires %{date}"
manage: Share for review and feedback
discard_metadata: Discard unsaved publication settings and share the saved article?
- sharing_notice: "Create a frozen copy of the saved article for seven days. Anyone with the link can read it and send private feedback, without an account. Later edits are not included. Existing upload URLs are not protected: do not use this for confidential attachments."
- label: Reviewer or review-round label
- create: Create seven-day review link
- copy_notice: Anyone with this link can read the article revision it was created from. Revoke it to stop it working.
- link: Review link
- copy: Copy link
+ intro: Anyone with the link can read the draft and leave private feedback.
+ label: Label
+ label_placeholder: For example, editorial round
+ create: Create link
+ untitled: Untitled review link
+ copy: Copy
copied: Review link copied
- copy_failed: Copying was blocked by your browser. Select and copy the review link from the field instead.
- open: Open review
+ copy_failed: "Copying was blocked by your browser. Copy this link instead: %{url}"
+ open: Open
links: Review links
- version: "Article revision %{version}"
- active: Active
- inactive: Expired or revoked
- revoke: Revoke link
+ status:
+ active: Active
+ expired: Expired
+ revoked: Revoked
+ published: Closed when published
+ inactive: Inactive
+ expired_on: "Expired %{date}"
+ revoked_on: "Revoked %{date}"
+ closed_on: "Closed %{date}"
+ revoke: Revoke
revoke_confirm: Revoke this review link? It will immediately stop accepting new views and feedback. Existing feedback stays private and available here.
- feedback_count: "Feedback (%{count})"
+ feedback_count: "Read feedback (%{count})"
no_links: No review links yet.
- feedback_for: "Private feedback on revision %{version}"
- unverified: Names and email addresses are supplied by reviewers and are not verified. This feedback is never published with the article.
- no_feedback: No feedback on this review link yet.
- unavailable: This review link has expired, was revoked, or is no longer available. Ask the editor for a new link.
- reader_notice: "Draft for review · frozen article revision %{version}. This link can expire or be revoked by the editor."
+ unverified: Private to editors. Names and emails aren't verified.
+ no_feedback: No feedback yet
+ unavailable: This review link has expired, was revoked, or is no longer available.
+ published_title: This draft has been published
+ published_body: The preview link was closed when the article went live.
+ read_article: Read the article
+ reader_badge: "Draft version %{version} for review"
leave_feedback: Leave feedback
feedback_privacy: Your feedback is private to the article editors. No account is required. Your name and email are optional; add an email if you would like the editor to contact you.
message: Feedback
@@ -268,7 +269,8 @@ en:
status: Status
published: Published
replies: Replies
- scheduled: Scheduled
+ edits_pending: Edits pending
+ edits_need_approval: Edits need approval
more_actions: More actions
preview_changes: Preview changes
view_on_blog: View on blog
@@ -278,8 +280,6 @@ en:
drafts: Drafts
published: Published
visit_blog: Visit blog
- private_draft: Draft
- draft_correction: Draft correction
public_discussion: Public discussion
not_published: Not on the blog
preview: Preview
diff --git a/plugins/blog/config/locales/server.en.yml b/plugins/blog/config/locales/server.en.yml
index f3d24efd547..90f261920cf 100644
--- a/plugins/blog/config/locales/server.en.yml
+++ b/plugins/blog/config/locales/server.en.yml
@@ -133,7 +133,7 @@ en:
review:
page_title: Draft review
javascript_required: Enable JavaScript to read this shared draft and leave feedback.
- unavailable: This review link has expired, was revoked, or is no longer available. Ask the editor for a new link.
+ unavailable: This review link has expired, was revoked, or is no longer available.
limit: This draft already has 20 active review links. Revoke one before creating another.
feedback_limit: This review has reached its feedback limit. Contact the editor for a new review link.
editorial:
diff --git a/plugins/blog/db/migrate/20261102174233_add_revoked_by_publish_to_blog_reviews.rb b/plugins/blog/db/migrate/20261102174233_add_revoked_by_publish_to_blog_reviews.rb
new file mode 100644
index 00000000000..cd645978ccd
--- /dev/null
+++ b/plugins/blog/db/migrate/20261102174233_add_revoked_by_publish_to_blog_reviews.rb
@@ -0,0 +1,6 @@
+# frozen_string_literal: true
+class AddRevokedByPublishToBlogReviews < ActiveRecord::Migration[8.1]
+ def change
+ add_column :blog_reviews, :revoked_by_publish, :boolean, default: false, null: false
+ end
+end
diff --git a/plugins/blog/lib/blog/publication_entry.rb b/plugins/blog/lib/blog/publication_entry.rb
index 8c0209848a3..4d1c1e6be96 100644
--- a/plugins/blog/lib/blog/publication_entry.rb
+++ b/plugins/blog/lib/blog/publication_entry.rb
@@ -60,6 +60,7 @@ module ::Blog
can_publish: Configuration.publisher?(user),
review_feedback_count: source ? feedback_count(source) : 0,
active_review_links: source ? Review.where(topic_id: source.id).unexpired.count : 0,
+ awaiting_approval: awaiting_approval?,
submitted_revision: revision_entry(publication.submitted_revision),
approved_revision: revision_entry(publication.approved_revision),
scheduled_revision: revision_entry(publication.scheduled_revision),
@@ -83,6 +84,13 @@ module ::Blog
"source"
end
+ # Scheduling submits and approves in one step, so only an unapproved submission is waiting.
+ def awaiting_approval?
+ submitted = publication.submitted_revision_id
+ submitted.present? && submitted != publication.published_revision_id &&
+ submitted != publication.approved_revision_id
+ end
+
def status(changes)
return "scheduled" if publication.scheduled_at
return "unpublished" if !publication.published? && publication.published_revision_id
diff --git a/plugins/blog/spec/requests/editorial_workflow_spec.rb b/plugins/blog/spec/requests/editorial_workflow_spec.rb
index 67b55803f20..7c5dc203b3d 100644
--- a/plugins/blog/spec/requests/editorial_workflow_spec.rb
+++ b/plugins/blog/spec/requests/editorial_workflow_spec.rb
@@ -35,6 +35,7 @@ RSpec.describe "Blog editorial workflow", type: :request do
post "/blog-editor/publications/#{topic.id}/submit.json"
expect(response.status).to eq(200)
revision_id = response.parsed_body.dig("submitted_revision", "id")
+ expect(response.parsed_body["awaiting_approval"]).to eq(true)
post "/blog-editor/publications/#{topic.id}/approve.json", params: { revision_id: revision_id }
expect(response.status).to eq(403)
post "/blog-editor/publications/#{topic.id}/publish.json", params: { revision_id: revision_id }
@@ -45,6 +46,7 @@ RSpec.describe "Blog editorial workflow", type: :request do
expect(response.status).to eq(400)
post "/blog-editor/publications/#{topic.id}/approve.json", params: { revision_id: revision_id }
expect(response.status).to eq(200)
+ expect(response.parsed_body["awaiting_approval"]).to eq(false)
first_post.revise(writer, raw: "A newer private edit that has not been submitted or approved.")
post "/blog-editor/publications/#{topic.id}/publish.json", params: { revision_id: revision_id }
expect(response.status).to eq(200)
diff --git a/plugins/blog/spec/requests/publication_panel_spec.rb b/plugins/blog/spec/requests/publication_panel_spec.rb
index df348b39cd9..471ca096150 100644
--- a/plugins/blog/spec/requests/publication_panel_spec.rb
+++ b/plugins/blog/spec/requests/publication_panel_spec.rb
@@ -74,6 +74,7 @@ RSpec.describe "Blog publication panel", type: :request do
older = Blog::Review.issue!(topic: topic, user: admin, label: "Round one")
newer = Blog::Review.issue!(topic: topic, user: admin)
+ newer.update_columns(post_version: 2)
older.submit_feedback!(name: "Ada", message: "Tighten the introduction.")
newer.submit_feedback!(message: "Loving it but the colours hurt.")
older.revoke!(admin)
@@ -94,6 +95,7 @@ RSpec.describe "Blog publication panel", type: :request do
expect(feedback.last["review"]).to include("label" => "Round one", "post_version" => 1)
expect(feedback.last["review"]["revoked_at"]).to be_present
expect(response.parsed_body["more"]).to be(false)
+ expect(response.parsed_body["latest_version"]).to eq(2)
sign_in(user)
get "/blog-editor/publications/#{topic.id}/feedback.json"
diff --git a/plugins/blog/spec/requests/reviews_spec.rb b/plugins/blog/spec/requests/reviews_spec.rb
index a03b041c07e..206bc481c9a 100644
--- a/plugins/blog/spec/requests/reviews_spec.rb
+++ b/plugins/blog/spec/requests/reviews_spec.rb
@@ -63,6 +63,57 @@ RSpec.describe "External draft review", type: :request do
expect(UserHistory.where(custom_type: "blog_review_create", acting_user_id: admin.id)).to exist
end
+ it "keeps a signed-in editor signed in after opening a review link on the forum host" do
+ SiteSetting.blog_url = ""
+ _review, token = issue_review
+
+ get "https://test.localhost/blog/review", params: { review_token: token }
+ expect(response.status).to eq(200)
+
+ get "https://test.localhost/blog-editor/publications/#{topic.id}/reviews.json"
+ expect(response.status).to eq(200)
+ end
+
+ it "boots the review page for a revoked link so it can explain itself" do
+ review, token = issue_review
+ delete "https://test.localhost/blog-editor/publications/#{topic.id}/reviews/#{review["id"]}.json"
+ sign_out
+
+ get "https://blog.example.com/blog/review", params: { review_token: token }
+ expect(response.status).to eq(404)
+ expect(response.media_type).to eq("text/html")
+ expect(response.body).not_to include(first_post.raw)
+
+ get "https://blog.example.com/blog/review.json", params: { review_token: token }
+ expect(response.status).to eq(404)
+ end
+
+ it "closes links on publish and points their readers to the live article" do
+ published_link, published_token = issue_review
+ manual, manual_token = issue_review
+ delete "https://test.localhost/blog-editor/publications/#{topic.id}/reviews/#{manual["id"]}.json"
+
+ publication = Blog::Publication.for_topic(topic)
+ publication.publish!(admin)
+
+ get "https://test.localhost/blog-editor/publications/#{topic.id}/reviews.json"
+ entries = response.parsed_body["reviews"].index_by { |entry| entry["id"] }
+ expect(entries[published_link["id"]]).to include(
+ "revoked_by_publish" => true,
+ "revoked_at" => be_present,
+ )
+ expect(entries[manual["id"]]).to include("revoked_by_publish" => false)
+
+ sign_out
+ get "https://blog.example.com/blog/review.json", params: { review_token: published_token }
+ expect(response.status).to eq(404)
+ expect(response.parsed_body["published_url"]).to eq(publication.reload.url)
+
+ get "https://blog.example.com/blog/review.json", params: { review_token: manual_token }
+ expect(response.status).to eq(404)
+ expect(response.body).not_to include("published_url")
+ end
+
it "shares a sanitized frozen revision without staff replies or custom code" do
private_reply =
Fabricate(
diff --git a/plugins/blog/test/javascripts/acceptance/blog-editor-test.js b/plugins/blog/test/javascripts/acceptance/blog-editor-test.js
index c0c56a3479a..f39fca7853a 100644
--- a/plugins/blog/test/javascripts/acceptance/blog-editor-test.js
+++ b/plugins/blog/test/javascripts/acceptance/blog-editor-test.js
@@ -38,6 +38,7 @@ acceptance("Blog editor", function (needs) {
url: "https://blog.example.com/an-unfinished-story",
excerpt: "",
featured: false,
+ status: "draft",
draft: true,
published: false,
live: false,
@@ -49,6 +50,7 @@ acceptance("Blog editor", function (needs) {
...draft,
id: 124,
title: "A published story",
+ status: "live",
draft: false,
published: true,
live: true,
@@ -113,6 +115,7 @@ acceptance("Blog editor", function (needs) {
url: "https://blog.example.com/live-article",
discussion_url: "/t/live-article/200",
source_url: "/t/private-correction/201",
+ status: "changes_pending",
draft_correction: true,
};
await visit("/blog-editor");
@@ -158,25 +161,49 @@ acceptance("Blog editor", function (needs) {
await click('[data-topic-id="124"] .blog-dashboard__more-actions');
assert
.dom('[data-topic-id="124"] .blog-dashboard__status')
- .hasText(
- "Published",
- "corrections do not mark a live article unpublished"
- );
+ .hasText("Live", "edits do not change the article's own state");
assert
- .dom('[data-topic-id="124"] .blog-dashboard__correction')
- .hasText("Draft correction", "pending editorial changes are identified");
+ .dom('[data-topic-id="124"] .blog-dashboard__pending')
+ .hasText("Edits pending", "unpublished edits are shown separately");
assert
.dom('[data-topic-id="123"] .blog-dashboard__status')
.hasText("Draft", "never-published articles are drafts");
+ assert
+ .dom('[data-topic-id="123"] .blog-dashboard__status')
+ .doesNotHaveClass("--success", "drafts use the neutral status style");
+ });
+
+ test("shows a submitted draft's approval request beside its state", async function (assert) {
+ draft = { ...draft, awaiting_approval: true };
+ await visit("/blog-editor");
+ assert
+ .dom('[data-topic-id="123"] .blog-dashboard__status')
+ .hasText("Draft", "a submitted draft is still a draft");
+ assert
+ .dom('[data-topic-id="123"] .blog-dashboard__pending')
+ .hasText("Needs approval");
assert
.dom('[data-topic-id="124"] .blog-dashboard__status')
+ .hasText("Live")
.hasClass("--success", "live articles use the success status style");
assert
- .dom('[data-topic-id="123"] .blog-dashboard__status')
- .doesNotHaveClass("--success", "drafts use the neutral status style");
+ .dom('[data-topic-id="124"] .blog-dashboard__pending')
+ .doesNotExist("articles without pending work show one status");
+ });
+
+ test("shows submitted edits on a live article", async function (assert) {
+ published = {
+ ...published,
+ status: "changes_pending",
+ awaiting_approval: true,
+ };
+ await visit("/blog-editor");
assert
- .dom('[data-topic-id="123"] .blog-dashboard__correction')
- .doesNotExist("new drafts are not corrections");
+ .dom('[data-topic-id="124"] .blog-dashboard__status')
+ .hasText("Live", "the article stays live while edits wait");
+ assert
+ .dom('[data-topic-id="124"] .blog-dashboard__pending')
+ .hasText("Edits need approval");
});
test("lists status, publication date, replies, and row actions", async function (assert) {
@@ -184,10 +211,11 @@ acceptance("Blog editor", function (needs) {
...published,
discussion_url: "/t/live-article/200",
scheduled_at: "2026-10-01T10:00:00.000Z",
+ status: "scheduled",
};
await visit("/blog-editor");
assert
- .dom('[data-topic-id="124"] .blog-dashboard__scheduled')
+ .dom('[data-topic-id="124"] .blog-dashboard__status')
.hasText("Scheduled", "scheduled releases are identified");
assert
.dom('[data-topic-id="124"] .blog-dashboard__published .relative-date')
diff --git a/plugins/blog/test/javascripts/acceptance/blog-publication-panel-test.js b/plugins/blog/test/javascripts/acceptance/blog-publication-panel-test.js
index e0fc3edd9c4..5cbc3da7dd7 100644
--- a/plugins/blog/test/javascripts/acceptance/blog-publication-panel-test.js
+++ b/plugins/blog/test/javascripts/acceptance/blog-publication-panel-test.js
@@ -1,5 +1,6 @@
-import { click, visit } from "@ember/test-helpers";
+import { click, fillIn as typeInto, visit } from "@ember/test-helpers";
import { test } from "qunit";
+import sinon from "sinon";
import { cloneJSON } from "discourse/lib/object";
import topicFixtures from "discourse/tests/fixtures/topic";
import pretender, { response } from "discourse/tests/helpers/create-pretender";
@@ -54,6 +55,7 @@ acceptance("Blog publication panel", function (needs) {
});
test("publishes the current draft in one step", async function (assert) {
+ publication.active_review_links = 2;
pretender.post("/blog-editor/publications/280/publish.json", (request) => {
assert.false(
new URLSearchParams(request.requestBody).has("revision_id"),
@@ -74,19 +76,31 @@ acceptance("Blog publication panel", function (needs) {
.dom(`${PANEL}__badge`)
.hasText("Draft", "a never-published draft is labelled");
assert
- .dom(`${PANEL}__meta a`)
+ .dom(`${PANEL}__future-url`)
.hasText(
"blog.example.com/an-unfinished-story",
"the future article address is shown"
);
+ assert
+ .dom(`${PANEL}__meta a`)
+ .doesNotExist("the future address is not linked before it exists");
assert
.dom(`${PANEL}__publish`)
- .hasText("Publish", "publishing is the primary action");
+ .hasText("Publish now", "publishing is the primary action");
+ const toasts = this.owner.lookup("service:toasts");
+ const toastSpy = sinon.spy(toasts.success);
+ sinon.replaceGetter(toasts, "success", () => toastSpy);
await click(`${PANEL}__publish`);
assert
.dom(".dialog-body")
.includesText("stay private", "the privacy boundary is explained");
await click(".dialog-footer .btn-primary");
+ assert.true(
+ toastSpy.calledWithMatch({
+ data: { message: sinon.match("Its 2 preview links were closed.") },
+ }),
+ "closing the draft's preview links is announced"
+ );
assert
.dom(`${PANEL}__badge`)
.hasText("Live", "the panel reflects the release");
@@ -128,10 +142,10 @@ acceptance("Blog publication panel", function (needs) {
.includesText("3 edits since", "the amount of drift is shown");
assert
.dom(`${PANEL}__changed`)
- .hasText("Changed: body, excerpt", "changed fields are listed");
+ .hasText("Changed: Body, excerpt", "changed fields are listed");
assert
.dom(`${PANEL}__publish`)
- .hasText("Publish correction", "corrections are named explicitly");
+ .hasText("Publish changes", "publishing edits is named explicitly");
await click(`${PANEL}__toggle-diff`);
assert
.dom(`${PANEL}__diff ins`)
@@ -147,6 +161,7 @@ acceptance("Blog publication panel", function (needs) {
pretender.post("/blog-editor/publications/280/submit.json", () => {
publication = {
...publication,
+ awaiting_approval: true,
submitted_revision: {
id: 7,
preview_url: "/blog-editor/preview/280?revision_id=7",
@@ -163,57 +178,23 @@ acceptance("Blog publication panel", function (needs) {
.doesNotExist("publisher options are not offered");
await click(`${PANEL}__publish`);
assert
- .dom(`${PANEL}__pending`)
- .includesText("Revision 7 submitted", "the submission is confirmed");
- assert
- .dom(`${PANEL}__approve`)
- .doesNotExist("approval requires a publisher");
+ .dom(`${PANEL}__badge`)
+ .hasText("Needs approval", "the submission replaces the status");
});
- test("publishers approve and publish a submitted revision", async function (assert) {
+ test("publishers see a pending submission without a separate approval step", async function (assert) {
+ publication.awaiting_approval = true;
publication.submitted_revision = {
id: 7,
preview_url: "/blog-editor/preview/280?revision_id=7",
};
- pretender.post("/blog-editor/publications/280/approve.json", (request) => {
- assert.step(
- `approve ${new URLSearchParams(request.requestBody).get("revision_id")}`
- );
- publication = {
- ...publication,
- approved_revision: publication.submitted_revision,
- };
- return response(publication);
- });
- pretender.post("/blog-editor/publications/280/publish.json", (request) => {
- assert.step(
- `publish ${new URLSearchParams(request.requestBody).get("revision_id")}`
- );
- publication = {
- ...publication,
- status: "live",
- published: true,
- live: true,
- published_revision_id: 7,
- };
- return response(publication);
- });
await visit(TOPIC_URL);
assert
- .dom(`${PANEL}__pending a`)
- .hasAttribute(
- "href",
- "/blog-editor/preview/280?revision_id=7",
- "the frozen revision can be previewed"
- );
- await click(`${PANEL}__approve`);
- assert.verifySteps(
- ["approve 7", "publish 7"],
- "only the submitted revision is approved and published"
- );
+ .dom(`${PANEL}__badge`)
+ .hasText("Needs approval", "the request is visible to publishers");
assert
- .dom(`${PANEL}__pending`)
- .doesNotExist("the published revision is no longer pending");
+ .dom(`${PANEL}__publish`)
+ .exists("publishing the draft approves it in one step");
});
test("schedules the current draft and allows cancellation", async function (assert) {
@@ -283,7 +264,7 @@ acceptance("Blog publication panel", function (needs) {
.hasText("Scheduled", "the scheduled release is shown");
assert
.dom(`${PANEL}__meta`)
- .includesText("approved by eviltrout", "provenance is shown");
+ .includesText("Approved by eviltrout", "provenance is shown");
await click(`${PANEL}__cancel-schedule`);
assert.verifySteps(["cancel"], "the schedule can be cancelled");
assert
@@ -323,33 +304,111 @@ acceptance("Blog publication panel", function (needs) {
},
],
more: false,
+ latest_version: 3,
})
);
await visit(TOPIC_URL);
assert
.dom(`${PANEL}__reviews-title`)
- .includesText("2 private feedback", "the feedback count is visible");
- assert
- .dom(`${PANEL}__reviews-title`)
- .includesText("1 active review link", "open links are counted");
+ .includesText("Show feedback", "feedback can be opened");
assert.dom(`${PANEL}__feedback`).doesNotExist("feedback loads on demand");
await click(`${PANEL}__toggle-feedback`);
- assert.dom(`${PANEL}__feedback-entry`).exists({ count: 2 });
assert
- .dom(`${PANEL}__feedback-entry:first-child`)
- .includesText("Anonymous reviewer", "missing names are labelled");
+ .dom(`${PANEL}__feedback-entry`)
+ .exists({ count: 1 }, "only feedback on the newest version is shown");
+ assert
+ .dom(`${PANEL}__feedback-entry`)
+ .includesText("Anonymous reviewer", "missing names are labelled")
+ .includesText("Untitled review link", "unlabelled links are named");
assert
- .dom(`${PANEL}__feedback-entry:last-child`)
+ .dom(`${PANEL}__toggle-older-feedback`)
+ .hasText("Show 1 earlier response", "older feedback is offered");
+ await click(`${PANEL}__toggle-older-feedback`);
+ assert.dom(`${PANEL}__feedback-entry`).exists({ count: 2 });
+ assert
+ .dom(`${PANEL}__older-feedback ${PANEL}__feedback-entry`)
.includesText("Ada", "reviewer names are shown")
- .includesText("Round one", "the review label is shown")
- .includesText("Article revision 1", "the reviewed revision is shown");
+ .includesText("Round one", "the review label is shown");
assert
- .dom(`${PANEL}__feedback-entry:last-child script`)
+ .dom(`${PANEL}__older-feedback script`)
.doesNotExist("feedback is rendered as text");
+ assert
+ .dom(`${PANEL}__toggle-older-feedback`)
+ .hasText("Hide earlier responses", "older feedback can be hidden again");
await click(`${PANEL}__toggle-feedback`);
assert.dom(`${PANEL}__feedback`).doesNotExist("feedback collapses again");
});
+ test("starts a new feedback round after publishing", async function (assert) {
+ publication = {
+ ...publication,
+ review_feedback_count: 1,
+ last_published_at: "2026-09-05T10:00:00Z",
+ };
+ pretender.get("/blog-editor/publications/280/feedback.json", () =>
+ response({
+ feedback: [
+ {
+ id: 1,
+ name: "Ada",
+ email: "",
+ message: "Tighten the introduction.",
+ created_at: "2026-09-02T10:00:00Z",
+ review: { id: 8, label: "Round one", post_version: 1 },
+ },
+ ],
+ more: false,
+ latest_version: 1,
+ })
+ );
+ await visit(TOPIC_URL);
+ await click(`${PANEL}__toggle-feedback`);
+ assert
+ .dom(`${PANEL}__no-new-feedback`)
+ .hasText(
+ "No new feedback since the last publish.",
+ "feedback on the published text is not presented as new"
+ );
+ assert
+ .dom(`${PANEL}__feedback-notice`)
+ .doesNotExist("the privacy note waits until feedback is shown");
+ assert
+ .dom(`${PANEL}__toggle-older-feedback`)
+ .hasText("Show 1 earlier response");
+ await click(`${PANEL}__toggle-older-feedback`);
+ assert
+ .dom(`${PANEL}__older-feedback ${PANEL}__feedback-entry`)
+ .includesText("Ada", "earlier feedback stays available");
+ assert
+ .dom(`${PANEL}__feedback-notice`)
+ .doesNotExist("expanding earlier feedback does not shift the list");
+ });
+
+ test("rechecks its status after the title is edited inline", async function (assert) {
+ publication = {
+ ...publication,
+ status: "live",
+ published: true,
+ live: true,
+ draft: false,
+ published_revision_id: 7,
+ };
+ await visit(TOPIC_URL);
+ assert.dom(`${PANEL}__badge`).hasText("Live");
+
+ publication = {
+ ...publication,
+ status: "changes_pending",
+ changes: ["title"],
+ };
+ await click("#topic-title .d-icon-pencil");
+ await typeInto("#edit-title", "A sharper title for the article");
+ await click("#topic-title .submit-edit");
+ assert
+ .dom(`${PANEL}__badge`)
+ .hasText("Changes pending", "the panel updates without a reload");
+ });
+
test("saves article settings without publishing", async function (assert) {
pretender.put("/blog-editor/publications/280.json", (request) => {
const data = new URLSearchParams(request.requestBody);
@@ -375,7 +434,7 @@ acceptance("Blog publication panel", function (needs) {
.hasText("Draft", "saving settings does not publish");
});
- test("the public discussion topic points at the private working copy", async function (assert) {
+ test("the public discussion topic explains where replies appear", async function (assert) {
publication = {
...publication,
role: "discussion",
@@ -389,14 +448,14 @@ acceptance("Blog publication panel", function (needs) {
await visit(TOPIC_URL);
assert.dom(PANEL).doesNotExist("the full panel stays on the working copy");
assert
- .dom(".blog-discussion-banner")
- .includesText(
- "which has unpublished changes",
- "pending corrections are mentioned"
+ .dom(".blog-discussion-banner__text")
+ .hasText(
+ "This is the public discussion, replies here will appear on the blog.",
+ "the banner explains where replies appear"
);
assert
.dom('.blog-discussion-banner a[href="/t/private-working-copy/281"]')
- .exists("the working copy is linked");
+ .doesNotExist("Edit privately is the way into the working copy");
assert
.dom(".blog-discussion-banner__edit")
.hasText("Edit privately", "editing is redirected to the working copy");
@@ -450,6 +509,6 @@ acceptance("Blog publication panel", function (needs) {
assert.dom(`${PANEL}__badge`).hasText("Scheduled");
assert
.dom(`${PANEL}__changed`)
- .includesText("body", "drift since the frozen revision is still listed");
+ .includesText("Body", "drift since the frozen revision is still listed");
});
});
diff --git a/plugins/blog/test/javascripts/acceptance/blog-review-test.js b/plugins/blog/test/javascripts/acceptance/blog-review-test.js
index 69638ba09e5..8d4d1a60d72 100644
--- a/plugins/blog/test/javascripts/acceptance/blog-review-test.js
+++ b/plugins/blog/test/javascripts/acceptance/blog-review-test.js
@@ -18,6 +18,24 @@ acceptance("Blog review reader", function (needs) {
);
});
+ test("points readers of a link closed by publishing to the live article", async function (assert) {
+ pretender.get("/blog/review.json", () =>
+ response(404, { published_url: "https://blog.example.com/live-story" })
+ );
+ await visit("/blog/review?review_token=closed-on-publish");
+ assert
+ .dom(".blog-review__published-title")
+ .hasText("This draft has been published");
+ assert
+ .dom(".blog-review__published-link")
+ .hasAttribute(
+ "href",
+ "https://blog.example.com/live-story",
+ "the reader can continue to the public article"
+ );
+ assert.dom(".blog-review__feedback").doesNotExist("feedback is closed");
+ });
+
test("accepts private feedback without an account or forum chrome", async function (assert) {
pretender.post("/blog/review/feedback.json", (request) => {
const values = new URLSearchParams(request.requestBody);
@@ -38,6 +56,9 @@ acceptance("Blog review reader", function (needs) {
assert
.dom(".blog-review h1")
.hasText("A frozen draft", "the frozen title is rendered");
+ assert
+ .dom(".blog-review__badge")
+ .hasText("Draft version 1 for review", "the reviewed revision is named");
assert
.dom(".blog-review__article")
.hasText(
@@ -94,8 +115,8 @@ acceptance("Blog review reader", function (needs) {
assert
.dom(".alert-error")
.includesText(
- "Ask the editor",
- "the recipient can request a replacement"
+ "no longer available",
+ "the recipient is told the link no longer works"
);
});
});
diff --git a/plugins/blog/test/javascripts/acceptance/blog-reviews-management-test.js b/plugins/blog/test/javascripts/acceptance/blog-reviews-management-test.js
index 490c3fd44e1..a47cd769968 100644
--- a/plugins/blog/test/javascripts/acceptance/blog-reviews-management-test.js
+++ b/plugins/blog/test/javascripts/acceptance/blog-reviews-management-test.js
@@ -12,10 +12,11 @@ acceptance("Blog review management", function (needs) {
needs.user({ admin: true });
needs.settings({ blog_enabled: true });
+ let draft;
let reviews;
needs.hooks.beforeEach(() => {
reviews = [];
- const draft = {
+ draft = {
id: 280,
role: "draft",
status: "draft",
@@ -42,7 +43,10 @@ acceptance("Blog review management", function (needs) {
);
});
- test("creates, reads private feedback, and revokes a review link separately from publication", async function (assert) {
+ test("creates and revokes a review link, then hands off to the private feedback list", async function (assert) {
+ pretender.get("/blog-editor/publications/280.json", () =>
+ response({ ...draft, review_feedback_count: 1 })
+ );
pretender.post("/blog-editor/publications/280/reviews.json", (request) => {
assert.strictEqual(
new URLSearchParams(request.requestBody).get("label"),
@@ -55,20 +59,22 @@ acceptance("Blog review management", function (needs) {
post_version: 1,
active: true,
feedback_count: 1,
+ expires_at: "2099-01-08T00:00:00Z",
url: "https://blog.example.com/blog/review?review_token=secret",
};
reviews = [review];
return response({ review });
});
- pretender.get("/blog-editor/publications/280/reviews/1/feedback.json", () =>
+ pretender.get("/blog-editor/publications/280/feedback.json", () =>
response({
feedback: [
{
id: 1,
name: "Guest",
email: "",
- message: "<script>not executable</script>",
+ message: "Tighten the introduction.",
created_at: "2030-01-01T00:00:00Z",
+ review: { id: 1, label: "Editorial round", post_version: 1 },
},
],
more: false,
@@ -87,6 +93,7 @@ acceptance("Blog review management", function (needs) {
return response(204);
});
await visit(TOPIC_URL);
+ await click(".blog-publication-panel__menu-trigger");
await click(".blog-publication-panel__share-for-review");
assert
.dom(".blog-reviews")
@@ -99,10 +106,13 @@ acceptance("Blog review management", function (needs) {
.fillIn("Editorial round");
await formKit(".blog-reviews__create").submit();
assert
- .dom(".blog-reviews__link-url")
- .hasValue(
- "https://blog.example.com/blog/review?review_token=secret",
- "an issued link stays readable instead of being shown once"
+ .form(".blog-reviews__create")
+ .field("label")
+ .hasValue("", "the label is cleared for the next link");
+ assert
+ .dom(".blog-reviews__copy")
+ .exists(
+ "an issued link stays available to copy instead of being shown once"
);
assert
.dom(".blog-reviews__open")
@@ -110,29 +120,53 @@ acceptance("Blog review management", function (needs) {
"href",
"https://blog.example.com/blog/review?review_token=secret"
);
- await click(".blog-reviews__feedback-toggle");
- assert
- .dom(".blog-reviews__feedback p")
- .hasText(
- "<script>not executable</script>",
- "untrusted feedback is escaped"
- );
- assert
- .dom(".blog-reviews__feedback script")
- .doesNotExist("feedback never becomes executable HTML");
await click(".blog-reviews__revoke");
assert.verifySteps([], "revocation requires confirmation");
await click(".dialog-footer .btn-primary");
assert.verifySteps(["revoked"], "the selected grant is revoked");
assert
- .dom(".blog-reviews__link")
+ .dom(".blog-reviews__copy")
.doesNotExist("a revoked link is no longer offered for sharing");
assert
.dom('[data-review-id="1"]')
.includesText(
- "Expired or revoked",
- "the old review remains available for private feedback"
+ "Revoked",
+ "the old review remains listed with its feedback"
);
+ await click(".blog-reviews__feedback-link");
+ assert
+ .dom(".blog-reviews")
+ .doesNotExist("the modal stays focused on links and closes");
+ assert
+ .dom(".blog-publication-panel__feedback-message")
+ .hasText("Tighten the introduction.", "feedback opens in the panel");
+ });
+
+ test("names links that publishing closed", async function (assert) {
+ reviews = [
+ {
+ id: 4,
+ label: "Before launch",
+ post_version: 1,
+ active: false,
+ feedback_count: 0,
+ expires_at: "2099-01-08T00:00:00Z",
+ revoked_at: "2030-01-01T00:00:00Z",
+ revoked_by_publish: true,
+ },
+ ];
+ await visit(TOPIC_URL);
+ await click(".blog-publication-panel__menu-trigger");
+ await click(".blog-publication-panel__share-for-review");
+ assert
+ .dom('[data-review-id="4"] .blog-reviews__status')
+ .hasText(
+ "Closed when published",
+ "publish closures are not shown as revokes"
+ );
+ assert
+ .dom('[data-review-id="4"] .blog-reviews__revoke')
+ .doesNotExist("a closed link cannot be revoked again");
});
test("asks before discarding unsaved publication settings", async function (assert) {
@@ -141,6 +175,7 @@ acceptance("Blog review management", function (needs) {
await formKit(".blog-publication-panel__form")
.field("excerpt")
.fillIn("Unsaved publication excerpt");
+ await click(".blog-publication-panel__menu-trigger");
await click(".blog-publication-panel__share-for-review");
assert
.dom(".dialog-body")