FEATURE: channels can allow/disallow @all/@here mentions (#19317)

The settings tab of each category channel should now present the option to allow or disallow channel wide mentions: @here and @all.

When disallowed, using these mentions in the channel should have no effect.
This commit is contained in:
Joffrey JAFFEUX
2022-12-05 17:03:51 +01:00
committed by GitHub
parent 569299b7a9
commit 68c4f16a73
23 changed files with 417 additions and 126 deletions

View File

@ -31,6 +31,7 @@ export const directMessageChannels = [
muted: false,
following: true,
},
allow_channel_wide_mentions: true,
last_message_sent_at: "2021-07-20T08:14:16.950Z",
message_bus_last_ids: {
new_mentions: 0,
@ -66,6 +67,7 @@ export const directMessageChannels = [
muted: false,
following: true,
},
allow_channel_wide_mentions: true,
last_message_sent_at: "2021-07-05T12:04:00.850Z",
message_bus_last_ids: {
new_mentions: 0,
@ -107,6 +109,7 @@ export const chatChannels = {
title: "Site",
status: "open",
chatable: chatables[1],
allow_channel_wide_mentions: true,
last_message_sent_at: "2021-07-24T08:14:16.950Z",
current_user_membership: {
unread_count: 0,
@ -126,6 +129,7 @@ export const chatChannels = {
title: "Bug",
status: "open",
chatable: chatables[1],
allow_channel_wide_mentions: true,
last_message_sent_at: "2021-07-15T08:14:16.950Z",
current_user_membership: {
unread_count: 0,
@ -145,6 +149,7 @@ export const chatChannels = {
title: "Public category",
status: "open",
chatable: chatables[8],
allow_channel_wide_mentions: true,
last_message_sent_at: "2021-07-14T08:14:16.950Z",
current_user_membership: {
unread_count: 0,
@ -164,6 +169,7 @@ export const chatChannels = {
title: "Public category (read-only)",
status: "read_only",
chatable: chatables[8],
allow_channel_wide_mentions: true,
last_message_sent_at: "2021-07-10T08:14:16.950Z",
current_user_membership: {
unread_count: 0,
@ -183,6 +189,7 @@ export const chatChannels = {
title: "Public category (closed)",
status: "closed",
chatable: chatables[8],
allow_channel_wide_mentions: true,
last_message_sent_at: "2021-07-21T08:14:16.950Z",
current_user_membership: {
unread_count: 0,
@ -202,6 +209,7 @@ export const chatChannels = {
title: "Public category (archived)",
status: "archived",
chatable: chatables[8],
allow_channel_wide_mentions: true,
last_message_sent_at: "2021-07-25T08:14:16.950Z",
current_user_membership: {
unread_count: 0,
@ -221,6 +229,7 @@ export const chatChannels = {
title: "Another Category",
status: "open",
chatable: chatables[12],
allow_channel_wide_mentions: true,
last_message_sent_at: "2021-07-02T08:14:16.950Z",
current_user_membership: {
unread_count: 0,

View File

@ -0,0 +1,31 @@
import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import { render, settled } from "@ember/test-helpers";
import { hbs } from "ember-cli-htmlbars";
module(
"Discourse Chat | Component | chat-channel-settings-saved-indicator",
function (hooks) {
setupRenderingTest(hooks);
test("when property changes", async function (assert) {
await render(
hbs`<ChatChannelSettingsSavedIndicator @property={{this.property}} />`
);
assert
.dom(".chat-channel-settings-saved-indicator.is-active")
.doesNotExist();
this.set("property", 1);
assert.dom(".chat-channel-settings-saved-indicator.is-active").exists();
await settled();
assert
.dom(".chat-channel-settings-saved-indicator.is-active")
.doesNotExist();
});
}
);

View File

@ -9,7 +9,14 @@ import { CHATABLE_TYPES } from "discourse/plugins/chat/discourse/models/chat-cha
import { module } from "qunit";
function membershipFixture(id, options = {}) {
options = Object.assign({}, options, { muted: false, following: true });
options = Object.assign(
{},
{
muted: false,
following: true,
},
options
);
return {
following: options.following,
@ -99,7 +106,7 @@ module(
return [
200,
{ "Content-Type": "application/json" },
membershipFixture(this.channel.id, { muted: true }),
membershipFixture(this.channel.id, { muted: false }),
];
}
);
@ -111,6 +118,34 @@ module(
assert.equal(sk.header().value(), "false");
},
});
componentTest("allow channel wide mentions", {
template: hbs`{{chat-channel-settings-view channel=channel}}`,
beforeEach() {
this.set("channel", fabricators.chatChannel());
},
async test(assert) {
pretender.put(`/chat/api/chat_channels/${this.channel.id}.json`, () => {
return [
200,
{ "Content-Type": "application/json" },
{
allow_channel_wide_mentions: false,
},
];
});
const sk = selectKit(
".channel-settings-view__channel-wide-mentions-selector"
);
await sk.expand();
await sk.selectRowByName("No");
assert.equal(sk.header().value(), "false");
},
});
}
);
@ -205,7 +240,7 @@ module(
return [
200,
{ "Content-Type": "application/json" },
membershipFixture(this.channel.id, { muted: true }),
membershipFixture(this.channel.id, { muted: false }),
];
}
);
@ -217,5 +252,24 @@ module(
assert.equal(sk.header().value(), "false");
},
});
componentTest("allow channel wide mentions", {
template: hbs`{{chat-channel-settings-view channel=channel}}`,
beforeEach() {
this.set(
"channel",
fabricators.chatChannel({
chatable_type: CHATABLE_TYPES.directMessageChannel,
})
);
},
async test(assert) {
assert
.dom(".channel-settings-view__channel-wide-mentions-selector")
.doesNotExist();
},
});
}
);

View File

@ -31,6 +31,7 @@ export default {
name: "My category name",
chatable: categoryChatableFabricator(),
last_message_sent_at: "2021-11-08T21:26:05.710Z",
allow_channel_wide_mentions: true,
message_bus_last_ids: {
new_mentions: 0,
new_messages: 0,