Skip to content

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

UX: link chat settings in retention message (#37683)

Krisf585f0c73c06
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-retention-reminder-text.gjs b/plugins/chat/assets/javascripts/discourse/components/chat-retention-reminder-text.gjs
index 9076dc72396..ffb332218e1 100644
--- a/plugins/chat/assets/javascripts/discourse/components/chat-retention-reminder-text.gjs
+++ b/plugins/chat/assets/javascripts/discourse/components/chat-retention-reminder-text.gjs
@@ -1,31 +1,38 @@
import Component from "@glimmer/component";
import { service } from "@ember/service";
+import { htmlSafe } from "@ember/template";
+import getURL from "discourse/lib/get-url";
import { i18n } from "discourse-i18n";
export default class ChatRetentionReminderText extends Component {
+ @service currentUser;
@service siteSettings;
get type() {
return this.args.type ?? "long";
}
+ get #chatSettingsLink() {
+ const label = i18n("chat.retention_reminders.chat_settings");
+ if (this.currentUser?.admin) {
+ const url = getURL("/admin/site_settings/category/chat");
+ return `<a href="${url}">${label}</a>`;
+ }
+ return label;
+ }
+
get text() {
- if (this.args.channel.isDirectMessageChannel) {
- if (this.#countForChannelType > 0) {
- return i18n(`chat.retention_reminders.${this.type}`, {
- count: this.siteSettings.chat_dm_retention_days,
- });
- } else {
- return i18n(`chat.retention_reminders.indefinitely_${this.type}`);
- }
+ const opts = { chatSettingsLink: this.#chatSettingsLink };
+ const count = this.#countForChannelType;
+
+ if (count > 0) {
+ return htmlSafe(
+ i18n(`chat.retention_reminders.${this.type}`, { ...opts, count })
+ );
} else {
- if (this.#countForChannelType > 0) {
- return i18n(`chat.retention_reminders.${this.type}`, {
- count: this.siteSettings.chat_channel_retention_days,
- });
- } else {
- return i18n(`chat.retention_reminders.indefinitely_${this.type}`);
- }
+ return htmlSafe(
+ i18n(`chat.retention_reminders.indefinitely_${this.type}`, opts)
+ );
}
}
diff --git a/plugins/chat/assets/stylesheets/common/chat-notices.scss b/plugins/chat/assets/stylesheets/common/chat-notices.scss
index 117d3ca856d..8757b0ff13e 100644
--- a/plugins/chat/assets/stylesheets/common/chat-notices.scss
+++ b/plugins/chat/assets/stylesheets/common/chat-notices.scss
@@ -20,13 +20,17 @@
justify-content: space-between;
background: var(--tertiary-low);
padding: var(--space-2);
- border-radius: var(--d-border-radius);
color: var(--primary);
min-width: 280px;
margin-left: auto;
margin-right: auto;
gap: 0.25rem;
box-sizing: border-box;
+ border-radius: var(--d-border-radius);
+
+ .chat-drawer-outlet & {
+ border-radius: 0;
+ }
&:has(.dismiss-btn) {
padding-right: 0;
@@ -37,6 +41,10 @@
color: var(--primary-medium);
align-self: flex-start;
+ .chat-drawer-outlet & {
+ padding-top: var(--space-half);
+ }
+
&:hover,
&:focus {
background: var(--tertiary-medium);
diff --git a/plugins/chat/config/locales/client.en.yml b/plugins/chat/config/locales/client.en.yml
index 3494f49ea56..9c7e67d05b8 100644
--- a/plugins/chat/config/locales/client.en.yml
+++ b/plugins/chat/config/locales/client.en.yml
@@ -628,14 +628,15 @@ en:
other: "%{commaSeparatedUsernames} and %{count} others are typing"
retention_reminders:
+ chat_settings: "Chat settings"
indefinitely_short: "indefinitely"
- indefinitely_long: "Chat settings have been set to retain channel messages indefinitely."
+ indefinitely_long: "%{chatSettingsLink} have been set to retain channel messages indefinitely."
short:
one: "%{count} day"
other: "%{count} days"
long:
- one: "Chat settings have been set to retain channel messages for %{count} day."
- other: "Chat settings have been set to retain channel messages for %{count} days."
+ one: "%{chatSettingsLink} have been set to retain channel messages for %{count} day."
+ other: "%{chatSettingsLink} have been set to retain channel messages for %{count} days."
flags:
off_topic: "This message is not relevant to the current discussion as defined by the channel title, and should probably be moved elsewhere."
diff --git a/plugins/chat/test/javascripts/components/chat-retention-reminder-test.gjs b/plugins/chat/test/javascripts/components/chat-retention-reminder-test.gjs
index ec845f28a37..8e079703341 100644
--- a/plugins/chat/test/javascripts/components/chat-retention-reminder-test.gjs
+++ b/plugins/chat/test/javascripts/components/chat-retention-reminder-test.gjs
@@ -18,11 +18,11 @@ module(
<template><ChatRetentionReminder @channel={{this.channel}} /></template>
);
- assert.dom(".chat-retention-reminder").includesText(
- i18n("chat.retention_reminders.long", {
- count: this.siteSettings.chat_channel_retention_days,
- })
- );
+ assert
+ .dom(".chat-retention-reminder")
+ .includesText(
+ `retain channel messages for ${this.siteSettings.chat_channel_retention_days} days`
+ );
});
test("@type=short", async function (assert) {
diff --git a/plugins/chat/test/javascripts/components/chat-retention-reminder-text-test.gjs b/plugins/chat/test/javascripts/components/chat-retention-reminder-text-test.gjs
index a7d49b720df..86cba8be750 100644
--- a/plugins/chat/test/javascripts/components/chat-retention-reminder-text-test.gjs
+++ b/plugins/chat/test/javascripts/components/chat-retention-reminder-text-test.gjs
@@ -23,7 +23,7 @@ module(
assert
.dom(".chat-retention-reminder-text")
- .includesText(i18n("chat.retention_reminders.indefinitely_long"));
+ .includesText("retain channel messages indefinitely");
await render(
<template>
@@ -48,7 +48,7 @@ module(
assert
.dom(".chat-retention-reminder-text")
- .includesText(i18n("chat.retention_reminders.long", { count: 10 }));
+ .includesText("retain channel messages for 10 days");
await render(
<template>
@@ -73,7 +73,7 @@ module(
assert
.dom(".chat-retention-reminder-text")
- .includesText(i18n("chat.retention_reminders.long", { count: 10 }));
+ .includesText("retain channel messages for 10 days");
await render(
<template>
@@ -85,5 +85,35 @@ module(
.dom(".chat-retention-reminder-text")
.includesText(i18n("chat.retention_reminders.short", { count: 10 }));
});
+
+ test("links to chat settings for admins", async function (assert) {
+ this.currentUser.admin = true;
+ this.channel = new ChatFabricators(getOwner(this)).channel();
+ this.siteSettings.chat_channel_retention_days = 0;
+
+ await render(
+ <template>
+ <ChatRetentionReminderText @channel={{this.channel}} />
+ </template>
+ );
+
+ assert
+ .dom(".chat-retention-reminder-text a")
+ .hasAttribute("href", "/admin/site_settings/category/chat");
+ });
+
+ test("does not link to chat settings for non-admins", async function (assert) {
+ this.currentUser.admin = false;
+ this.channel = new ChatFabricators(getOwner(this)).channel();
+ this.siteSettings.chat_channel_retention_days = 0;
+
+ await render(
+ <template>
+ <ChatRetentionReminderText @channel={{this.channel}} />
+ </template>
+ );
+
+ assert.dom(".chat-retention-reminder-text a").doesNotExist();
+ });
}
);