FIX: Don't show personal messages if disabled as a composer action

This commit is contained in:
Robin Ward 2018-02-09 16:58:04 -05:00
parent 56352137ca
commit 2faa4c2f5f
2 changed files with 15 additions and 2 deletions

View File

@ -1,5 +1,5 @@
import DropdownSelectBoxComponent from "select-kit/components/dropdown-select-box";
import { default as computed } from "ember-addons/ember-computed-decorators";
import computed from "ember-addons/ember-computed-decorators";
import { default as Composer, PRIVATE_MESSAGE, CREATE_TOPIC, REPLY, EDIT } from "discourse/models/composer";
// Component can get destroyed and lose state
@ -79,7 +79,7 @@ export default DropdownSelectBoxComponent.extend({
});
}
if (action !== PRIVATE_MESSAGE) {
if (this.siteSettings.enable_personal_messages && action !== PRIVATE_MESSAGE) {
items.push({
name: I18n.t("composer.composer_actions.reply_as_private_message.label"),
description: I18n.t("composer.composer_actions.reply_as_private_message.desc"),
@ -107,6 +107,17 @@ export default DropdownSelectBoxComponent.extend({
});
}
// Edge case: If personal messages are disabled, it is possible to have
// no items which stil renders a button that pops up nothing. In this
// case, add an option for what you're currently doing.
if (action === CREATE_TOPIC && items.length === 0) {
items.push({
name: I18n.t("composer.composer_actions.create_topic.label"),
description: I18n.t("composer.composer_actions.reply_as_new_topic.desc"),
icon: "mail-forward",
id: "create_topic"
});
}
return items;
},

View File

@ -1307,6 +1307,8 @@ en:
toggle_whisper:
label: Toggle whipser
desc: Whispers will only be visible by staff members
create_topic:
label: "New Topic"
notifications:
tooltip: