FEATURE: Chat global mention warnings (pre-send & post-send) (#22764)

This is also fixes the issue of chat composer warnings persisting across channels. Currently if you try to mention more groups than is allowed for example, a mention warning pops up. When you change channels the mention warning will not disappear even if there is no text in the composer.

This adds a reset function to the chat-composer-warnings-tracker.js, which is called when the channel is changed and the message is empty. In the event that the message is not empty we call captureMentions to check the loaded drafts' mentions.

This PR would be nicer if the post-send notice used the new chat notices API to publish the mention warnings but we would have to change the existing ones and I thought that would be too much change for this PR. It'd be a good followup though.
This commit is contained in:
Mark VanLandingham
2023-08-22 15:54:35 -05:00
committed by GitHub
parent c9de84c63d
commit 68eba53e09
13 changed files with 137 additions and 10 deletions

View File

@ -98,5 +98,21 @@ module(
)
.exists();
});
test("displays a warning when global mentions are disabled", async function (assert) {
this.message = fabricators.message();
this.message.mentionWarning = fabricators.messageMentionWarning(
this.message,
{
global_mentions_disabled: true,
}
);
await render(template);
assert
.dom(".chat-message-mention-warning__text.-global-mentions-disabled")
.exists();
});
}
);