mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 06:04:11 +08:00
FEATURE: show status in search results when mentioning user in composers (#17811)
This commit is contained in:
parent
55fa94f759
commit
e87ca397be
|
@ -1,11 +1,9 @@
|
|||
import { emojiUnescape } from "discourse/lib/text";
|
||||
import { escapeExpression } from "discourse/lib/utilities";
|
||||
import { htmlSafe } from "@ember/template";
|
||||
import { helper } from "@ember/component/helper";
|
||||
import { registerUnbound } from "discourse-common/lib/helpers";
|
||||
|
||||
function emoji(code, options) {
|
||||
registerUnbound("emoji", function (code, options) {
|
||||
const escaped = escapeExpression(`:${code}:`);
|
||||
return htmlSafe(emojiUnescape(escaped, options));
|
||||
}
|
||||
|
||||
export default helper(emoji);
|
||||
});
|
||||
|
|
|
@ -5,8 +5,9 @@
|
|||
<a href title="{{user.name}}">
|
||||
{{avatar user imageSize="tiny"}}
|
||||
<span class='username'>{{format-username user.username}}</span>
|
||||
<span class='name'>{{user.name}}</span>
|
||||
{{decorate-username-selector user.username}}
|
||||
{{#if user.status}}
|
||||
{{emoji user.status.emoji title=user.status.description}}
|
||||
{{/if}}
|
||||
</a>
|
||||
</li>
|
||||
{{/each}}
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
import { test } from "qunit";
|
||||
import { click, fillIn, triggerKeyEvent, visit } from "@ember/test-helpers";
|
||||
import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";
|
||||
import {
|
||||
acceptance,
|
||||
exists,
|
||||
query,
|
||||
} from "discourse/tests/helpers/qunit-helpers";
|
||||
import { setCaretPosition } from "discourse/lib/utilities";
|
||||
|
||||
acceptance("Composer - editor mentions", function (needs) {
|
||||
|
@ -16,6 +20,10 @@ acceptance("Composer - editor mentions", function (needs) {
|
|||
name: "Some User",
|
||||
avatar_template:
|
||||
"https://avatars.discourse.org/v3/letter/t/41988e/{size}.png",
|
||||
status: {
|
||||
emoji: "tooth",
|
||||
description: "off to dentist",
|
||||
},
|
||||
},
|
||||
{
|
||||
username: "user2",
|
||||
|
@ -104,4 +112,20 @@ acceptance("Composer - editor mentions", function (needs) {
|
|||
"should replace mention correctly"
|
||||
);
|
||||
});
|
||||
|
||||
test("shows status on search results when mentioning a user", async function (assert) {
|
||||
await visit("/");
|
||||
await click("#create-topic");
|
||||
|
||||
// emulate typing in "abc @u"
|
||||
const editor = query(".d-editor-input");
|
||||
await fillIn(".d-editor-input", "@");
|
||||
await setCaretPosition(editor, 5);
|
||||
await triggerKeyEvent(".d-editor-input", "keyup", "@");
|
||||
await fillIn(".d-editor-input", "@u");
|
||||
await setCaretPosition(editor, 6);
|
||||
await triggerKeyEvent(".d-editor-input", "keyup", "U");
|
||||
|
||||
assert.ok(exists(".autocomplete .emoji[title='off to dentist']"));
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user