mirror of
https://github.com/discourse/discourse.git
synced 2025-06-01 09:08:10 +08:00
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:
@ -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,
|
||||
|
@ -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();
|
||||
});
|
||||
}
|
||||
);
|
@ -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();
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
|
@ -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,
|
||||
|
Reference in New Issue
Block a user