2017-03-23 04:10:49 +08:00
|
|
|
import React, { Component } from 'react';
|
2023-03-20 21:08:35 +08:00
|
|
|
import ModalFullscreen from '/imports/ui/components/common/modal/fullscreen/component';
|
2020-05-26 04:00:13 +08:00
|
|
|
import { defineMessages, injectIntl } from 'react-intl';
|
2018-02-06 21:33:48 +08:00
|
|
|
import DataSaving from '/imports/ui/components/settings/submenus/data-saving/component';
|
2019-01-04 01:14:45 +08:00
|
|
|
import Application from '/imports/ui/components/settings/submenus/application/component';
|
2020-03-19 22:19:40 +08:00
|
|
|
import Notification from '/imports/ui/components/settings/submenus/notification/component';
|
2023-11-30 23:10:36 +08:00
|
|
|
import Transcription from '/imports/ui/components/settings/submenus/transcription/component';
|
2023-02-17 21:17:19 +08:00
|
|
|
import { clone } from 'radash';
|
2017-10-28 03:29:48 +08:00
|
|
|
import PropTypes from 'prop-types';
|
2021-11-05 20:10:12 +08:00
|
|
|
import Styled from './styles';
|
2022-09-09 01:25:29 +08:00
|
|
|
import { formatLocaleCode } from '/imports/utils/string-utils';
|
2017-01-27 23:41:11 +08:00
|
|
|
|
2017-04-18 02:19:27 +08:00
|
|
|
const intlMessages = defineMessages({
|
|
|
|
appTabLabel: {
|
|
|
|
id: 'app.settings.applicationTab.label',
|
|
|
|
description: 'label for application tab',
|
|
|
|
},
|
|
|
|
audioTabLabel: {
|
|
|
|
id: 'app.settings.audioTab.label',
|
|
|
|
description: 'label for audio tab',
|
|
|
|
},
|
|
|
|
videoTabLabel: {
|
|
|
|
id: 'app.settings.videoTab.label',
|
|
|
|
description: 'label for video tab',
|
|
|
|
},
|
|
|
|
usersTabLabel: {
|
|
|
|
id: 'app.settings.usersTab.label',
|
|
|
|
description: 'label for participants tab',
|
|
|
|
},
|
2017-04-28 23:56:27 +08:00
|
|
|
SettingsLabel: {
|
|
|
|
id: 'app.settings.main.label',
|
|
|
|
description: 'General settings label',
|
|
|
|
},
|
|
|
|
CancelLabel: {
|
|
|
|
id: 'app.settings.main.cancel.label',
|
|
|
|
description: 'Discard the changes and close the settings menu',
|
|
|
|
},
|
2017-04-29 03:13:42 +08:00
|
|
|
CancelLabelDesc: {
|
|
|
|
id: 'app.settings.main.cancel.label.description',
|
|
|
|
description: 'Settings modal cancel button description',
|
|
|
|
},
|
2017-04-28 23:56:27 +08:00
|
|
|
SaveLabel: {
|
|
|
|
id: 'app.settings.main.save.label',
|
|
|
|
description: 'Save the changes and close the settings menu',
|
|
|
|
},
|
2017-04-29 03:13:42 +08:00
|
|
|
SaveLabelDesc: {
|
|
|
|
id: 'app.settings.main.save.label.description',
|
|
|
|
description: 'Settings modal save button label',
|
|
|
|
},
|
2021-02-01 23:57:43 +08:00
|
|
|
notificationLabel: {
|
|
|
|
id: 'app.submenu.notification.SectionTitle', // set menu label identical to section title
|
|
|
|
description: 'label for notification tab',
|
|
|
|
},
|
2018-02-01 19:31:17 +08:00
|
|
|
dataSavingLabel: {
|
2018-02-06 21:33:48 +08:00
|
|
|
id: 'app.settings.dataSavingTab.label',
|
2018-01-30 19:20:51 +08:00
|
|
|
description: 'label for data savings tab',
|
|
|
|
},
|
2023-11-30 23:10:36 +08:00
|
|
|
transcriptionLabel: {
|
|
|
|
id: 'app.settings.transcriptionTab.label',
|
|
|
|
description: 'label for transcriptions tab',
|
|
|
|
},
|
2019-05-08 23:50:00 +08:00
|
|
|
savedAlertLabel: {
|
|
|
|
id: 'app.settings.save-notification.label',
|
|
|
|
description: 'label shown in toast when settings are saved',
|
|
|
|
},
|
2021-05-01 03:06:28 +08:00
|
|
|
on: {
|
|
|
|
id: 'app.switch.onLabel',
|
|
|
|
description: 'label for toggle switch on state',
|
|
|
|
},
|
|
|
|
off: {
|
|
|
|
id: 'app.switch.offLabel',
|
|
|
|
description: 'label for toggle switch off state',
|
|
|
|
},
|
2017-04-18 02:19:27 +08:00
|
|
|
});
|
|
|
|
|
2017-01-27 23:41:11 +08:00
|
|
|
const propTypes = {
|
2021-01-28 03:50:48 +08:00
|
|
|
intl: PropTypes.shape({
|
|
|
|
formatMessage: PropTypes.func.isRequired,
|
|
|
|
}).isRequired,
|
2019-01-04 01:14:45 +08:00
|
|
|
dataSaving: PropTypes.shape({
|
|
|
|
viewParticipantsWebcams: PropTypes.bool,
|
|
|
|
viewScreenshare: PropTypes.bool,
|
|
|
|
}).isRequired,
|
2023-11-30 23:10:36 +08:00
|
|
|
transcription: PropTypes.shape({
|
|
|
|
partialUtterances: PropTypes.bool,
|
|
|
|
minUtteraceLength: PropTypes.number,
|
|
|
|
}).isRequired,
|
2019-01-04 01:14:45 +08:00
|
|
|
application: PropTypes.shape({
|
|
|
|
chatAudioAlerts: PropTypes.bool,
|
|
|
|
chatPushAlerts: PropTypes.bool,
|
2019-11-06 04:08:26 +08:00
|
|
|
userJoinAudioAlerts: PropTypes.bool,
|
2021-08-21 01:15:29 +08:00
|
|
|
userLeaveAudioAlerts: PropTypes.bool,
|
|
|
|
userLeavePushAlerts: PropTypes.bool,
|
2020-07-16 02:50:56 +08:00
|
|
|
guestWaitingAudioAlerts: PropTypes.bool,
|
2021-03-04 03:20:19 +08:00
|
|
|
guestWaitingPushAlerts: PropTypes.bool,
|
2020-08-29 03:29:45 +08:00
|
|
|
paginationEnabled: PropTypes.bool,
|
2022-04-09 03:05:29 +08:00
|
|
|
darkTheme: PropTypes.bool,
|
2019-01-04 01:14:45 +08:00
|
|
|
fallbackLocale: PropTypes.string,
|
|
|
|
fontSize: PropTypes.string,
|
|
|
|
locale: PropTypes.string,
|
2021-01-23 03:30:42 +08:00
|
|
|
microphoneConstraints: PropTypes.objectOf(Object),
|
2019-01-04 01:14:45 +08:00
|
|
|
}).isRequired,
|
2017-10-28 03:29:48 +08:00
|
|
|
updateSettings: PropTypes.func.isRequired,
|
2019-01-04 01:14:45 +08:00
|
|
|
availableLocales: PropTypes.objectOf(PropTypes.array).isRequired,
|
2021-05-01 03:06:28 +08:00
|
|
|
showToggleLabel: PropTypes.bool.isRequired,
|
2023-08-11 21:14:16 +08:00
|
|
|
isReactionsEnabled: PropTypes.bool.isRequired,
|
2023-11-30 23:10:36 +08:00
|
|
|
isGladiaEnabled: PropTypes.bool.isRequired,
|
2017-01-27 23:41:11 +08:00
|
|
|
};
|
2016-05-06 05:14:39 +08:00
|
|
|
|
2017-04-18 02:19:27 +08:00
|
|
|
class Settings extends Component {
|
2017-10-11 06:08:51 +08:00
|
|
|
static setHtmlFontSize(size) {
|
|
|
|
document.getElementsByTagName('html')[0].style.fontSize = size;
|
|
|
|
}
|
2019-01-04 01:14:45 +08:00
|
|
|
|
2016-05-06 05:14:39 +08:00
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
2017-02-22 04:29:36 +08:00
|
|
|
|
2017-12-19 19:13:37 +08:00
|
|
|
const {
|
2023-11-30 23:10:36 +08:00
|
|
|
dataSaving, application, transcription, selectedTab,
|
2017-12-19 19:13:37 +08:00
|
|
|
} = props;
|
2017-03-09 22:34:33 +08:00
|
|
|
|
2017-01-27 23:41:11 +08:00
|
|
|
this.state = {
|
|
|
|
current: {
|
2023-02-17 21:17:19 +08:00
|
|
|
dataSaving: clone(dataSaving),
|
|
|
|
application: clone(application),
|
2023-11-30 23:10:36 +08:00
|
|
|
transcription: clone(transcription),
|
2017-01-27 23:41:11 +08:00
|
|
|
},
|
2017-02-25 04:19:53 +08:00
|
|
|
saved: {
|
2023-02-17 21:17:19 +08:00
|
|
|
dataSaving: clone(dataSaving),
|
|
|
|
application: clone(application),
|
2023-11-30 23:10:36 +08:00
|
|
|
transcription: clone(transcription),
|
2017-02-25 04:19:53 +08:00
|
|
|
},
|
2023-02-17 21:17:19 +08:00
|
|
|
selectedTab: Number.isFinite(selectedTab) && selectedTab >= 0 && selectedTab <= 2
|
2021-10-19 04:52:59 +08:00
|
|
|
? selectedTab
|
|
|
|
: 0,
|
2016-05-06 05:14:39 +08:00
|
|
|
};
|
|
|
|
|
2017-03-29 02:41:48 +08:00
|
|
|
this.updateSettings = props.updateSettings;
|
2017-01-27 23:41:11 +08:00
|
|
|
this.handleUpdateSettings = this.handleUpdateSettings.bind(this);
|
2017-02-25 04:19:53 +08:00
|
|
|
this.handleSelectTab = this.handleSelectTab.bind(this);
|
2021-05-01 03:06:28 +08:00
|
|
|
this.displaySettingsStatus = this.displaySettingsStatus.bind(this);
|
2016-07-12 01:43:42 +08:00
|
|
|
}
|
|
|
|
|
2020-05-14 01:05:59 +08:00
|
|
|
componentDidMount() {
|
2019-01-04 01:14:45 +08:00
|
|
|
const { availableLocales } = this.props;
|
2021-01-28 03:50:48 +08:00
|
|
|
|
2019-01-04 01:14:45 +08:00
|
|
|
availableLocales.then((locales) => {
|
2021-01-28 03:50:48 +08:00
|
|
|
this.setState({ allLocales: locales });
|
2017-04-06 20:36:59 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-01-27 23:41:11 +08:00
|
|
|
handleUpdateSettings(key, newSettings) {
|
2017-06-03 03:25:02 +08:00
|
|
|
const settings = this.state;
|
2017-01-27 23:41:11 +08:00
|
|
|
settings.current[key] = newSettings;
|
2017-02-25 04:19:53 +08:00
|
|
|
this.setState(settings);
|
2017-01-27 23:41:11 +08:00
|
|
|
}
|
|
|
|
|
2017-02-25 04:19:53 +08:00
|
|
|
handleSelectTab(tab) {
|
2017-01-27 23:41:11 +08:00
|
|
|
this.setState({
|
|
|
|
selectedTab: tab,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-12-17 00:02:46 +08:00
|
|
|
displaySettingsStatus(status, textOnly = false) {
|
2021-05-01 03:06:28 +08:00
|
|
|
const { intl } = this.props;
|
2022-12-17 00:02:46 +08:00
|
|
|
if (textOnly) {
|
|
|
|
return status ? intl.formatMessage(intlMessages.on)
|
2023-05-17 01:39:56 +08:00
|
|
|
: intl.formatMessage(intlMessages.off);
|
2022-12-17 00:02:46 +08:00
|
|
|
}
|
2021-05-01 03:06:28 +08:00
|
|
|
return (
|
2022-12-17 00:02:46 +08:00
|
|
|
<Styled.ToggleLabel aria-hidden>
|
2021-05-01 03:06:28 +08:00
|
|
|
{status ? intl.formatMessage(intlMessages.on)
|
|
|
|
: intl.formatMessage(intlMessages.off)}
|
2021-11-05 20:10:12 +08:00
|
|
|
</Styled.ToggleLabel>
|
2021-05-01 03:06:28 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2017-01-27 23:41:11 +08:00
|
|
|
renderModalContent() {
|
2019-01-26 02:19:54 +08:00
|
|
|
const {
|
|
|
|
intl,
|
2020-07-06 20:56:19 +08:00
|
|
|
isModerator,
|
2022-02-26 01:56:03 +08:00
|
|
|
isPresenter,
|
2021-05-30 23:09:33 +08:00
|
|
|
showGuestNotification,
|
2021-05-01 03:06:28 +08:00
|
|
|
showToggleLabel,
|
2021-08-05 19:03:24 +08:00
|
|
|
layoutContextDispatch,
|
2021-06-22 04:28:51 +08:00
|
|
|
selectedLayout,
|
2022-03-16 00:58:15 +08:00
|
|
|
isScreenSharingEnabled,
|
|
|
|
isVideoEnabled,
|
2023-08-11 21:14:16 +08:00
|
|
|
isReactionsEnabled,
|
2023-11-30 23:10:36 +08:00
|
|
|
isGladiaEnabled,
|
2019-01-26 02:19:54 +08:00
|
|
|
} = this.props;
|
|
|
|
|
2019-01-04 01:14:45 +08:00
|
|
|
const {
|
|
|
|
selectedTab,
|
|
|
|
current,
|
2021-01-30 00:17:35 +08:00
|
|
|
allLocales,
|
2019-01-04 01:14:45 +08:00
|
|
|
} = this.state;
|
2019-01-26 02:19:54 +08:00
|
|
|
|
2022-03-16 00:58:15 +08:00
|
|
|
const isDataSavingTabEnabled = isScreenSharingEnabled || isVideoEnabled;
|
|
|
|
|
2017-01-27 23:41:11 +08:00
|
|
|
return (
|
2021-11-05 20:10:12 +08:00
|
|
|
<Styled.SettingsTabs
|
2017-02-25 04:19:53 +08:00
|
|
|
onSelect={this.handleSelectTab}
|
2019-01-04 01:14:45 +08:00
|
|
|
selectedIndex={selectedTab}
|
2017-04-18 02:19:27 +08:00
|
|
|
role="presentation"
|
2017-01-27 23:41:11 +08:00
|
|
|
>
|
2021-11-05 20:10:12 +08:00
|
|
|
<Styled.SettingsTabList>
|
|
|
|
<Styled.SettingsTabSelector
|
2017-12-19 19:13:37 +08:00
|
|
|
aria-labelledby="appTab"
|
2021-11-05 20:10:12 +08:00
|
|
|
selectedClassName="is-selected"
|
2017-12-19 19:13:37 +08:00
|
|
|
>
|
2021-11-05 20:10:12 +08:00
|
|
|
<Styled.SettingsIcon iconName="application" />
|
2017-04-18 02:19:27 +08:00
|
|
|
<span id="appTab">{intl.formatMessage(intlMessages.appTabLabel)}</span>
|
2021-11-05 20:10:12 +08:00
|
|
|
</Styled.SettingsTabSelector>
|
|
|
|
<Styled.SettingsTabSelector
|
|
|
|
selectedClassName="is-selected"
|
2020-03-19 22:19:40 +08:00
|
|
|
>
|
2021-11-05 20:10:12 +08:00
|
|
|
<Styled.SettingsIcon iconName="alert" />
|
2021-02-01 23:57:43 +08:00
|
|
|
<span id="notificationTab">{intl.formatMessage(intlMessages.notificationLabel)}</span>
|
2021-11-05 20:10:12 +08:00
|
|
|
</Styled.SettingsTabSelector>
|
2022-03-16 00:58:15 +08:00
|
|
|
{isDataSavingTabEnabled
|
|
|
|
? (
|
|
|
|
<Styled.SettingsTabSelector
|
|
|
|
aria-labelledby="dataSavingTab"
|
|
|
|
selectedClassName="is-selected"
|
|
|
|
>
|
|
|
|
<Styled.SettingsIcon iconName="network" />
|
|
|
|
<span id="dataSaving">{intl.formatMessage(intlMessages.dataSavingLabel)}</span>
|
|
|
|
</Styled.SettingsTabSelector>
|
|
|
|
)
|
|
|
|
: null}
|
2023-11-30 23:10:36 +08:00
|
|
|
{isGladiaEnabled
|
|
|
|
? (
|
|
|
|
<Styled.SettingsTabSelector
|
|
|
|
aria-labelledby="transcriptionTab"
|
|
|
|
selectedClassName="is-selected"
|
|
|
|
>
|
|
|
|
<Styled.SettingsIcon iconName="closed_caption" />
|
|
|
|
<span id="transcriptionTab">{intl.formatMessage(intlMessages.transcriptionLabel)}</span>
|
|
|
|
</Styled.SettingsTabSelector>
|
|
|
|
)
|
|
|
|
: null}
|
2021-11-05 20:10:12 +08:00
|
|
|
</Styled.SettingsTabList>
|
|
|
|
<Styled.SettingsTabPanel selectedClassName="is-selected">
|
2017-03-09 22:34:33 +08:00
|
|
|
<Application
|
2021-01-30 00:17:35 +08:00
|
|
|
allLocales={allLocales}
|
2017-03-09 22:34:33 +08:00
|
|
|
handleUpdateSettings={this.handleUpdateSettings}
|
2019-01-04 01:14:45 +08:00
|
|
|
settings={current.application}
|
2021-05-01 03:06:28 +08:00
|
|
|
showToggleLabel={showToggleLabel}
|
|
|
|
displaySettingsStatus={this.displaySettingsStatus}
|
2021-08-05 19:03:24 +08:00
|
|
|
layoutContextDispatch={layoutContextDispatch}
|
2021-06-22 04:28:51 +08:00
|
|
|
selectedLayout={selectedLayout}
|
2022-02-26 01:56:03 +08:00
|
|
|
isPresenter={isPresenter}
|
2023-08-11 21:14:16 +08:00
|
|
|
isReactionsEnabled={isReactionsEnabled}
|
2017-06-03 03:25:02 +08:00
|
|
|
/>
|
2021-11-05 20:10:12 +08:00
|
|
|
</Styled.SettingsTabPanel>
|
|
|
|
<Styled.SettingsTabPanel selectedClassName="is-selected">
|
2020-03-19 22:19:40 +08:00
|
|
|
<Notification
|
|
|
|
handleUpdateSettings={this.handleUpdateSettings}
|
|
|
|
settings={current.application}
|
2021-05-30 23:09:33 +08:00
|
|
|
showGuestNotification={showGuestNotification}
|
2021-05-01 03:06:28 +08:00
|
|
|
showToggleLabel={showToggleLabel}
|
|
|
|
displaySettingsStatus={this.displaySettingsStatus}
|
2020-07-06 20:56:19 +08:00
|
|
|
{...{ isModerator }}
|
2020-03-19 22:19:40 +08:00
|
|
|
/>
|
2021-11-05 20:10:12 +08:00
|
|
|
</Styled.SettingsTabPanel>
|
2022-03-16 00:58:15 +08:00
|
|
|
{isDataSavingTabEnabled
|
|
|
|
? (
|
|
|
|
<Styled.SettingsTabPanel selectedClassName="is-selected">
|
|
|
|
<DataSaving
|
|
|
|
settings={current.dataSaving}
|
|
|
|
handleUpdateSettings={this.handleUpdateSettings}
|
|
|
|
showToggleLabel={showToggleLabel}
|
|
|
|
displaySettingsStatus={this.displaySettingsStatus}
|
|
|
|
isScreenSharingEnabled={isScreenSharingEnabled}
|
|
|
|
isVideoEnabled={isVideoEnabled}
|
|
|
|
/>
|
|
|
|
</Styled.SettingsTabPanel>
|
|
|
|
)
|
|
|
|
: null}
|
2023-11-30 23:10:36 +08:00
|
|
|
{isGladiaEnabled
|
|
|
|
? (
|
|
|
|
<Styled.SettingsTabPanel selectedClassName="is-selected">
|
|
|
|
<Transcription
|
|
|
|
handleUpdateSettings={this.handleUpdateSettings}
|
|
|
|
settings={current.transcription}
|
|
|
|
displaySettingsStatus={this.displaySettingsStatus}
|
|
|
|
/>
|
|
|
|
</Styled.SettingsTabPanel>
|
|
|
|
)
|
|
|
|
: null}
|
2021-11-05 20:10:12 +08:00
|
|
|
</Styled.SettingsTabs>
|
2017-01-27 23:41:11 +08:00
|
|
|
);
|
|
|
|
}
|
2019-01-04 01:14:45 +08:00
|
|
|
|
2017-10-11 06:08:51 +08:00
|
|
|
render() {
|
2018-02-07 04:06:52 +08:00
|
|
|
const {
|
|
|
|
intl,
|
2023-03-21 21:00:46 +08:00
|
|
|
setIsOpen,
|
2023-04-12 23:51:23 +08:00
|
|
|
isOpen,
|
|
|
|
priority,
|
2018-02-07 04:06:52 +08:00
|
|
|
} = this.props;
|
2019-01-04 01:14:45 +08:00
|
|
|
const {
|
|
|
|
current,
|
|
|
|
saved,
|
|
|
|
} = this.state;
|
2017-10-11 06:08:51 +08:00
|
|
|
return (
|
2023-03-20 21:08:35 +08:00
|
|
|
<ModalFullscreen
|
2017-10-11 06:08:51 +08:00
|
|
|
title={intl.formatMessage(intlMessages.SettingsLabel)}
|
|
|
|
confirm={{
|
2018-04-17 01:41:23 +08:00
|
|
|
callback: () => {
|
2022-09-29 00:48:27 +08:00
|
|
|
this.updateSettings(current, intlMessages.savedAlertLabel);
|
2022-09-09 01:25:29 +08:00
|
|
|
|
|
|
|
if (saved.application.locale !== current.application.locale) {
|
|
|
|
const { language } = formatLocaleCode(saved.application.locale);
|
|
|
|
document.body.classList.remove(`lang-${language}`);
|
|
|
|
}
|
|
|
|
|
2023-03-21 21:00:46 +08:00
|
|
|
/* We need to use setIsOpen(false) here to prevent submenu state updates,
|
2018-04-17 23:06:19 +08:00
|
|
|
* from re-opening the modal.
|
|
|
|
*/
|
2023-03-21 21:00:46 +08:00
|
|
|
setIsOpen(false);
|
2018-04-17 01:41:23 +08:00
|
|
|
},
|
2017-10-11 06:08:51 +08:00
|
|
|
label: intl.formatMessage(intlMessages.SaveLabel),
|
|
|
|
description: intl.formatMessage(intlMessages.SaveLabelDesc),
|
|
|
|
}}
|
|
|
|
dismiss={{
|
2018-06-23 01:30:40 +08:00
|
|
|
callback: () => {
|
2019-01-04 01:14:45 +08:00
|
|
|
Settings.setHtmlFontSize(saved.application.fontSize);
|
2021-04-20 19:51:15 +08:00
|
|
|
document.getElementsByTagName('html')[0].lang = saved.application.locale;
|
2023-03-21 21:00:46 +08:00
|
|
|
setIsOpen(false);
|
2018-06-23 01:30:40 +08:00
|
|
|
},
|
2017-10-11 06:08:51 +08:00
|
|
|
label: intl.formatMessage(intlMessages.CancelLabel),
|
|
|
|
description: intl.formatMessage(intlMessages.CancelLabelDesc),
|
|
|
|
}}
|
2023-04-12 23:51:23 +08:00
|
|
|
{...{
|
|
|
|
isOpen,
|
|
|
|
priority,
|
|
|
|
}}
|
2017-10-11 06:08:51 +08:00
|
|
|
>
|
|
|
|
{this.renderModalContent()}
|
2023-03-20 21:08:35 +08:00
|
|
|
</ModalFullscreen>
|
2017-10-11 06:08:51 +08:00
|
|
|
);
|
|
|
|
}
|
2017-01-27 23:41:11 +08:00
|
|
|
}
|
|
|
|
|
2017-02-16 02:49:40 +08:00
|
|
|
Settings.propTypes = propTypes;
|
2023-03-21 21:00:46 +08:00
|
|
|
export default injectIntl(Settings);
|