FEATURE: site setting enable_mentions to turn on/off mentions
This commit is contained in:
parent
3e4f02a180
commit
fd99e1ef56
|
@ -77,16 +77,18 @@ export default Ember.Component.extend({
|
||||||
const $input = this.$('.d-editor-input');
|
const $input = this.$('.d-editor-input');
|
||||||
const $preview = this.$('.d-editor-preview-wrapper');
|
const $preview = this.$('.d-editor-preview-wrapper');
|
||||||
|
|
||||||
$input.autocomplete({
|
if (this.siteSettings.enable_mentions) {
|
||||||
template: findRawTemplate('user-selector-autocomplete'),
|
$input.autocomplete({
|
||||||
dataSource: term => userSearch({
|
template: findRawTemplate('user-selector-autocomplete'),
|
||||||
term,
|
dataSource: term => userSearch({
|
||||||
topicId,
|
term,
|
||||||
includeMentionableGroups: true
|
topicId,
|
||||||
}),
|
includeMentionableGroups: true
|
||||||
key: "@",
|
}),
|
||||||
transformComplete: v => v.username || v.name
|
key: "@",
|
||||||
});
|
transformComplete: v => v.username || v.name
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (this._enableAdvancedEditorPreviewSync()) {
|
if (this._enableAdvancedEditorPreviewSync()) {
|
||||||
this._initInputPreviewSync($input, $preview);
|
this._initInputPreviewSync($input, $preview);
|
||||||
|
|
|
@ -154,13 +154,15 @@ export function applySearchAutocomplete($input, siteSettings, appEvents, options
|
||||||
afterComplete
|
afterComplete
|
||||||
}, options));
|
}, options));
|
||||||
|
|
||||||
$input.autocomplete(_.merge({
|
if (Discourse.SiteSettings.enable_mentions) {
|
||||||
template: findRawTemplate('user-selector-autocomplete'),
|
$input.autocomplete(_.merge({
|
||||||
key: "@",
|
template: findRawTemplate('user-selector-autocomplete'),
|
||||||
width: '100%',
|
key: "@",
|
||||||
treatAsTextarea: true,
|
width: '100%',
|
||||||
transformComplete: v => v.username || v.name,
|
treatAsTextarea: true,
|
||||||
dataSource: term => userSearch({ term, includeGroups: true }),
|
transformComplete: v => v.username || v.name,
|
||||||
afterComplete
|
dataSource: term => userSearch({ term, includeGroups: true }),
|
||||||
}, options));
|
afterComplete
|
||||||
|
}, options));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -38,6 +38,10 @@ function addMention(buffer, matches, state) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setup(helper) {
|
export function setup(helper) {
|
||||||
|
helper.registerOptions((opts, siteSettings) => {
|
||||||
|
opts.features.mentions = !!siteSettings.enable_mentions;
|
||||||
|
});
|
||||||
|
|
||||||
helper.registerPlugin(md => {
|
helper.registerPlugin(md => {
|
||||||
|
|
||||||
const rule = {
|
const rule = {
|
||||||
|
|
|
@ -1283,6 +1283,7 @@ en:
|
||||||
newuser_max_replies_per_topic: "Maximum number of replies a new user can make in a single topic until someone replies to them."
|
newuser_max_replies_per_topic: "Maximum number of replies a new user can make in a single topic until someone replies to them."
|
||||||
max_mentions_per_post: "Maximum number of @name notifications anyone can use in a post."
|
max_mentions_per_post: "Maximum number of @name notifications anyone can use in a post."
|
||||||
max_users_notified_per_group_mention: "Maximum number of users that may receive a notification if a group is mentioned (if threshold is met no notifications will be raised)"
|
max_users_notified_per_group_mention: "Maximum number of users that may receive a notification if a group is mentioned (if threshold is met no notifications will be raised)"
|
||||||
|
enable_mentions: "Allow users to mention other users."
|
||||||
|
|
||||||
create_thumbnails: "Create thumbnails and lightbox images that are too large to fit in a post."
|
create_thumbnails: "Create thumbnails and lightbox images that are too large to fit in a post."
|
||||||
|
|
||||||
|
|
|
@ -537,6 +537,9 @@ posting:
|
||||||
default: 1
|
default: 1
|
||||||
client: true
|
client: true
|
||||||
post_undo_action_window_mins: 10
|
post_undo_action_window_mins: 10
|
||||||
|
enable_mentions:
|
||||||
|
default: true
|
||||||
|
client: true
|
||||||
max_mentions_per_post: 10
|
max_mentions_per_post: 10
|
||||||
max_users_notified_per_group_mention: 100
|
max_users_notified_per_group_mention: 100
|
||||||
newuser_max_replies_per_topic: 3
|
newuser_max_replies_per_topic: 3
|
||||||
|
|
|
@ -8,6 +8,7 @@ QUnit.module("lib:pretty-text");
|
||||||
const rawOpts = {
|
const rawOpts = {
|
||||||
siteSettings: {
|
siteSettings: {
|
||||||
enable_emoji: true,
|
enable_emoji: true,
|
||||||
|
enable_mentions: true,
|
||||||
emoji_set: 'emoji_one',
|
emoji_set: 'emoji_one',
|
||||||
highlighted_languages: 'json|ruby|javascript',
|
highlighted_languages: 'json|ruby|javascript',
|
||||||
default_code_lang: 'auto',
|
default_code_lang: 'auto',
|
||||||
|
@ -282,7 +283,6 @@ QUnit.test("Quotes", assert => {
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test("Mentions", assert => {
|
QUnit.test("Mentions", assert => {
|
||||||
|
|
||||||
const alwaysTrue = { mentionLookup: (function() { return "user"; }) };
|
const alwaysTrue = { mentionLookup: (function() { return "user"; }) };
|
||||||
|
|
||||||
assert.cookedOptions("Hello @sam", alwaysTrue,
|
assert.cookedOptions("Hello @sam", alwaysTrue,
|
||||||
|
@ -370,6 +370,12 @@ QUnit.test("Mentions", assert => {
|
||||||
"it allows mentions within HTML tags");
|
"it allows mentions within HTML tags");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
QUnit.test("Mentions - disabled", assert => {
|
||||||
|
assert.cookedOptions("@eviltrout",
|
||||||
|
{ siteSettings : { enable_mentions: false }},
|
||||||
|
"<p>@eviltrout</p>");
|
||||||
|
});
|
||||||
|
|
||||||
QUnit.test("Category hashtags", assert => {
|
QUnit.test("Category hashtags", assert => {
|
||||||
const alwaysTrue = { categoryHashtagLookup: (function() { return ["http://test.discourse.org/category-hashtag", "category-hashtag"]; }) };
|
const alwaysTrue = { categoryHashtagLookup: (function() { return ["http://test.discourse.org/category-hashtag", "category-hashtag"]; }) };
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue