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

@ -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();
},
});
}
);