Skip to content
Snippets Groups Projects
Commit 21a7324f authored by Pedro Beschorner Marin's avatar Pedro Beschorner Marin
Browse files

feat(guests): notification settings

Avoid showing the guest's notification toggles at client's settings if the guest
policy isn't `ASK_MODERATOR`.
parent 8ade9d1f
No related branches found
No related tags found
No related merge requests found
...@@ -164,6 +164,7 @@ class Settings extends Component { ...@@ -164,6 +164,7 @@ class Settings extends Component {
const { const {
intl, intl,
isModerator, isModerator,
showGuestNotification,
showToggleLabel, showToggleLabel,
} = this.props; } = this.props;
...@@ -219,6 +220,7 @@ class Settings extends Component { ...@@ -219,6 +220,7 @@ class Settings extends Component {
<Notification <Notification
handleUpdateSettings={this.handleUpdateSettings} handleUpdateSettings={this.handleUpdateSettings}
settings={current.application} settings={current.application}
showGuestNotification={showGuestNotification}
showToggleLabel={showToggleLabel} showToggleLabel={showToggleLabel}
displaySettingsStatus={this.displaySettingsStatus} displaySettingsStatus={this.displaySettingsStatus}
{...{ isModerator }} {...{ isModerator }}
......
...@@ -5,6 +5,7 @@ import Settings from './component'; ...@@ -5,6 +5,7 @@ import Settings from './component';
import { import {
getUserRoles, getUserRoles,
showGuestNotification,
updateSettings, updateSettings,
getAvailableLocales, getAvailableLocales,
} from './service'; } from './service';
...@@ -20,5 +21,6 @@ export default withTracker(() => ({ ...@@ -20,5 +21,6 @@ export default withTracker(() => ({
updateSettings, updateSettings,
availableLocales: getAvailableLocales(), availableLocales: getAvailableLocales(),
isModerator: getUserRoles() === 'MODERATOR', isModerator: getUserRoles() === 'MODERATOR',
showGuestNotification: showGuestNotification(),
showToggleLabel: false, showToggleLabel: false,
}))(SettingsContainer); }))(SettingsContainer);
...@@ -2,6 +2,7 @@ import Users from '/imports/api/users'; ...@@ -2,6 +2,7 @@ import Users from '/imports/api/users';
import Auth from '/imports/ui/services/auth'; import Auth from '/imports/ui/services/auth';
import Settings from '/imports/ui/services/settings'; import Settings from '/imports/ui/services/settings';
import { notify } from '/imports/ui/services/notification'; import { notify } from '/imports/ui/services/notification';
import GuestService from '/imports/ui/components/waiting-users/service';
const getUserRoles = () => { const getUserRoles = () => {
const user = Users.findOne({ const user = Users.findOne({
...@@ -11,6 +12,14 @@ const getUserRoles = () => { ...@@ -11,6 +12,14 @@ const getUserRoles = () => {
return user.role; return user.role;
}; };
const showGuestNotification = () => {
const guestPolicy = GuestService.getGuestPolicy();
// Guest notification only makes sense when guest
// entrance is being controlled by moderators
return guestPolicy === 'ASK_MODERATOR';
};
const updateSettings = (obj, msg) => { const updateSettings = (obj, msg) => {
Object.keys(obj).forEach(k => (Settings[k] = obj[k])); Object.keys(obj).forEach(k => (Settings[k] = obj[k]));
Settings.save(); Settings.save();
...@@ -31,6 +40,7 @@ const getAvailableLocales = () => fetch('./locale-list').then(locales => locales ...@@ -31,6 +40,7 @@ const getAvailableLocales = () => fetch('./locale-list').then(locales => locales
export { export {
getUserRoles, getUserRoles,
showGuestNotification,
updateSettings, updateSettings,
getAvailableLocales, getAvailableLocales,
}; };
...@@ -54,8 +54,13 @@ class NotificationMenu extends BaseMenu { ...@@ -54,8 +54,13 @@ class NotificationMenu extends BaseMenu {
render() { render() {
const { const {
intl, isModerator, showToggleLabel, displaySettingsStatus, intl,
isModerator,
showGuestNotification,
showToggleLabel,
displaySettingsStatus,
} = this.props; } = this.props;
const { settings } = this.state; const { settings } = this.state;
return ( return (
...@@ -144,7 +149,7 @@ class NotificationMenu extends BaseMenu { ...@@ -144,7 +149,7 @@ class NotificationMenu extends BaseMenu {
</div> </div>
</div> </div>
{isModerator ? ( {isModerator && showGuestNotification ? (
<div className={styles.row}> <div className={styles.row}>
<div className={styles.col}> <div className={styles.col}>
<label className={styles.label}> <label className={styles.label}>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment