Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Missing option to disable/enable System Messages #10704

Merged
merged 3 commits into from
May 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
{{#with settings.t}}
<div class="rc-user-info__row rc-user-info__row--separator">
<div class="rc-switch-double">
<div class="rc-switch-double__label {{equal true value 'disabled'}}">
<div class="rc-switch-double__label {{equal false value 'disabled'}}">
{{_ "Public"}}{{equal default value '*'}}
<div class="rc-switch-double__description">
{{_ "Everyone_can_access_this_channel"}}
Expand All @@ -79,7 +79,7 @@
</span>
</label>
</div>
<div class="rc-switch-double__label {{equal false value 'disabled'}}">
<div class="rc-switch-double__label {{equal true value 'disabled'}}">
{{_ "Private"}}
<div class="rc-switch-double__description">
{{_ "Just_invited_people_can_access_this_channel"}}
Expand All @@ -93,7 +93,7 @@
{{#with settings.ro}}
<div class="rc-user-info__row rc-user-info__row--separator">
<div class="rc-switch-double">
<div class="rc-switch-double__label {{equal true value 'disabled'}}">
<div class="rc-switch-double__label {{equal false value 'disabled'}}">
{{_ "Colaborative"}}{{equal default value '*'}}
<div class="rc-switch-double__description">
{{_ "All_users_in_the_channel_can_write_new_messages"}}
Expand All @@ -107,7 +107,7 @@
</span>
</label>
</div>
<div class="rc-switch-double__label {{equal false value 'disabled'}}">
<div class="rc-switch-double__label {{equal true value 'disabled'}}">
{{_ "Read_only"}}
<div class="rc-switch-double__description">
{{_ "Only_authorized_users_can_write_new_messages"}}
Expand Down Expand Up @@ -163,6 +163,25 @@
</div>
{{/if}}
{{/with}}

{{#with settings.sysMes}}
{{#if canView}}
<div class="rc-user-info__row">
<div class="rc-switch rc-switch--blue">
<label class="rc-switch__label">
<span class="rc-switch__text">
{{_ label}}{{equal default value '*'}}
</span>
<input type="checkbox" class="rc-switch__input js-input-check" name="archived" checked="{{checked}}" disabled="{{./disabled}}">
<span class="rc-switch__button">
<span class="rc-switch__button-inside"></span>
</span>
</label>
</div>
</div>
{{/if}}
{{/with}}

{{#with settings.broadcast}}
{{#if canView}}
<div class="rc-user-info__row">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,33 @@ Template.channelSettingsEditing.onCreated(function() {
});
}
},
sysMes: {
type: 'boolean',
label: 'System_messages',
isToggle: true,
processing: new ReactiveVar(false),
canView() {
return RocketChat.roomTypes.roomTypes[room.t].allowRoomSettingChange(
room,
RoomSettingsEnum.SYSTEM_MESSAGES
);
},
getValue() {
return room.sysMes !== false;
},
canEdit() {
return RocketChat.authz.hasAllPermission('edit-room', room._id);
},
save(value) {
return call('saveRoomSettings', room._id, 'systemMessages', value).then(
() => {
toastr.success(
TAPi18n.__('System_messages_setting_changed_successfully')
);
}
);
}
},
archived: {
type: 'boolean',
label: 'Room_archivation_state_true',
Expand Down
3 changes: 2 additions & 1 deletion packages/rocketchat-lib/lib/RoomTypeConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ export const RoomSettingsEnum = {
REACT_WHEN_READ_ONLY: 'reactWhenReadOnly',
ARCHIVE_OR_UNARCHIVE: 'archiveOrUnarchive',
JOIN_CODE: 'joinCode',
BROADCAST: 'broadcast'
BROADCAST: 'broadcast',
SYSTEM_MESSAGES: 'systemMessages'
};

export const UiTextContext = {
Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-lib/lib/roomTypes/direct.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export class DirectMessageRoomType extends RoomTypeConfig {
allowRoomSettingChange(room, setting) {
switch (setting) {
case RoomSettingsEnum.NAME:
case RoomSettingsEnum.SYSTEM_MESSAGES:
case RoomSettingsEnum.DESCRIPTION:
case RoomSettingsEnum.READ_ONLY:
case RoomSettingsEnum.REACT_WHEN_READ_ONLY:
Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-lib/lib/roomTypes/private.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export class PrivateRoomType extends RoomTypeConfig {
return !room.broadcast;
case RoomSettingsEnum.REACT_WHEN_READ_ONLY:
return !room.broadcast && room.ro;
case RoomSettingsEnum.SYSTEM_MESSAGES:
default:
return true;
}
Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-lib/lib/roomTypes/public.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export class PublicRoomType extends RoomTypeConfig {
return !room.broadcast;
case RoomSettingsEnum.REACT_WHEN_READ_ONLY:
return !room.broadcast && room.ro;
case RoomSettingsEnum.SYSTEM_MESSAGES:
default:
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,6 @@
}
}

& .rc-switch-double__label {
color: #a1a1a1;
}

&--separator {

margin: 14px 0;
Expand Down Expand Up @@ -294,6 +290,8 @@

word-break: break-word;

color: #444;

&__description {
margin: 5px 2px;

Expand All @@ -314,7 +312,7 @@
}

&.disabled {
color: inherit;
opacity: 0.3;
}
}

Expand Down
1 change: 1 addition & 0 deletions server/publications/room.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const fields = {
label: 1,
ro: 1,
reactWhenReadOnly: 1,
sysMes: 1,
sentiment: 1,
tokenpass: 1,
streamingOptions: 1,
Expand Down