2020-03-19 22:19:40 +08:00
|
|
|
import React from 'react';
|
2022-02-15 23:58:28 +08:00
|
|
|
import Toggle from '/imports/ui/components/common/switch/component';
|
2020-03-19 22:19:40 +08:00
|
|
|
import { defineMessages, injectIntl } from 'react-intl';
|
|
|
|
import BaseMenu from '../base/component';
|
2021-11-05 22:18:04 +08:00
|
|
|
import Styled from './styles';
|
2020-03-19 22:19:40 +08:00
|
|
|
|
|
|
|
const CHAT_ENABLED = Meteor.settings.public.chat.enabled;
|
|
|
|
|
|
|
|
const intlMessages = defineMessages({
|
|
|
|
notificationSectionTitle: {
|
|
|
|
id: 'app.submenu.notification.SectionTitle',
|
|
|
|
description: 'Notification section title',
|
|
|
|
},
|
|
|
|
notificationSectionDesc: {
|
|
|
|
id: 'app.submenu.notification.Desc',
|
|
|
|
description: 'provides extra info for notification section',
|
|
|
|
},
|
|
|
|
audioAlertLabel: {
|
|
|
|
id: 'app.submenu.notification.audioAlertLabel',
|
|
|
|
description: 'audio notification label',
|
|
|
|
},
|
|
|
|
pushAlertLabel: {
|
|
|
|
id: 'app.submenu.notification.pushAlertLabel',
|
|
|
|
description: 'push notifiation label',
|
|
|
|
},
|
|
|
|
messagesLabel: {
|
|
|
|
id: 'app.submenu.notification.messagesLabel',
|
|
|
|
description: 'label for chat messages',
|
|
|
|
},
|
|
|
|
userJoinLabel: {
|
|
|
|
id: 'app.submenu.notification.userJoinLabel',
|
|
|
|
description: 'label for chat messages',
|
|
|
|
},
|
2021-08-21 01:15:29 +08:00
|
|
|
userLeaveLabel: {
|
|
|
|
id: 'app.submenu.notification.userLeaveLabel',
|
|
|
|
description: 'label for user leave notifications',
|
|
|
|
},
|
2020-07-16 02:50:56 +08:00
|
|
|
guestWaitingLabel: {
|
|
|
|
id: 'app.submenu.notification.guestWaitingLabel',
|
2021-03-04 03:20:19 +08:00
|
|
|
description: 'label for guests waiting for approval',
|
2020-07-16 02:50:56 +08:00
|
|
|
},
|
2020-03-19 22:19:40 +08:00
|
|
|
raiseHandLabel: {
|
|
|
|
id: 'app.submenu.notification.raiseHandLabel',
|
|
|
|
description: 'label for raise hand emoji notifications',
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
class NotificationMenu extends BaseMenu {
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
this.state = {
|
|
|
|
settingsName: 'notification',
|
|
|
|
settings: props.settings,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2021-05-01 03:06:28 +08:00
|
|
|
const {
|
2021-05-30 23:09:33 +08:00
|
|
|
intl,
|
|
|
|
isModerator,
|
|
|
|
showGuestNotification,
|
|
|
|
showToggleLabel,
|
|
|
|
displaySettingsStatus,
|
2021-05-01 03:06:28 +08:00
|
|
|
} = this.props;
|
2021-05-30 23:09:33 +08:00
|
|
|
|
2020-03-19 22:19:40 +08:00
|
|
|
const { settings } = this.state;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<div>
|
2021-11-05 22:18:04 +08:00
|
|
|
<Styled.Title>
|
2020-03-19 22:19:40 +08:00
|
|
|
{intl.formatMessage(intlMessages.notificationSectionTitle)}
|
2021-11-05 22:18:04 +08:00
|
|
|
</Styled.Title>
|
|
|
|
<Styled.SubTitle>
|
|
|
|
{intl.formatMessage(intlMessages.notificationSectionDesc)}
|
|
|
|
</Styled.SubTitle>
|
2020-03-19 22:19:40 +08:00
|
|
|
</div>
|
|
|
|
|
2021-11-05 22:18:04 +08:00
|
|
|
<Styled.Form>
|
|
|
|
<Styled.Row>
|
|
|
|
<Styled.Col />
|
|
|
|
<Styled.ColHeading>
|
2020-03-19 22:19:40 +08:00
|
|
|
{intl.formatMessage(intlMessages.audioAlertLabel)}
|
2021-11-05 22:18:04 +08:00
|
|
|
</Styled.ColHeading>
|
|
|
|
<Styled.ColHeading>
|
2020-03-19 22:19:40 +08:00
|
|
|
{intl.formatMessage(intlMessages.pushAlertLabel)}
|
2021-11-05 22:18:04 +08:00
|
|
|
</Styled.ColHeading>
|
|
|
|
</Styled.Row>
|
2020-03-19 22:19:40 +08:00
|
|
|
|
|
|
|
{CHAT_ENABLED ? (
|
2021-11-05 22:18:04 +08:00
|
|
|
<Styled.Row>
|
|
|
|
<Styled.Col>
|
|
|
|
<Styled.Label>
|
2020-03-19 22:19:40 +08:00
|
|
|
{intl.formatMessage(intlMessages.messagesLabel)}
|
2021-11-05 22:18:04 +08:00
|
|
|
</Styled.Label>
|
|
|
|
</Styled.Col>
|
|
|
|
<Styled.Col>
|
|
|
|
<Styled.FormElementCenter>
|
2021-05-01 03:06:28 +08:00
|
|
|
{displaySettingsStatus(settings.chatAudioAlerts)}
|
2020-03-19 22:19:40 +08:00
|
|
|
<Toggle
|
|
|
|
icons={false}
|
|
|
|
defaultChecked={settings.chatAudioAlerts}
|
|
|
|
onChange={() => this.handleToggle('chatAudioAlerts')}
|
|
|
|
ariaLabel={`${intl.formatMessage(intlMessages.messagesLabel)} ${intl.formatMessage(intlMessages.audioAlertLabel)}`}
|
2021-05-01 03:06:28 +08:00
|
|
|
showToggleLabel={showToggleLabel}
|
2020-03-19 22:19:40 +08:00
|
|
|
/>
|
2021-11-05 22:18:04 +08:00
|
|
|
</Styled.FormElementCenter>
|
|
|
|
</Styled.Col>
|
|
|
|
<Styled.Col>
|
|
|
|
<Styled.FormElementCenter>
|
2021-05-01 03:06:28 +08:00
|
|
|
{displaySettingsStatus(settings.chatPushAlerts)}
|
2020-03-19 22:19:40 +08:00
|
|
|
<Toggle
|
|
|
|
icons={false}
|
|
|
|
defaultChecked={settings.chatPushAlerts}
|
|
|
|
onChange={() => this.handleToggle('chatPushAlerts')}
|
|
|
|
ariaLabel={`${intl.formatMessage(intlMessages.messagesLabel)} ${intl.formatMessage(intlMessages.pushAlertLabel)}`}
|
2021-05-01 03:06:28 +08:00
|
|
|
showToggleLabel={showToggleLabel}
|
2022-01-20 21:03:18 +08:00
|
|
|
data-test="chatPopupAlertsBtn"
|
2020-03-19 22:19:40 +08:00
|
|
|
/>
|
2021-11-05 22:18:04 +08:00
|
|
|
</Styled.FormElementCenter>
|
|
|
|
</Styled.Col>
|
|
|
|
</Styled.Row>
|
|
|
|
) : null}
|
2020-03-19 22:19:40 +08:00
|
|
|
|
2021-11-05 22:18:04 +08:00
|
|
|
<Styled.Row>
|
|
|
|
<Styled.Col>
|
|
|
|
<Styled.Label>
|
2020-03-19 22:19:40 +08:00
|
|
|
{intl.formatMessage(intlMessages.userJoinLabel)}
|
2021-11-05 22:18:04 +08:00
|
|
|
</Styled.Label>
|
|
|
|
</Styled.Col>
|
|
|
|
<Styled.Col>
|
|
|
|
<Styled.FormElementCenter>
|
2021-05-01 03:06:28 +08:00
|
|
|
{displaySettingsStatus(settings.userJoinAudioAlerts)}
|
2020-03-19 22:19:40 +08:00
|
|
|
<Toggle
|
|
|
|
icons={false}
|
|
|
|
defaultChecked={settings.userJoinAudioAlerts}
|
|
|
|
onChange={() => this.handleToggle('userJoinAudioAlerts')}
|
|
|
|
ariaLabel={`${intl.formatMessage(intlMessages.userJoinLabel)} ${intl.formatMessage(intlMessages.audioAlertLabel)}`}
|
2021-05-01 03:06:28 +08:00
|
|
|
showToggleLabel={showToggleLabel}
|
2020-03-19 22:19:40 +08:00
|
|
|
/>
|
2021-11-05 22:18:04 +08:00
|
|
|
</Styled.FormElementCenter>
|
|
|
|
</Styled.Col>
|
|
|
|
<Styled.Col>
|
|
|
|
<Styled.FormElementCenter>
|
2021-05-01 03:06:28 +08:00
|
|
|
{displaySettingsStatus(settings.userJoinPushAlerts)}
|
2020-03-19 22:19:40 +08:00
|
|
|
<Toggle
|
|
|
|
icons={false}
|
|
|
|
defaultChecked={settings.userJoinPushAlerts}
|
|
|
|
onChange={() => this.handleToggle('userJoinPushAlerts')}
|
|
|
|
ariaLabel={`${intl.formatMessage(intlMessages.userJoinLabel)} ${intl.formatMessage(intlMessages.pushAlertLabel)}`}
|
2021-05-01 03:06:28 +08:00
|
|
|
showToggleLabel={showToggleLabel}
|
2022-01-20 21:03:18 +08:00
|
|
|
data-test="userJoinPopupAlerts"
|
2020-03-19 22:19:40 +08:00
|
|
|
/>
|
2021-11-05 22:18:04 +08:00
|
|
|
</Styled.FormElementCenter>
|
|
|
|
</Styled.Col>
|
|
|
|
</Styled.Row>
|
2020-03-19 22:19:40 +08:00
|
|
|
|
2021-11-05 22:18:04 +08:00
|
|
|
<Styled.Row>
|
|
|
|
<Styled.Col>
|
|
|
|
<Styled.Label>
|
2021-08-21 01:15:29 +08:00
|
|
|
{intl.formatMessage(intlMessages.userLeaveLabel)}
|
2021-11-05 22:18:04 +08:00
|
|
|
</Styled.Label>
|
|
|
|
</Styled.Col>
|
|
|
|
<Styled.Col>
|
|
|
|
<Styled.FormElementCenter>
|
2021-08-21 01:15:29 +08:00
|
|
|
{displaySettingsStatus(settings.userLeaveAudioAlerts)}
|
|
|
|
<Toggle
|
|
|
|
icons={false}
|
|
|
|
defaultChecked={settings.userLeaveAudioAlerts}
|
|
|
|
onChange={() => this.handleToggle('userLeaveAudioAlerts')}
|
|
|
|
ariaLabel={`${intl.formatMessage(intlMessages.userLeaveLabel)} ${intl.formatMessage(intlMessages.audioAlertLabel)}`}
|
|
|
|
showToggleLabel={showToggleLabel}
|
|
|
|
/>
|
2021-11-05 22:18:04 +08:00
|
|
|
</Styled.FormElementCenter>
|
|
|
|
</Styled.Col>
|
|
|
|
<Styled.Col>
|
|
|
|
<Styled.FormElementCenter>
|
2021-08-21 01:15:29 +08:00
|
|
|
{displaySettingsStatus(settings.userLeavePushAlerts)}
|
|
|
|
<Toggle
|
|
|
|
icons={false}
|
|
|
|
defaultChecked={settings.userLeavePushAlerts}
|
|
|
|
onChange={() => this.handleToggle('userLeavePushAlerts')}
|
|
|
|
ariaLabel={`${intl.formatMessage(intlMessages.userLeaveLabel)} ${intl.formatMessage(intlMessages.pushAlertLabel)}`}
|
|
|
|
showToggleLabel={showToggleLabel}
|
|
|
|
/>
|
2021-11-05 22:18:04 +08:00
|
|
|
</Styled.FormElementCenter>
|
|
|
|
</Styled.Col>
|
|
|
|
</Styled.Row>
|
2021-08-21 01:15:29 +08:00
|
|
|
|
2021-05-30 23:09:33 +08:00
|
|
|
{isModerator && showGuestNotification ? (
|
2021-11-05 22:18:04 +08:00
|
|
|
<Styled.Row>
|
|
|
|
<Styled.Col>
|
|
|
|
<Styled.Label>
|
2020-07-16 02:50:56 +08:00
|
|
|
{intl.formatMessage(intlMessages.guestWaitingLabel)}
|
2021-11-05 22:18:04 +08:00
|
|
|
</Styled.Label>
|
|
|
|
</Styled.Col>
|
|
|
|
<Styled.Col>
|
|
|
|
<Styled.FormElementCenter>
|
2021-05-01 03:06:28 +08:00
|
|
|
{displaySettingsStatus(settings.guestWaitingAudioAlerts)}
|
2020-07-16 02:50:56 +08:00
|
|
|
<Toggle
|
|
|
|
icons={false}
|
|
|
|
defaultChecked={settings.guestWaitingAudioAlerts}
|
|
|
|
onChange={() => this.handleToggle('guestWaitingAudioAlerts')}
|
2021-03-04 03:20:19 +08:00
|
|
|
ariaLabel={`${intl.formatMessage(intlMessages.guestWaitingLabel)} ${intl.formatMessage(intlMessages.audioAlertLabel)}`}
|
2021-05-01 03:06:28 +08:00
|
|
|
showToggleLabel={showToggleLabel}
|
2021-03-04 03:20:19 +08:00
|
|
|
/>
|
2021-11-05 22:18:04 +08:00
|
|
|
</Styled.FormElementCenter>
|
|
|
|
</Styled.Col>
|
|
|
|
<Styled.Col>
|
|
|
|
<Styled.FormElementCenter>
|
2021-05-01 03:06:28 +08:00
|
|
|
{displaySettingsStatus(settings.guestWaitingPushAlerts)}
|
2021-03-04 03:20:19 +08:00
|
|
|
<Toggle
|
|
|
|
icons={false}
|
|
|
|
defaultChecked={settings.guestWaitingPushAlerts}
|
|
|
|
onChange={() => this.handleToggle('guestWaitingPushAlerts')}
|
|
|
|
ariaLabel={`${intl.formatMessage(intlMessages.guestWaitingLabel)} ${intl.formatMessage(intlMessages.pushAlertLabel)}`}
|
2021-05-01 03:06:28 +08:00
|
|
|
showToggleLabel={showToggleLabel}
|
2020-07-16 02:50:56 +08:00
|
|
|
/>
|
2021-11-05 22:18:04 +08:00
|
|
|
</Styled.FormElementCenter>
|
|
|
|
</Styled.Col>
|
|
|
|
</Styled.Row>
|
2020-07-16 02:50:56 +08:00
|
|
|
) : null}
|
|
|
|
|
2020-07-06 20:56:19 +08:00
|
|
|
{isModerator ? (
|
2021-11-05 22:18:04 +08:00
|
|
|
<Styled.Row>
|
|
|
|
<Styled.Col>
|
|
|
|
<Styled.Label>
|
2020-07-06 20:56:19 +08:00
|
|
|
{intl.formatMessage(intlMessages.raiseHandLabel)}
|
2021-11-05 22:18:04 +08:00
|
|
|
</Styled.Label>
|
|
|
|
</Styled.Col>
|
|
|
|
<Styled.Col>
|
|
|
|
<Styled.FormElementCenter>
|
2021-05-01 03:06:28 +08:00
|
|
|
{displaySettingsStatus(settings.raiseHandAudioAlerts)}
|
2020-07-06 20:56:19 +08:00
|
|
|
<Toggle
|
|
|
|
icons={false}
|
|
|
|
defaultChecked={settings.raiseHandAudioAlerts}
|
|
|
|
onChange={() => this.handleToggle('raiseHandAudioAlerts')}
|
|
|
|
ariaLabel={`${intl.formatMessage(intlMessages.raiseHandLabel)} ${intl.formatMessage(intlMessages.audioAlertLabel)}`}
|
2021-05-01 03:06:28 +08:00
|
|
|
showToggleLabel={showToggleLabel}
|
2020-07-06 20:56:19 +08:00
|
|
|
/>
|
2021-11-05 22:18:04 +08:00
|
|
|
</Styled.FormElementCenter>
|
|
|
|
</Styled.Col>
|
|
|
|
<Styled.Col>
|
|
|
|
<Styled.FormElementCenter>
|
2021-05-01 03:06:28 +08:00
|
|
|
{displaySettingsStatus(settings.raiseHandPushAlerts)}
|
2020-07-06 20:56:19 +08:00
|
|
|
<Toggle
|
|
|
|
icons={false}
|
|
|
|
defaultChecked={settings.raiseHandPushAlerts}
|
|
|
|
onChange={() => this.handleToggle('raiseHandPushAlerts')}
|
|
|
|
ariaLabel={`${intl.formatMessage(intlMessages.raiseHandLabel)} ${intl.formatMessage(intlMessages.pushAlertLabel)}`}
|
2021-05-01 03:06:28 +08:00
|
|
|
showToggleLabel={showToggleLabel}
|
2020-07-06 20:56:19 +08:00
|
|
|
/>
|
2021-11-05 22:18:04 +08:00
|
|
|
</Styled.FormElementCenter>
|
|
|
|
</Styled.Col>
|
|
|
|
</Styled.Row>
|
2020-07-06 20:56:19 +08:00
|
|
|
) : null}
|
2020-03-19 22:19:40 +08:00
|
|
|
|
2021-11-05 22:18:04 +08:00
|
|
|
</Styled.Form>
|
2020-03-19 22:19:40 +08:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default injectIntl(NotificationMenu);
|