Skip to content

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

UX: fix various issues caused by disabling emoji (#44309)

Krisa08d9a5fac64
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index f1dba55b050..1650d9d445f 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -3028,7 +3028,7 @@ en:
hide_forever: "no thanks"
hidden_for_session: "OK, we'll ask you tomorrow. You can always use 'Log In' to create an account, too."
intro: "Hello! Looks like you’re enjoying the discussion, but you haven’t signed up for an account yet."
- value_prop: "Tired of scrolling through the same posts? When you create an account you’ll always come back to where you left off. With an account you can also be notified of new replies, save bookmarks, and use likes to thank others. We can all work together to make this community great. :heart:"
+ value_prop: "Tired of scrolling through the same posts? When you create an account you’ll always come back to where you left off. With an account you can also be notified of new replies, save bookmarks, and use likes to thank others. We can all work together to make this community great."
offline_indicator:
no_internet: "No internet connection."
diff --git a/frontend/discourse/admin/components/upsert-category/general.gjs b/frontend/discourse/admin/components/upsert-category/general.gjs
index dfab7bcf52c..f122a4bc8b7 100644
--- a/frontend/discourse/admin/components/upsert-category/general.gjs
+++ b/frontend/discourse/admin/components/upsert-category/general.gjs
@@ -15,6 +15,7 @@ import lazyHash from "discourse/helpers/lazy-hash";
import { ajax } from "discourse/lib/ajax";
import { popupAjaxError } from "discourse/lib/ajax-error";
import { uniqueItemsFromArray } from "discourse/lib/array-tools";
+import categoryStyleType from "discourse/lib/category-style-type";
import {
availableCategoryType,
unavailableBadgeText,
@@ -745,7 +746,10 @@ export default class UpsertCategoryGeneral extends Component {
>
<styleField.Control>
<@form.ConditionalContent
- @activeName={{or styleField.value @category.styleType "square"}}
+ @activeName={{or
+ (categoryStyleType (or styleField.value @category.styleType))
+ "square"
+ }}
@onChange={{this.onStyleTypeChange}}
as |cc|
>
@@ -753,9 +757,11 @@ export default class UpsertCategoryGeneral extends Component {
<Condition @name="icon">
{{i18n "category.styles.icon"}}
</Condition>
- <Condition @name="emoji">
- {{i18n "category.styles.emoji"}}
- </Condition>
+ {{#if this.siteSettings.enable_emoji}}
+ <Condition @name="emoji">
+ {{i18n "category.styles.emoji"}}
+ </Condition>
+ {{/if}}
<Condition @name="square">
{{i18n "category.styles.square"}}
</Condition>
diff --git a/frontend/discourse/app/components/category-card-contents.gjs b/frontend/discourse/app/components/category-card-contents.gjs
index 942ba408545..69a02bd12b0 100644
--- a/frontend/discourse/app/components/category-card-contents.gjs
+++ b/frontend/discourse/app/components/category-card-contents.gjs
@@ -11,6 +11,7 @@ import FeaturedTopic from "discourse/components/topic-list/featured-topic";
import categoryVariables from "discourse/helpers/category-variables";
import { ajax } from "discourse/lib/ajax";
import { popupAjaxError } from "discourse/lib/ajax-error";
+import categoryStyleType from "discourse/lib/category-style-type";
import { number } from "discourse/lib/formatter";
import { wantsNewWindow } from "discourse/lib/intercept-click";
import { applyValueTransformer } from "discourse/lib/transformer";
@@ -21,8 +22,8 @@ import Topic from "discourse/models/topic";
import { and, eq, or } from "discourse/truth-helpers";
import DButton from "discourse/ui-kit/d-button";
import DSkeleton from "discourse/ui-kit/d-skeleton";
+import dEmoji from "discourse/ui-kit/helpers/d-emoji";
import dIcon from "discourse/ui-kit/helpers/d-icon";
-import dReplaceEmoji from "discourse/ui-kit/helpers/d-replace-emoji";
import { i18n } from "discourse-i18n";
const CATEGORY_HASHTAG_SELECTOR =
@@ -32,17 +33,21 @@ const LATEST_TOPICS_CACHE_MS = 5 * 60 * 1000; // 5 minutes
const CategoryNameLink = <template>
<a class="category-card__link" href={{@category.url}} ...attributes>
- <span
- class="category-card__style
- {{concat '--style-' (or @category.style_type 'square')}}"
- style={{categoryVariables @category}}
- >
- {{#if (and (eq @category.style_type "icon") @category.icon)}}
- {{dIcon @category.icon}}
- {{else if (and (eq @category.style_type "emoji") @category.emoji)}}
- {{dReplaceEmoji (concat ":" @category.emoji ":")}}
- {{/if}}
- </span>
+ {{#let
+ (or (categoryStyleType @category.style_type) "square")
+ as |styleType|
+ }}
+ <span
+ class="category-card__style {{concat '--style-' styleType}}"
+ style={{categoryVariables @category}}
+ >
+ {{#if (and (eq styleType "icon") @category.icon)}}
+ {{dIcon @category.icon}}
+ {{else if (and (eq styleType "emoji") @category.emoji)}}
+ {{dEmoji @category.emoji}}
+ {{/if}}
+ </span>
+ {{/let}}
<span class="category-card__name">{{@category.name}}</span>
{{yield}}
</a>
diff --git a/frontend/discourse/app/lib/category-style-type.js b/frontend/discourse/app/lib/category-style-type.js
new file mode 100644
index 00000000000..7a9d5aa5124
--- /dev/null
+++ b/frontend/discourse/app/lib/category-style-type.js
@@ -0,0 +1,17 @@
+import { helperContext } from "discourse/lib/helpers";
+
+/**
+ * Resolves the style a category should render with. Emoji-styled categories
+ * fall back to the default square while emoji are disabled, keeping the saved
+ * emoji for when they're re-enabled.
+ *
+ * @param {string} [styleType] the category's saved style type
+ * @returns {string|undefined}
+ */
+export default function categoryStyleType(styleType) {
+ if (styleType === "emoji" && !helperContext().siteSettings.enable_emoji) {
+ return "square";
+ }
+
+ return styleType;
+}
diff --git a/frontend/discourse/app/lib/hashtag-types/category.js b/frontend/discourse/app/lib/hashtag-types/category.js
index 15eaa17d09b..ad8260e3b9f 100644
--- a/frontend/discourse/app/lib/hashtag-types/category.js
+++ b/frontend/discourse/app/lib/hashtag-types/category.js
@@ -1,6 +1,7 @@
import { service } from "@ember/service";
+import categoryStyleType from "discourse/lib/category-style-type";
import { iconHTML } from "discourse/lib/icon-library";
-import dReplaceEmoji from "discourse/ui-kit/helpers/d-replace-emoji";
+import dEmoji from "discourse/ui-kit/helpers/d-emoji";
import HashtagTypeBase from "./base";
export default class CategoryHashtagType extends HashtagTypeBase {
@@ -43,14 +44,15 @@ export default class CategoryHashtagType extends HashtagTypeBase {
}
}
+ const styleType = categoryStyleType(categoryOrHashtag.style_type);
let style;
- if (categoryOrHashtag.style_type === "square") {
+ if (styleType === "square") {
if (parentColor) {
style = `background: linear-gradient(-90deg, #${color} 50%, #${parentColor} 50%);`;
} else {
style = `background-color: #${color};`;
}
- } else if (categoryOrHashtag.style_type === "icon") {
+ } else if (styleType === "icon") {
style = `color: #${color};`;
} else {
return [];
@@ -61,17 +63,18 @@ export default class CategoryHashtagType extends HashtagTypeBase {
generateIconHTML(hashtag) {
hashtag.preloaded ? this.onLoad(hashtag) : this.load(hashtag.id);
+ const styleType = categoryStyleType(hashtag.style_type);
let style = "";
- if (hashtag.style_type === "icon" && hashtag.icon) {
+ if (styleType === "icon" && hashtag.icon) {
style = iconHTML(hashtag.icon);
}
- if (hashtag.style_type === "emoji" && hashtag.emoji) {
- style = dReplaceEmoji(`:${hashtag.emoji}:`);
+ if (styleType === "emoji" && hashtag.emoji) {
+ style = dEmoji(hashtag.emoji);
}
const colorCssClass = `hashtag-color--${this.type}-${hashtag.id}`;
- return `<span class="hashtag-category-${hashtag.style_type} ${colorCssClass}">${style}</span>`;
+ return `<span class="hashtag-category-${styleType} ${colorCssClass}">${style}</span>`;
}
isLoaded(id) {
diff --git a/frontend/discourse/app/lib/sidebar/user/categories-section/category-section-link.js b/frontend/discourse/app/lib/sidebar/user/categories-section/category-section-link.js
index 6cb587df589..f5ab0e63f1b 100644
--- a/frontend/discourse/app/lib/sidebar/user/categories-section/category-section-link.js
+++ b/frontend/discourse/app/lib/sidebar/user/categories-section/category-section-link.js
@@ -1,5 +1,6 @@
import { tracked } from "@glimmer/tracking";
import { get, set } from "@ember/object";
+import categoryStyleType from "discourse/lib/category-style-type";
import { bind } from "discourse/lib/decorators";
import Category from "discourse/models/category";
import { i18n } from "discourse-i18n";
@@ -148,7 +149,7 @@ export default class CategorySectionLink {
return customPrefixType;
}
- return this.category.styleType;
+ return categoryStyleType(this.category.styleType);
}
get prefixValue() {
@@ -159,7 +160,7 @@ export default class CategorySectionLink {
return customPrefixValue;
}
- const styleType = this.category.styleType;
+ const styleType = categoryStyleType(this.category.styleType);
if (styleType === "icon") {
return this.category.icon;
diff --git a/frontend/discourse/app/ui-kit/helpers/d-category-link.js b/frontend/discourse/app/ui-kit/helpers/d-category-link.js
index fae27b2cf94..f4a271b3c54 100644
--- a/frontend/discourse/app/ui-kit/helpers/d-category-link.js
+++ b/frontend/discourse/app/ui-kit/helpers/d-category-link.js
@@ -1,13 +1,14 @@
import { get } from "@ember/object";
import { trustHTML } from "@ember/template";
import categoryVariables from "discourse/helpers/category-variables";
+import categoryStyleType from "discourse/lib/category-style-type";
import getURL from "discourse/lib/get-url";
import { helperContext } from "discourse/lib/helpers";
import { iconHTML } from "discourse/lib/icon-library";
import { applyValueTransformer } from "discourse/lib/transformer";
import { escapeExpression } from "discourse/lib/utilities";
import Category from "discourse/models/category";
-import dReplaceEmoji from "discourse/ui-kit/helpers/d-replace-emoji";
+import dEmoji from "discourse/ui-kit/helpers/d-emoji";
import { i18n } from "discourse-i18n";
let _renderer = defaultCategoryLinkRenderer;
@@ -51,7 +52,7 @@ export function categoryBadgeHTML(category, opts) {
}
if (!opts.styleType) {
- opts.styleType = category.style_type || "square";
+ opts.styleType = categoryStyleType(category.style_type) || "square";
if (opts.styleType === "icon") {
opts.icon = opts.icon || category.icon;
@@ -187,7 +188,7 @@ export function defaultCategoryLinkRenderer(category, opts) {
}
if (opts.styleType === "emoji" && opts.emoji) {
- html += dReplaceEmoji(`:${opts.emoji}:`);
+ html += dEmoji(opts.emoji) ?? "";
}
// not ideal as we have to call it manually and we pass a fake category object
diff --git a/frontend/discourse/app/ui-kit/helpers/d-emoji.js b/frontend/discourse/app/ui-kit/helpers/d-emoji.js
index dba0f716794..876c21d66d4 100644
--- a/frontend/discourse/app/ui-kit/helpers/d-emoji.js
+++ b/frontend/discourse/app/ui-kit/helpers/d-emoji.js
@@ -1,8 +1,15 @@
import { trustHTML } from "@ember/template";
+import { helperContext } from "discourse/lib/helpers";
import { emojiUnescape } from "discourse/lib/text";
import { escapeExpression } from "discourse/lib/utilities";
export default function dEmoji(code, options) {
+ // With emoji disabled the code would otherwise leak into the UI as literal
+ // `:code:` text.
+ if (!helperContext().siteSettings.enable_emoji) {
+ return;
+ }
+
const escaped = escapeExpression(`:${code}:`);
return trustHTML(emojiUnescape(escaped, options));
}
diff --git a/frontend/discourse/tests/acceptance/category-edit-test.js b/frontend/discourse/tests/acceptance/category-edit-test.js
index e61e898c94e..ca3da9d2e03 100644
--- a/frontend/discourse/tests/acceptance/category-edit-test.js
+++ b/frontend/discourse/tests/acceptance/category-edit-test.js
@@ -632,3 +632,26 @@ acceptance(
});
}
);
+
+acceptance("Category Edit - emoji disabled", function (needs) {
+ needs.user();
+ needs.settings({ enable_emoji: false });
+ needs.pretender((server, helper) => {
+ server.get("/c/bug/find_by_slug.json", () =>
+ helper.response(200, {
+ category: seededCategory({ style_type: "emoji", emoji: "wave" }),
+ })
+ );
+ });
+
+ test("hides the emoji style and shows emoji categories as square", async function (assert) {
+ await visit("/c/bug/edit/general");
+
+ assert
+ .dom(".form-kit__control-radio[value='emoji']")
+ .doesNotExist("emoji style isn't offered");
+ assert
+ .dom(".form-kit__control-radio[value='square']")
+ .isChecked("emoji category resolves to square");
+ });
+});
diff --git a/frontend/discourse/tests/integration/ui-kit/helpers/d-emoji-test.gjs b/frontend/discourse/tests/integration/ui-kit/helpers/d-emoji-test.gjs
index c942d11ded5..48aca209f07 100644
--- a/frontend/discourse/tests/integration/ui-kit/helpers/d-emoji-test.gjs
+++ b/frontend/discourse/tests/integration/ui-kit/helpers/d-emoji-test.gjs
@@ -18,4 +18,13 @@ module("Integration | ui-kit | Helper | dEmoji", function (hooks) {
assert.dom(`.emoji[title="${title}"]`).exists();
});
+
+ test("it renders nothing when emoji are disabled", async function (assert) {
+ this.siteSettings.enable_emoji = false;
+
+ await render(<template>{{dEmoji "tada"}}</template>);
+
+ assert.dom(".emoji").doesNotExist();
+ assert.dom().doesNotIncludeText(":tada:");
+ });
});
diff --git a/frontend/discourse/tests/unit/lib/category-badge-test.js b/frontend/discourse/tests/unit/lib/category-badge-test.js
index 83f44129e55..891765a41ca 100644
--- a/frontend/discourse/tests/unit/lib/category-badge-test.js
+++ b/frontend/discourse/tests/unit/lib/category-badge-test.js
@@ -140,6 +140,22 @@ module("Unit | Utility | category-badge", function (hooks) {
);
});
+ test("emoji style falls back to square when emoji are disabled", function (assert) {
+ const store = getOwner(this).lookup("service:store");
+ const category = store.createRecord("category", {
+ name: "hello",
+ id: 123,
+ style_type: "emoji",
+ emoji: "wave",
+ });
+ helperContext().siteSettings.enable_emoji = false;
+
+ const badge = categoryBadgeHTML(category);
+
+ assert.true(badge.includes("--style-square"), "has square style");
+ assert.false(badge.includes(":wave:"), "doesn't leak the emoji code");
+ });
+
test("category style with ancestors", function (assert) {
const store = getOwner(this).lookup("service:store");
diff --git a/plugins/chat/assets/javascripts/discourse/components/channel-icon/index.gjs b/plugins/chat/assets/javascripts/discourse/components/channel-icon/index.gjs
index b5c3b667cf5..ddadadeb10b 100644
--- a/plugins/chat/assets/javascripts/discourse/components/channel-icon/index.gjs
+++ b/plugins/chat/assets/javascripts/discourse/components/channel-icon/index.gjs
@@ -1,7 +1,7 @@
import Component from "@glimmer/component";
import { trustHTML } from "@ember/template";
+import dEmoji from "discourse/ui-kit/helpers/d-emoji";
import dIcon from "discourse/ui-kit/helpers/d-icon";
-import dReplaceEmoji from "discourse/ui-kit/helpers/d-replace-emoji";
import ChatUserAvatar from "discourse/plugins/chat/discourse/components/chat-user-avatar";
export default class ChatChannelIcon extends Component {
@@ -33,20 +33,20 @@ export default class ChatChannelIcon extends Component {
}
get categoryChannelIcon() {
- const { emoji } = this.args.channel;
- return emoji ? dReplaceEmoji(`:${emoji}:`) : dIcon("d-chat");
+ return this.channelEmoji || dIcon("d-chat");
}
- get channelEmojiCode() {
- return `:${this.args.channel.emoji}:`;
+ get channelEmoji() {
+ const { emoji } = this.args.channel;
+ return emoji && dEmoji(emoji);
}
<template>
{{#if @channel.isDirectMessageChannel}}
{{#if this.groupDirectMessage}}
- {{#if @channel.emoji}}
+ {{#if this.channelEmoji}}
<div class="chat-channel-icon --emoji">
- {{dReplaceEmoji this.channelEmojiCode}}
+ {{this.channelEmoji}}
</div>
{{else if this.groupIsDuoOnly}}
<div class="chat-channel-icon --avatar">
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-composer.gjs b/plugins/chat/assets/javascripts/discourse/components/chat-composer.gjs
index 3ef31ce4323..2b58e0f2962 100644
--- a/plugins/chat/assets/javascripts/discourse/components/chat-composer.gjs
+++ b/plugins/chat/assets/javascripts/discourse/components/chat-composer.gjs
@@ -311,6 +311,10 @@ export default class ChatComposer extends Component {
}
async reactingToLastMessage() {
+ if (!this.siteSettings.enable_emoji) {
+ return false;
+ }
+
// Check if the message is a reaction to the latest message in the channel.
const message = this.draft.message.trim();
let reactionCode = "";
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-message-actions-desktop.gjs b/plugins/chat/assets/javascripts/discourse/components/chat-message-actions-desktop.gjs
index b413f49cb97..6a2e95aac6d 100644
--- a/plugins/chat/assets/javascripts/discourse/components/chat-message-actions-desktop.gjs
+++ b/plugins/chat/assets/javascripts/discourse/components/chat-message-actions-desktop.gjs
@@ -114,7 +114,11 @@ export default class ChatMessageActionsDesktop extends Component {
}
get shouldRenderFavoriteReactions() {
- return this.size === FULL && this.message.channel?.isFollowing;
+ return (
+ this.size === FULL &&
+ this.message.channel?.isFollowing &&
+ this.messageInteractor.canReact
+ );
}
// A bookmark's reminder makes a useful name once one is set, but the button needs one
@@ -182,7 +186,7 @@ export default class ChatMessageActionsDesktop extends Component {
{{/each}}
{{/if}}
- {{#if this.messageInteractor.canInteractWithMessage}}
+ {{#if this.messageInteractor.canReact}}
<DButton
class="btn-flat react-btn"
@action={{this.openEmojiPicker}}
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-message.gjs b/plugins/chat/assets/javascripts/discourse/components/chat-message.gjs
index 5fa67fd6a37..3e5f99e8611 100644
--- a/plugins/chat/assets/javascripts/discourse/components/chat-message.gjs
+++ b/plugins/chat/assets/javascripts/discourse/components/chat-message.gjs
@@ -51,6 +51,7 @@ export const MESSAGE_CONTEXT_THREAD = "thread";
export default class ChatMessage extends Component {
@service site;
+ @service siteSettings;
@service currentUser;
@service chat;
@service chatApi;
@@ -141,6 +142,10 @@ export default class ChatMessage extends Component {
);
}
+ get shouldRenderReactions() {
+ return this.siteSettings.enable_emoji && this.args.message.reactions.length;
+ }
+
get shouldRenderOpenEmojiPickerButton() {
return (
this.args.interactive !== false &&
@@ -757,7 +762,7 @@ export default class ChatMessage extends Component {
@edited={{@message.edited}}
@uploads={{@message.uploads}}
>
- {{#if @message.reactions.length}}
+ {{#if this.shouldRenderReactions}}
<div class="chat-message-reaction-list">
{{#each @message.reactions as |reaction|}}
<ChatMessageReaction
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat/channel/empty-state.gjs b/plugins/chat/assets/javascripts/discourse/components/chat/channel/empty-state.gjs
index 65a453110b3..18554705cc7 100644
--- a/plugins/chat/assets/javascripts/discourse/components/chat/channel/empty-state.gjs
+++ b/plugins/chat/assets/javascripts/discourse/components/chat/channel/empty-state.gjs
@@ -7,8 +7,8 @@ import { trustHTML } from "@ember/template";
import DEmptyState from "discourse/ui-kit/d-empty-state";
import dAvatar from "discourse/ui-kit/helpers/d-avatar";
import dConcatClass from "discourse/ui-kit/helpers/d-concat-class";
+import dEmoji from "discourse/ui-kit/helpers/d-emoji";
import dIcon from "discourse/ui-kit/helpers/d-icon";
-import dReplaceEmoji from "discourse/ui-kit/helpers/d-replace-emoji";
import { i18n } from "discourse-i18n";
const MAX_AVATARS = 5;
@@ -41,7 +41,7 @@ export default class ChatChannelEmptyState extends Component {
return dAvatar(chatable.users[0], { imageSize: "extra_large" });
}
- const icon = emoji ? dReplaceEmoji(`:${emoji}:`) : dIcon("d-chat");
+ const icon = (emoji && dEmoji(emoji)) || dIcon("d-chat");
if (!chatable?.color) {
return icon;
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat/modal/create-channel.gjs b/plugins/chat/assets/javascripts/discourse/components/chat/modal/create-channel.gjs
index 89f05394339..e731694d7cf 100644
--- a/plugins/chat/assets/javascripts/discourse/components/chat/modal/create-channel.gjs
+++ b/plugins/chat/assets/javascripts/discourse/components/chat/modal/create-channel.gjs
@@ -343,21 +343,23 @@ export default class ChatModalCreateChannel extends Component {
</field.Control>
</form.Field>
- <form.Field
- @name="emoji"
- @title={{i18n "chat.create_channel.emoji.label"}}
- @type="emoji"
- as |field|
- >
- <field.Control @context="channel-emoji" />
-
- <DButton
- class="btn-flat edit-channel-clear-emoji"
- @action={{fn field.set null}}
- @disabled={{not field.value}}
- @label="chat.create_channel.emoji.reset"
- />
- </form.Field>
+ {{#if this.siteSettings.enable_emoji}}
+ <form.Field
+ @name="emoji"
+ @title={{i18n "chat.create_channel.emoji.label"}}
+ @type="emoji"
+ as |field|
+ >
+ <field.Control @context="channel-emoji" />
+
+ <DButton
+ class="btn-flat edit-channel-clear-emoji"
+ @action={{fn field.set null}}
+ @disabled={{not field.value}}
+ @label="chat.create_channel.emoji.reset"
+ />
+ </form.Field>
+ {{/if}}
{{#if this.autoJoinAvailable}}
<form.Field
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat/modal/edit-channel-name.gjs b/plugins/chat/assets/javascripts/discourse/components/chat/modal/edit-channel-name.gjs
index be693dd8407..33d2b4f4768 100644
--- a/plugins/chat/assets/javascripts/discourse/components/chat/modal/edit-channel-name.gjs
+++ b/plugins/chat/assets/javascripts/discourse/components/chat/modal/edit-channel-name.gjs
@@ -161,29 +161,31 @@ export default class ChatModalEditChannelName extends Component {
{{on "input" this.onChangeChatChannelSlug}}
/>
</div>
- <div class="edit-channel-control">
- <label class="edit-channel-label" for="channel-emoji">
- {{i18n "chat.channel_edit_name_slug_modal.emoji"}}
- </label>
-
- <EmojiPicker
- @btnClass="btn-default btn-emoji"
- @context="channel-emoji"
- @didSelectEmoji={{this.emojiSelected}}
- @emoji={{this.editedEmoji}}
- @inline={{true}}
- @modalForMobile={{false}}
- @showCaret={{true}}
- />
+ {{#if this.siteSettings.enable_emoji}}
+ <div class="edit-channel-control">
+ <label class="edit-channel-label" for="channel-emoji">
+ {{i18n "chat.channel_edit_name_slug_modal.emoji"}}
+ </label>
+
+ <EmojiPicker
+ @btnClass="btn-default btn-emoji"
+ @context="channel-emoji"
+ @didSelectEmoji={{this.emojiSelected}}
+ @emoji={{this.editedEmoji}}
+ @inline={{true}}
+ @modalForMobile={{false}}
+ @showCaret={{true}}
+ />
- <DButton
- class="btn-flat edit-channel-clear-emoji"
- @action={{this.resetEmoji}}
- @disabled={{not this.editedEmoji}}
- @label="chat.channel_edit_name_slug_modal.reset_emoji"
- />
+ <DButton
+ class="btn-flat edit-channel-clear-emoji"
+ @action={{this.resetEmoji}}
+ @disabled={{not this.editedEmoji}}
+ @label="chat.channel_edit_name_slug_modal.reset_emoji"
+ />
- </div>
+ </div>
+ {{/if}}
</:body>
<:footer>
<DButton
diff --git a/plugins/chat/assets/javascripts/discourse/components/upsert-category/chat.gjs b/plugins/chat/assets/javascripts/discourse/components/upsert-category/chat.gjs
index a92b507f599..f5f855ba915 100644
--- a/plugins/chat/assets/javascripts/discourse/components/upsert-category/chat.gjs
+++ b/plugins/chat/assets/javascripts/discourse/components/upsert-category/chat.gjs
@@ -14,8 +14,8 @@ import DConditionalLoadingSpinner from "discourse/ui-kit/d-conditional-loading-s
import DEmptyState from "discourse/ui-kit/d-empty-state";
import DToggleSwitch from "discourse/ui-kit/d-toggle-switch";
import dCategoryBadge from "discourse/ui-kit/helpers/d-category-badge";
+import dEmoji from "discourse/ui-kit/helpers/d-emoji";
import dIcon from "discourse/ui-kit/helpers/d-icon";
-import dReplaceEmoji from "discourse/ui-kit/helpers/d-replace-emoji";
import { i18n } from "discourse-i18n";
function channelColorStyle(channel) {
@@ -23,7 +23,7 @@ function channelColorStyle(channel) {
}
function channelIcon(channel) {
- return channel.emoji ? dReplaceEmoji(`:${channel.emoji}:`) : dIcon("d-chat");
+ return (channel.emoji && dEmoji(channel.emoji)) || dIcon("d-chat");
}
function isSubcategoryChannel(channel, categoryId) {
diff --git a/plugins/chat/assets/javascripts/discourse/initializers/chat-sidebar.js b/plugins/chat/assets/javascripts/discourse/initializers/chat-sidebar.js
index 98114d5f1af..f0a8cd9b519 100644
--- a/plugins/chat/assets/javascripts/discourse/initializers/chat-sidebar.js
+++ b/plugins/chat/assets/javascripts/discourse/initializers/chat-sidebar.js
@@ -7,6 +7,7 @@ import { decorateUsername } from "discourse/helpers/decorate-username-selector";
import noop from "discourse/helpers/noop";
import { avatarUrl } from "discourse/lib/avatar-utils";
import { bind } from "discourse/lib/decorators";
+import { helperContext } from "discourse/lib/helpers";
import { withPluginApi } from "discourse/lib/plugin-api";
import { emojiUnescape } from "discourse/lib/text";
import { escapeExpression } from "discourse/lib/utilities";
@@ -134,7 +135,7 @@ function createChannelLink(BaseCustomSidebarSectionLink, options = {}) {
get prefixType() {
if (this.isDM) {
- if (this.channel.emoji) {
+ if (displayedEmoji(this.channel)) {
return "emoji";
} else if (this.channel.chatable.group) {
if (this.channel.chatable.users.length === 1) {
@@ -146,14 +147,14 @@ function createChannelLink(BaseCustomSidebarSectionLink, options = {}) {
return "image";
}
} else {
- return this.channel.emoji ? "emoji" : "icon";
+ return displayedEmoji(this.channel) ? "emoji" : "icon";
}
}
get prefixValue() {
if (this.isDM) {
- if (this.channel.emoji) {
- return this.channel.emoji;
+ if (displayedEmoji(this.channel)) {
+ return displayedEmoji(this.channel);
} else if (this.channel.chatable.group) {
if (this.channel.chatable.users.length === 1) {
return avatarUrl(
@@ -170,7 +171,7 @@ function createChannelLink(BaseCustomSidebarSectionLink, options = {}) {
);
}
} else {
- return this.channel.emoji ?? "d-chat";
+ return displayedEmoji(this.channel) ?? "d-chat";
}
}
@@ -278,6 +279,12 @@ function channelListOptionsAction(section, menuService) {
};
}
+// Emoji are skipped while disabled so the prefix falls back to the channel's
+// icon, avatar, or member count instead of rendering the raw `:code:`.
+function displayedEmoji(channel) {
+ return helperContext().siteSettings.enable_emoji ? channel.emoji : null;
+}
+
export default {
name: "chat-sidebar",
initialize(container) {
@@ -621,11 +628,11 @@ export default {
}
get prefixType() {
- return this.channel.emoji ? "emoji" : "icon";
+ return displayedEmoji(this.channel) ? "emoji" : "icon";
}
get prefixValue() {
- return this.channel.emoji ?? "d-chat";
+ return displayedEmoji(this.channel) ?? "d-chat";
}
get prefixColor() {
@@ -914,7 +921,7 @@ export default {
}
get prefixType() {
- if (this.channel.emoji) {
+ if (displayedEmoji(this.channel)) {
return "emoji";
} else if (this.channel.chatable.group) {
if (this.channel.chatable.users.length === 1) {
@@ -928,8 +935,8 @@ export default {
}
get prefixValue() {
- if (this.channel.emoji) {
- return this.channel.emoji;
+ if (displayedEmoji(this.channel)) {
+ return displayedEmoji(this.channel);
} else if (this.channel.chatable.group) {
if (this.channel.chatable.users.length === 1) {
return avatarUrl(
diff --git a/plugins/chat/assets/javascripts/discourse/lib/chat-message-interactor.js b/plugins/chat/assets/javascripts/discourse/lib/chat-message-interactor.js
index 2c598b157e4..25ea220762c 100644
--- a/plugins/chat/assets/javascripts/discourse/lib/chat-message-interactor.js
+++ b/plugins/chat/assets/javascripts/discourse/lib/chat-message-interactor.js
@@ -123,7 +123,8 @@ export default class ChatMessageInteractor {
}
get canReact() {
- return this.canInteractWithMessage;
+ // Reactions are emoji, so there's nothing to react with while they're disabled.
+ return this.canInteractWithMessage && this.siteSettings.enable_emoji;
}
get canFlagMessage() {
diff --git a/plugins/chat/assets/javascripts/discourse/lib/hashtag-types/channel.js b/plugins/chat/assets/javascripts/discourse/lib/hashtag-types/channel.js
index a78d3c545a9..5283bfdb85d 100644
--- a/plugins/chat/assets/javascripts/discourse/lib/hashtag-types/channel.js
+++ b/plugins/chat/assets/javascripts/discourse/lib/hashtag-types/channel.js
@@ -1,7 +1,7 @@
import { service } from "@ember/service";
import HashtagTypeBase from "discourse/lib/hashtag-types/base";
import { iconHTML } from "discourse/lib/icon-library";
-import dReplaceEmoji from "discourse/ui-kit/helpers/d-replace-emoji";
+import dEmoji from "discourse/ui-kit/helpers/d-emoji";
export default class ChannelHashtagType extends HashtagTypeBase {
@service chatChannelsManager;
@@ -32,8 +32,10 @@ export default class ChannelHashtagType extends HashtagTypeBase {
generateIconHTML(hashtag) {
hashtag.colors ? this.onLoad(hashtag) : this.load(hashtag.id);
- if (hashtag.emoji) {
- return String(dReplaceEmoji(`:${hashtag.emoji}:`));
+ const emoji = hashtag.emoji && dEmoji(hashtag.emoji);
+
+ if (emoji) {
+ return String(emoji);
} else {
return iconHTML(hashtag.icon, {
class: `hashtag-color--${this.type}-${hashtag.id}`,
diff --git a/plugins/chat/assets/javascripts/discourse/templates/preferences/chat.gjs b/plugins/chat/assets/javascripts/discourse/templates/preferences/chat.gjs
index ef2fb8a3963..f7541de4fa1 100644
--- a/plugins/chat/assets/javascripts/discourse/templates/preferences/chat.gjs
+++ b/plugins/chat/assets/javascripts/discourse/templates/preferences/chat.gjs
@@ -2,6 +2,7 @@ import Component from "@glimmer/component";
import { tracked } from "@glimmer/tracking";
import { fn } from "@ember/helper";
import { action } from "@ember/object";
+import { service } from "@ember/service";
import EmojiPicker from "discourse/components/emoji-picker";
import Form from "discourse/components/form";
import { popupAjaxError } from "discourse/lib/ajax-error";
@@ -19,6 +20,8 @@ import {
} from "discourse/plugins/chat/discourse/lib/chat-constants";
export default class Chat extends Component {
+ @service siteSettings;
+
@tracked saved = false;
get chatQuickReactionTypes() {
@@ -119,41 +122,43 @@ export default class Chat extends Component {
</form.Field>
<form.Section @title={{i18n "chat.personalization_title"}}>
- <form.Field
- @format="large"
- @name="chat_quick_reaction_type"
- @title={{i18n "chat.quick_reaction_type.title"}}
- @type="radio-group"
- as |field|
- >
- <field.Control as |radioGroup|>
- {{#each this.chatQuickReactionTypes as |option|}}
- <radioGroup.Radio @value={{option.value}}>
- {{option.label}}
- </radioGroup.Radio>
- {{/each}}
- </field.Control>
- </form.Field>
-
- {{#if (eq data.chat_quick_reaction_type "custom")}}
+ {{#if this.siteSettings.enable_emoji}}
<form.Field
@format="large"
- @name="chat_quick_reactions_custom"
- @title={{i18n "chat.quick_reaction_type.options.custom"}}
- @type="custom"
+ @name="chat_quick_reaction_type"
+ @title={{i18n "chat.quick_reaction_type.title"}}
+ @type="radio-group"
as |field|
>
- <field.Control>
- {{#each data.chat_quick_reactions_custom as |emoji index|}}
- <EmojiPicker
- @btnClass="btn-default"
- @context="chat_preferences"
- @didSelectEmoji={{fn this.handleEmojiSet index field}}
- @emoji={{emoji}}
- />
+ <field.Control as |radioGroup|>
+ {{#each this.chatQuickReactionTypes as |option|}}
+ <radioGroup.Radio @value={{option.value}}>
+ {{option.label}}
+ </radioGroup.Radio>
{{/each}}
</field.Control>
</form.Field>
+
+ {{#if (eq data.chat_quick_reaction_type "custom")}}
+ <form.Field
+ @format="large"
+ @name="chat_quick_reactions_custom"
+ @title={{i18n "chat.quick_reaction_type.options.custom"}}
+ @type="custom"
+ as |field|
+ >
+ <field.Control>
+ {{#each data.chat_quick_reactions_custom as |emoji index|}}
+ <EmojiPicker
+ @btnClass="btn-default"
+ @context="chat_preferences"
+ @didSelectEmoji={{fn this.handleEmojiSet index field}}
+ @emoji={{emoji}}
+ />
+ {{/each}}
+ </field.Control>
+ </form.Field>
+ {{/if}}
{{/if}}
<form.Field
@format="large"
diff --git a/plugins/chat/spec/system/react_to_message_spec.rb b/plugins/chat/spec/system/react_to_message_spec.rb
index 456eba1a228..c55d85027d6 100644
--- a/plugins/chat/spec/system/react_to_message_spec.rb
+++ b/plugins/chat/spec/system/react_to_message_spec.rb
@@ -48,6 +48,29 @@ RSpec.describe "React to message" do
end
end
+ context "when emojis are disabled" do
+ before do
+ SiteSetting.enable_emoji = false
+ Chat::MessageReactor.new(other_user, category_channel_1).react!(
+ message_id: message_1.id,
+ react_action: :add,
+ emoji: "woman_detective",
+ )
+ end
+
+ it "hides existing reactions and the ways to add one" do
+ sign_in(current_user)
+ chat.visit_channel(category_channel_1)
+
+ expect(channel).to have_no_reactions(message_1)
+
+ message = channel.hover_message(message_1)
+ expect(message).to have_css(".chat-message-actions")
+ expect(message).to have_no_css(".chat-message-actions .react-btn")
+ expect(message).to have_no_css(".chat-message-actions .chat-message-reaction")
+ end
+ end
+
context "when current user reacts" do
let!(:reaction_1) do
Chat::MessageReactor.new(other_user, category_channel_1).react!(
diff --git a/plugins/chat/spec/system/sidebar_navigation_menu_spec.rb b/plugins/chat/spec/system/sidebar_navigation_menu_spec.rb
index fc60b925780..2869c5f1da2 100644
--- a/plugins/chat/spec/system/sidebar_navigation_menu_spec.rb
+++ b/plugins/chat/spec/system/sidebar_navigation_menu_spec.rb
@@ -37,6 +37,24 @@ RSpec.describe "Sidebar navigation menu" do
)
end
+ context "when the channel has an emoji and emoji are disabled" do
+ before do
+ channel_1.update!(emoji: "spiral_calendar")
+ SiteSetting.enable_emoji = false
+ end
+
+ it "falls back to the hash icon prefix" do
+ visit("/")
+
+ link = ".sidebar-section-link[data-link-name='#{channel_1.slug}']"
+ expect(sidebar_page.channels_section).to have_css(
+ "#{link} .sidebar-section-link-prefix svg.prefix-icon.d-icon-d-chat",
+ )
+ expect(sidebar_page.channels_section).to have_no_css("#{link} .prefix-emoji")
+ expect(sidebar_page.channels_section).to have_no_content(":spiral_calendar:")
+ end
+ end
+
it "channel link has the correct href" do
visit("/")
diff --git a/plugins/discourse-reactions/assets/javascripts/discourse/components/discourse-reactions-actions.gjs b/plugins/discourse-reactions/assets/javascripts/discourse/components/discourse-reactions-actions.gjs
index 52893a032ee..d49ace46847 100644
--- a/plugins/discourse-reactions/assets/javascripts/discourse/components/discourse-reactions-actions.gjs
+++ b/plugins/discourse-reactions/assets/javascripts/discourse/components/discourse-reactions-actions.gjs
@@ -211,7 +211,7 @@ export default class DiscourseReactionsActions extends Component {
}
get showReactionsPicker() {
- if (!this.reactionsPickerExpanded) {
+ if (!this.reactionsPickerExpanded || !this.siteSettings.enable_emoji) {
return false;
}
diff --git a/plugins/discourse-reactions/assets/javascripts/discourse/components/discourse-reactions-counter.gjs b/plugins/discourse-reactions/assets/javascripts/discourse/components/discourse-reactions-counter.gjs
index 40669c12fe8..ada23792ffb 100644
--- a/plugins/discourse-reactions/assets/javascripts/discourse/components/discourse-reactions-counter.gjs
+++ b/plugins/discourse-reactions/assets/javascripts/discourse/components/discourse-reactions-counter.gjs
@@ -30,9 +30,9 @@ export default class DiscourseReactionsCounter extends Component {
const { reactions } = this.args.post;
if (
- reactions &&
- reactions.length === 1 &&
- reactions[0].id === mainReaction
+ reactions?.length &&
+ (!this.siteSettings.enable_emoji ||
+ (reactions.length === 1 && reactions[0].id === mainReaction))
) {
classes.push("only-like");
}
diff --git a/plugins/discourse-reactions/assets/javascripts/discourse/components/discourse-reactions-list.gjs b/plugins/discourse-reactions/assets/javascripts/discourse/components/discourse-reactions-list.gjs
index d65a9fee7c5..3d2a62472ae 100644
--- a/plugins/discourse-reactions/assets/javascripts/discourse/components/discourse-reactions-list.gjs
+++ b/plugins/discourse-reactions/assets/javascripts/discourse/components/discourse-reactions-list.gjs
@@ -1,15 +1,38 @@
+import Component from "@glimmer/component";
+import { service } from "@ember/service";
import DiscourseReactionsListEmoji from "./discourse-reactions-list-emoji";
-const DiscourseReactionsList = <template>
- <span class="discourse-reactions-list" ...attributes>
- {{#if @post.reaction_users_count}}
- <span class="reactions">
- {{#each @post.reactions as |reaction|}}
- <DiscourseReactionsListEmoji @post={{@post}} @reaction={{reaction}} />
- {{/each}}
- </span>
- {{/if}}
- </span>
-</template>;
-
-export default DiscourseReactionsList;
+export default class DiscourseReactionsList extends Component {
+ @service siteSettings;
+
+ get reactions() {
+ const { reactions } = this.args.post;
+
+ // Every reaction renders as the like icon without emoji, so show it once.
+ if (!this.siteSettings.enable_emoji && reactions?.length) {
+ return [
+ {
+ id: this.siteSettings.discourse_reactions_reaction_for_like,
+ count: this.args.post.reaction_users_count,
+ },
+ ];
+ }
+
+ return reactions;
+ }
+
+ <template>
+ <span class="discourse-reactions-list" ...attributes>
+ {{#if @post.reaction_users_count}}
+ <span class="reactions">
+ {{#each this.reactions as |reaction|}}
+ <DiscourseReactionsListEmoji
+ @post={{@post}}
+ @reaction={{reaction}}
+ />
+ {{/each}}
+ </span>
+ {{/if}}
+ </span>
+ </template>
+}
diff --git a/plugins/discourse-reactions/assets/javascripts/discourse/components/discourse-reactions-reaction-button.gjs b/plugins/discourse-reactions/assets/javascripts/discourse/components/discourse-reactions-reaction-button.gjs
index 075ce332b0f..de1bef57ecd 100644
--- a/plugins/discourse-reactions/assets/javascripts/discourse/components/discourse-reactions-reaction-button.gjs
+++ b/plugins/discourse-reactions/assets/javascripts/discourse/components/discourse-reactions-reaction-button.gjs
@@ -40,6 +40,14 @@ export default class ReactionsReactionButton extends Component {
return icon;
}
+ // Without emoji rendering, any reaction is shown as a like.
+ get showLikedIcon() {
+ return (
+ this.args.post.current_user_used_main_reaction ||
+ (this.args.post.current_user_reaction && !this.siteSettings.enable_emoji)
+ );
+ }
+
get title() {
if (!this.currentUser) {
return i18n("discourse_reactions.main_reaction.unauthenticated");
@@ -154,7 +162,7 @@ export default class ReactionsReactionButton extends Component {
{{on "pointerover" this.pointerOver}}
{{on "pointerout" this.pointerOut}}
>
- {{#if @post.current_user_used_main_reaction}}
+ {{#if this.showLikedIcon}}
<DButton
class="btn-toggle-reaction-like btn-flat btn-icon no-text reaction-button"
@icon={{this.likedIcon}}
diff --git a/plugins/discourse-reactions/assets/javascripts/discourse/components/discourse-reactions-users-menu.gjs b/plugins/discourse-reactions/assets/javascripts/discourse/components/discourse-reactions-users-menu.gjs
index f0d826bc130..10584674ccb 100644
--- a/plugins/discourse-reactions/assets/javascripts/discourse/components/discourse-reactions-users-menu.gjs
+++ b/plugins/discourse-reactions/assets/javascripts/discourse/components/discourse-reactions-users-menu.gjs
@@ -14,6 +14,7 @@ import CustomReaction from "../models/discourse-reactions-custom-reaction";
export default class DiscourseReactionsUsersMenu extends Component {
@service router;
+ @service siteSettings;
@tracked activeFilter = null;
@@ -85,7 +86,9 @@ export default class DiscourseReactionsUsersMenu extends Component {
}
get showFilters() {
- return this.reactions.length > 1;
+ // Every reaction renders as the like icon without emoji, so per-reaction
+ // filters would be indistinguishable.
+ return this.siteSettings.enable_emoji && this.reactions.length > 1;
}
get titleText() {
diff --git a/plugins/discourse-reactions/assets/javascripts/discourse/helpers/discourse-reactions-emoji.js b/plugins/discourse-reactions/assets/javascripts/discourse/helpers/discourse-reactions-emoji.js
index 6c9aa2cae1d..c6084cf2859 100644
--- a/plugins/discourse-reactions/assets/javascripts/discourse/helpers/discourse-reactions-emoji.js
+++ b/plugins/discourse-reactions/assets/javascripts/discourse/helpers/discourse-reactions-emoji.js
@@ -7,12 +7,9 @@ export default class DiscourseReactionsEmoji extends Helper {
@service siteSettings;
compute([reaction], options) {
- // The like reaction must stay usable without emoji rendering, so fall
- // back to the configured like icon when emojis are disabled site-wide.
- if (
- !this.siteSettings.enable_emoji &&
- reaction === this.siteSettings.discourse_reactions_reaction_for_like
- ) {
+ // Without emoji rendering, reactions degrade to likes, so every reaction
+ // falls back to the configured like icon.
+ if (!this.siteSettings.enable_emoji) {
const icon = this.siteSettings.discourse_reactions_like_icon;
return dIcon(icon === "heart" ? "d-liked" : icon, {
...options,
diff --git a/plugins/discourse-reactions/spec/system/page_objects/post_reactions_button.rb b/plugins/discourse-reactions/spec/system/page_objects/post_reactions_button.rb
index 92cbf20df8e..4be2315d8f1 100644
--- a/plugins/discourse-reactions/spec/system/page_objects/post_reactions_button.rb
+++ b/plugins/discourse-reactions/spec/system/page_objects/post_reactions_button.rb
@@ -17,6 +17,18 @@ module PageObjects
context_component.find(post_reactions_actions_selector(post_id, position: "right")).hover
end
+ def click_like_button(post_id)
+ context_component.find(
+ "#{post_reactions_actions_selector(post_id, position: "right")} .discourse-reactions-reaction-button",
+ ).click
+ end
+
+ def has_no_expanded_reactions_picker?(post_id)
+ context_component.has_no_css?(
+ "#{post_reactions_actions_selector(post_id, position: "right")} .discourse-reactions-picker.is-expanded",
+ )
+ end
+
def has_expanded_reactions_picker?(post_id)
context_component.find(post_reactions_actions_selector(post_id, position: "right")).find(
".discourse-reactions-picker.is-expanded",
diff --git a/plugins/discourse-reactions/spec/system/page_objects/post_reactions_list.rb b/plugins/discourse-reactions/spec/system/page_objects/post_reactions_list.rb
index 1bc24a912ec..ea98fcdb36e 100644
--- a/plugins/discourse-reactions/spec/system/page_objects/post_reactions_list.rb
+++ b/plugins/discourse-reactions/spec/system/page_objects/post_reactions_list.rb
@@ -31,6 +31,10 @@ module PageObjects
component.has_css?("#{reaction_list_emoji_selector(reaction)} .d-icon-#{icon}")
end
+ def has_no_reaction?(reaction)
+ component.has_no_css?(reaction_list_emoji_selector(reaction))
+ end
+
def click_reaction(reaction)
component.find(reaction_list_emoji_selector(reaction)).click
end
diff --git a/plugins/discourse-reactions/spec/system/page_objects/post_reactions_popup.rb b/plugins/discourse-reactions/spec/system/page_objects/post_reactions_popup.rb
index eabd6b12d3b..a5e048955af 100644
--- a/plugins/discourse-reactions/spec/system/page_objects/post_reactions_popup.rb
+++ b/plugins/discourse-reactions/spec/system/page_objects/post_reactions_popup.rb
@@ -17,6 +17,10 @@ module PageObjects
find("#{SELECTOR} [data-reaction-filter=#{reaction}]").click
end
+ def has_no_filters?
+ page.has_no_css?("#{SELECTOR} [data-reaction-filter]")
+ end
+
def has_user?(username)
page.has_css?("#{SELECTOR} .users-popup__name[data-user-card=#{username}]")
end
diff --git a/plugins/discourse-reactions/spec/system/reactions_post_spec.rb b/plugins/discourse-reactions/spec/system/reactions_post_spec.rb
index 638e8d94c9e..f5d67ac27b1 100644
--- a/plugins/discourse-reactions/spec/system/reactions_post_spec.rb
+++ b/plugins/discourse-reactions/spec/system/reactions_post_spec.rb
@@ -70,22 +70,32 @@ describe "Reactions | Post reactions" do
expect(reactions_list).to have_reaction("laughing")
end
- it "lets the user like a post and see who liked it with emojis disabled" do
- SiteSetting.enable_emoji = false
- SiteSetting.discourse_reactions_enabled_reactions = "heart"
+ context "when emojis are disabled" do
+ fab!(:other_user, :user)
+ fab!(:laughing) { Fabricate(:reaction, post: post_2, reaction_value: "laughing") }
- visit post_2.url
- reactions_button.hover_like_button(post_2.id)
- expect(reactions_button).to have_reaction_icon("heart", "d-liked")
+ before do
+ SiteSetting.enable_emoji = false
+ Fabricate(:reaction_user, reaction: laughing, user: other_user, post: post_2)
+ end
- reactions_button.pick_reaction("heart")
- expect(reactions_list).to have_reaction_icon("heart", "d-liked")
+ it "degrades reactions to likes" do
+ visit post_2.url
+ expect(reactions_list).to have_reaction_icon("heart", "d-liked")
+ expect(reactions_list).to have_no_reaction("laughing")
+
+ reactions_button.hover_like_button(post_2.id)
+ expect(reactions_button).to have_no_expanded_reactions_picker(post_2.id)
- page.refresh
- expect(reactions_list).to have_reaction_icon("heart", "d-liked")
+ reactions_button.click_like_button(post_2.id)
+ page.refresh
+ expect(reactions_list).to have_reaction_icon("heart", "d-liked")
- reactions_list.click_counter
- expect(popup).to have_user_reaction_icon(current_user, "d-liked")
+ reactions_list.click_counter
+ expect(popup).to have_no_filters
+ expect(popup).to have_user_reaction_icon(current_user, "d-liked")
+ expect(popup).to have_user_reaction_icon(other_user, "d-liked")
+ end
end
it "does not show emoji_deny_list emojis for post reactions" do
diff --git a/plugins/discourse-reactions/test/javascripts/integration/helpers/discourse-reactions-emoji-test.gjs b/plugins/discourse-reactions/test/javascripts/integration/helpers/discourse-reactions-emoji-test.gjs
index 8e967329536..527ed9a946e 100644
--- a/plugins/discourse-reactions/test/javascripts/integration/helpers/discourse-reactions-emoji-test.gjs
+++ b/plugins/discourse-reactions/test/javascripts/integration/helpers/discourse-reactions-emoji-test.gjs
@@ -69,20 +69,13 @@ module("Integration | Helper | discourse-reactions-emoji", function (hooks) {
.hasAttribute("title", "heart", "the emoji keeps its tooltip");
});
- test("keeps other reactions as text when emojis are disabled", async function (assert) {
+ test("renders other reactions as the like icon when emojis are disabled", async function (assert) {
this.siteSettings.discourse_reactions_reaction_for_like = "+1";
+ this.siteSettings.discourse_reactions_like_icon = "star";
- await render(
- <template>
- <span>{{discourseReactionsEmoji "heart"}}</span>
- </template>
- );
+ await render(<template>{{discourseReactionsEmoji "laughing"}}</template>);
- assert
- .dom("span")
- .hasText(
- ":heart:",
- "the fallback only applies to the configured like reaction"
- );
+ assert.dom("svg use").hasAttribute("href", "#star");
+ assert.dom("svg").hasAria("label", "laughing");
});
});