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 $preview = this.$('.d-editor-preview-wrapper');
|
||||
|
||||
$input.autocomplete({
|
||||
template: findRawTemplate('user-selector-autocomplete'),
|
||||
dataSource: term => userSearch({
|
||||
term,
|
||||
topicId,
|
||||
includeMentionableGroups: true
|
||||
}),
|
||||
key: "@",
|
||||
transformComplete: v => v.username || v.name
|
||||
});
|
||||
if (this.siteSettings.enable_mentions) {
|
||||
$input.autocomplete({
|
||||
template: findRawTemplate('user-selector-autocomplete'),
|
||||
dataSource: term => userSearch({
|
||||
term,
|
||||
topicId,
|
||||
includeMentionableGroups: true
|
||||
}),
|
||||
key: "@",
|
||||
transformComplete: v => v.username || v.name
|
||||
});
|
||||
}
|
||||
|
||||
if (this._enableAdvancedEditorPreviewSync()) {
|
||||
this._initInputPreviewSync($input, $preview);
|
||||
|
|
|
@ -154,13 +154,15 @@ export function applySearchAutocomplete($input, siteSettings, appEvents, options
|
|||
afterComplete
|
||||
}, options));
|
||||
|
||||
$input.autocomplete(_.merge({
|
||||
template: findRawTemplate('user-selector-autocomplete'),
|
||||
key: "@",
|
||||
width: '100%',
|
||||
treatAsTextarea: true,
|
||||
transformComplete: v => v.username || v.name,
|
||||
dataSource: term => userSearch({ term, includeGroups: true }),
|
||||
afterComplete
|
||||
}, options));
|
||||
if (Discourse.SiteSettings.enable_mentions) {
|
||||
$input.autocomplete(_.merge({
|
||||
template: findRawTemplate('user-selector-autocomplete'),
|
||||
key: "@",
|
||||
width: '100%',
|
||||
treatAsTextarea: true,
|
||||
transformComplete: v => v.username || v.name,
|
||||
dataSource: term => userSearch({ term, includeGroups: true }),
|
||||
afterComplete
|
||||
}, options));
|
||||
}
|
||||
};
|
||||
|
|
|
@ -38,6 +38,10 @@ function addMention(buffer, matches, state) {
|
|||
}
|
||||
|
||||
export function setup(helper) {
|
||||
helper.registerOptions((opts, siteSettings) => {
|
||||
opts.features.mentions = !!siteSettings.enable_mentions;
|
||||
});
|
||||
|
||||
helper.registerPlugin(md => {
|
||||
|
||||
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."
|
||||
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)"
|
||||
enable_mentions: "Allow users to mention other users."
|
||||
|
||||
create_thumbnails: "Create thumbnails and lightbox images that are too large to fit in a post."
|
||||
|
||||
|
|
|
@ -537,6 +537,9 @@ posting:
|
|||
default: 1
|
||||
client: true
|
||||
post_undo_action_window_mins: 10
|
||||
enable_mentions:
|
||||
default: true
|
||||
client: true
|
||||
max_mentions_per_post: 10
|
||||
max_users_notified_per_group_mention: 100
|
||||
newuser_max_replies_per_topic: 3
|
||||
|
|
|
@ -8,6 +8,7 @@ QUnit.module("lib:pretty-text");
|
|||
const rawOpts = {
|
||||
siteSettings: {
|
||||
enable_emoji: true,
|
||||
enable_mentions: true,
|
||||
emoji_set: 'emoji_one',
|
||||
highlighted_languages: 'json|ruby|javascript',
|
||||
default_code_lang: 'auto',
|
||||
|
@ -282,7 +283,6 @@ QUnit.test("Quotes", assert => {
|
|||
});
|
||||
|
||||
QUnit.test("Mentions", assert => {
|
||||
|
||||
const alwaysTrue = { mentionLookup: (function() { return "user"; }) };
|
||||
|
||||
assert.cookedOptions("Hello @sam", alwaysTrue,
|
||||
|
@ -370,6 +370,12 @@ QUnit.test("Mentions", assert => {
|
|||
"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 => {
|
||||
const alwaysTrue = { categoryHashtagLookup: (function() { return ["http://test.discourse.org/category-hashtag", "category-hashtag"]; }) };
|
||||
|
||||
|
|
Loading…
Reference in New Issue