FIX: UX improvements for system messages when PMs are disabled

This commit is contained in:
Robin Ward 2018-01-23 13:11:39 -05:00
parent 28d432263e
commit 782d75069e
6 changed files with 40 additions and 3 deletions

View File

@ -6,6 +6,16 @@ export default Ember.Component.extend({
// Allow us to extend it
layoutName: 'components/topic-footer-buttons',
@computed('topic.isPrivateMessage')
canArchive(isPM) {
return this.siteSettings.enable_private_messages && isPM;
},
@computed('topic.isPrivateMessage')
showNotificationsButton(isPM) {
return (!isPM) || this.siteSettings.enable_private_messages;
},
@computed('topic.details.can_invite_to')
canInviteTo(result) {
return !this.site.mobileView && result;

View File

@ -50,8 +50,8 @@
disabled=inviteDisabled}}
{{/if}}
{{#if topic.isPrivateMessage}}
{{d-button class="standard"
{{#if canArchive}}
{{d-button class="standard archive-topic"
title=archiveTitle
label=archiveLabel
icon=archiveIcon
@ -79,7 +79,9 @@
{{pinned-button pinned=topic.pinned topic=topic}}
</div>
{{topic-notifications-button notificationLevel=topic.details.notification_level topic=topic}}
{{#if showNotificationsButton}}
{{topic-notifications-button notificationLevel=topic.details.notification_level topic=topic}}
{{/if}}
{{plugin-outlet name="after-topic-footer-buttons"
args=(hash topic=topic)

View File

@ -1034,6 +1034,7 @@ en:
summary_max_results: "Maximum posts returned by 'Summary This Topic'"
enable_private_messages: "Allow trust level 1 (configurable via min trust level to send messages) users to create messages and reply to messages. Note that staff can always send messages no matter what."
enable_system_message_replies: "Allows users to reply to system messages, even if private messages are disabled"
enable_private_email_messages: "Allow trust level 4 (configurable via min trust level to send messages) users to send private email messages. Note that staff can always send messages no matter what."
enable_long_polling: "Message bus used for notification can use long polling"

View File

@ -507,6 +507,8 @@ posting:
enable_private_messages:
default: true
client: true
enable_system_message_replies:
default: true
enable_private_email_messages:
default: false
client: true

View File

@ -80,6 +80,9 @@ module PostGuardian
# Creating Method
def can_create_post?(parent)
return false if !SiteSetting.enable_system_message_replies? && parent.try(:subtype) == "system_message"
(!SpamRule::AutoSilence.silence?(@user) || (!!parent.try(:private_message?) && parent.allowed_users.include?(@user))) && (
!parent ||
!parent.category ||

View File

@ -857,6 +857,25 @@ describe Guardian do
end
end
context "system message" do
let(:private_message) {
Fabricate(
:topic,
archetype: Archetype.private_message,
subtype: 'system_message',
category_id: nil
)
}
before { user.save! }
it "allows the user to reply to system messages" do
expect(Guardian.new(user).can_create_post?(private_message)).to eq(true)
SiteSetting.enable_system_message_replies = false
expect(Guardian.new(user).can_create_post?(private_message)).to eq(false)
end
end
context "private message" do
let(:private_message) { Fabricate(:topic, archetype: Archetype.private_message, category_id: nil) }