2018-05-01 03:18:29 +08:00
|
|
|
import React, { Component } from 'react';
|
|
|
|
import { defineMessages, injectIntl } from 'react-intl';
|
|
|
|
import Modal from '/imports/ui/components/modal/simple/component';
|
|
|
|
import _ from 'lodash';
|
|
|
|
import { styles } from './styles';
|
2018-05-03 02:55:46 +08:00
|
|
|
import deviceInfo from '/imports/utils/deviceInfo';
|
2018-05-01 03:18:29 +08:00
|
|
|
|
|
|
|
const intlMessages = defineMessages({
|
|
|
|
title: {
|
|
|
|
id: 'app.shortcut-help.title',
|
|
|
|
},
|
|
|
|
closeLabel: {
|
|
|
|
id: 'app.shortcut-help.closeLabel',
|
|
|
|
},
|
|
|
|
closeDesc: {
|
|
|
|
id: 'app.shortcut-help.closeDesc',
|
|
|
|
},
|
2018-05-03 10:20:38 +08:00
|
|
|
accessKeyNotAvailable: {
|
|
|
|
id: 'app.shortcut-help.accessKeyNotAvailable',
|
|
|
|
},
|
|
|
|
comboLabel: {
|
|
|
|
id: 'app.shortcut-help.comboLabel',
|
|
|
|
},
|
|
|
|
functionLabel: {
|
|
|
|
id: 'app.shortcut-help.functionLabel',
|
|
|
|
},
|
2018-05-01 03:18:29 +08:00
|
|
|
openOptions: {
|
|
|
|
id: 'app.shortcut-help.openOptions',
|
|
|
|
},
|
|
|
|
toggleUserList: {
|
|
|
|
id: 'app.shortcut-help.toggleUserList',
|
|
|
|
},
|
|
|
|
toggleMute: {
|
|
|
|
id: 'app.shortcut-help.toggleMute',
|
|
|
|
},
|
|
|
|
togglePublicChat: {
|
|
|
|
id: 'app.shortcut-help.togglePublicChat',
|
|
|
|
},
|
|
|
|
hidePrivateChat: {
|
|
|
|
id: 'app.shortcut-help.hidePrivateChat',
|
|
|
|
},
|
|
|
|
closePrivateChat: {
|
|
|
|
id: 'app.shortcut-help.closePrivateChat',
|
|
|
|
},
|
|
|
|
openActions: {
|
|
|
|
id: 'app.shortcut-help.openActions',
|
|
|
|
},
|
|
|
|
openStatus: {
|
|
|
|
id: 'app.shortcut-help.openStatus',
|
|
|
|
},
|
|
|
|
joinAudio: {
|
|
|
|
id: 'app.audio.joinAudio',
|
|
|
|
},
|
|
|
|
leaveAudio: {
|
|
|
|
id: 'app.audio.leaveAudio',
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2018-05-02 08:02:45 +08:00
|
|
|
const SHORTCUTS_CONFIG = Meteor.settings.public.app.shortcuts;
|
|
|
|
|
2018-05-01 03:18:29 +08:00
|
|
|
class ShortcutHelpComponent extends Component {
|
|
|
|
render() {
|
|
|
|
const { intl } = this.props;
|
|
|
|
const shortcuts = Object.values(SHORTCUTS_CONFIG);
|
|
|
|
|
2018-05-03 10:20:38 +08:00
|
|
|
let accessMod = null;
|
2018-05-03 02:55:46 +08:00
|
|
|
|
|
|
|
if (deviceInfo.osType().isMac) {
|
|
|
|
accessMod = 'Control + Alt';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (deviceInfo.osType().isWindows || deviceInfo.osType().isLinux) {
|
2018-05-03 10:20:38 +08:00
|
|
|
accessMod = deviceInfo.browserType().isFirefox ? 'Alt + Shift' : accessMod;
|
|
|
|
accessMod = deviceInfo.browserType().isChrome ? 'Alt' : accessMod;
|
2018-05-03 02:55:46 +08:00
|
|
|
}
|
|
|
|
|
2018-05-01 03:18:29 +08:00
|
|
|
return (
|
|
|
|
<Modal
|
|
|
|
title={intl.formatMessage(intlMessages.title)}
|
|
|
|
dismiss={{
|
|
|
|
label: intl.formatMessage(intlMessages.closeLabel),
|
|
|
|
description: intl.formatMessage(intlMessages.closeDesc),
|
|
|
|
}}
|
|
|
|
>
|
2018-05-03 10:20:38 +08:00
|
|
|
{ !accessMod ? <p>{intl.formatMessage(intlMessages.accessKeyNotAvailable)}</p> :
|
2018-05-03 02:55:46 +08:00
|
|
|
<span>
|
|
|
|
<table className={styles.shortcutTable}>
|
|
|
|
<tbody>
|
|
|
|
<tr>
|
2018-05-03 10:20:38 +08:00
|
|
|
<th>{intl.formatMessage(intlMessages.comboLabel)}</th>
|
|
|
|
<th>{intl.formatMessage(intlMessages.functionLabel)}</th>
|
2018-05-01 03:18:29 +08:00
|
|
|
</tr>
|
2018-05-03 02:55:46 +08:00
|
|
|
{shortcuts.map(shortcut => (
|
|
|
|
<tr key={_.uniqueId('hotkey-item-')}>
|
|
|
|
<td className={styles.keyCell}>{`${accessMod} + ${shortcut.accesskey}`}</td>
|
|
|
|
<td className={styles.descCell}>{intl.formatMessage(intlMessages[`${shortcut.descId}`])}</td>
|
|
|
|
</tr>
|
|
|
|
))}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</span>
|
|
|
|
}
|
2018-05-01 03:18:29 +08:00
|
|
|
</Modal>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default injectIntl(ShortcutHelpComponent);
|