2018-11-01 02:51:56 +08:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import { defineMessages, injectIntl, intlShape } from 'react-intl';
|
2018-06-12 07:12:43 +08:00
|
|
|
import browser from 'browser-detect';
|
2018-05-01 03:18:29 +08:00
|
|
|
import Modal from '/imports/ui/components/modal/simple/component';
|
|
|
|
import _ from 'lodash';
|
|
|
|
import { styles } from './styles';
|
2018-11-01 02:51:56 +08:00
|
|
|
import withShortcutHelper from './service';
|
2018-05-01 03:18:29 +08:00
|
|
|
|
|
|
|
const intlMessages = defineMessages({
|
|
|
|
title: {
|
|
|
|
id: 'app.shortcut-help.title',
|
2018-05-03 11:33:28 +08:00
|
|
|
description: 'modal title label',
|
2018-05-01 03:18:29 +08:00
|
|
|
},
|
|
|
|
closeLabel: {
|
|
|
|
id: 'app.shortcut-help.closeLabel',
|
2018-05-03 11:33:28 +08:00
|
|
|
description: 'label for close button',
|
2018-05-01 03:18:29 +08:00
|
|
|
},
|
|
|
|
closeDesc: {
|
|
|
|
id: 'app.shortcut-help.closeDesc',
|
2018-05-03 11:33:28 +08:00
|
|
|
description: 'description for close button',
|
2018-05-01 03:18:29 +08:00
|
|
|
},
|
2018-05-03 10:20:38 +08:00
|
|
|
accessKeyNotAvailable: {
|
|
|
|
id: 'app.shortcut-help.accessKeyNotAvailable',
|
2018-05-03 11:33:28 +08:00
|
|
|
description: 'message shown in place of access key table if not supported',
|
2018-05-03 10:20:38 +08:00
|
|
|
},
|
|
|
|
comboLabel: {
|
|
|
|
id: 'app.shortcut-help.comboLabel',
|
2018-05-03 11:33:28 +08:00
|
|
|
description: 'heading for key combo column',
|
2018-05-03 10:20:38 +08:00
|
|
|
},
|
|
|
|
functionLabel: {
|
|
|
|
id: 'app.shortcut-help.functionLabel',
|
2018-05-03 11:33:28 +08:00
|
|
|
description: 'heading for shortcut function column',
|
2018-05-03 10:20:38 +08:00
|
|
|
},
|
2018-05-01 03:18:29 +08:00
|
|
|
openOptions: {
|
|
|
|
id: 'app.shortcut-help.openOptions',
|
2018-05-03 11:33:28 +08:00
|
|
|
description: 'describes the open options shortcut',
|
2018-05-01 03:18:29 +08:00
|
|
|
},
|
|
|
|
toggleUserList: {
|
|
|
|
id: 'app.shortcut-help.toggleUserList',
|
2018-05-03 11:33:28 +08:00
|
|
|
description: 'describes the toggle userlist shortcut',
|
2018-05-01 03:18:29 +08:00
|
|
|
},
|
|
|
|
toggleMute: {
|
|
|
|
id: 'app.shortcut-help.toggleMute',
|
2018-05-03 11:33:28 +08:00
|
|
|
description: 'describes the toggle mute shortcut',
|
2018-05-01 03:18:29 +08:00
|
|
|
},
|
|
|
|
togglePublicChat: {
|
|
|
|
id: 'app.shortcut-help.togglePublicChat',
|
2018-05-03 11:33:28 +08:00
|
|
|
description: 'describes the toggle public chat shortcut',
|
2018-05-01 03:18:29 +08:00
|
|
|
},
|
|
|
|
hidePrivateChat: {
|
|
|
|
id: 'app.shortcut-help.hidePrivateChat',
|
2018-05-03 11:33:28 +08:00
|
|
|
description: 'describes the hide public chat shortcut',
|
2018-05-01 03:18:29 +08:00
|
|
|
},
|
|
|
|
closePrivateChat: {
|
|
|
|
id: 'app.shortcut-help.closePrivateChat',
|
2018-05-03 11:33:28 +08:00
|
|
|
description: 'describes the close private chat shortcut',
|
2018-05-01 03:18:29 +08:00
|
|
|
},
|
|
|
|
openActions: {
|
|
|
|
id: 'app.shortcut-help.openActions',
|
2018-05-03 11:33:28 +08:00
|
|
|
description: 'describes the open actions shortcut',
|
2018-05-01 03:18:29 +08:00
|
|
|
},
|
|
|
|
openStatus: {
|
|
|
|
id: 'app.shortcut-help.openStatus',
|
2018-05-03 11:33:28 +08:00
|
|
|
description: 'describes the open status shortcut',
|
2018-05-01 03:18:29 +08:00
|
|
|
},
|
|
|
|
joinAudio: {
|
|
|
|
id: 'app.audio.joinAudio',
|
2018-05-03 11:33:28 +08:00
|
|
|
description: 'describes the join audio shortcut',
|
2018-05-01 03:18:29 +08:00
|
|
|
},
|
|
|
|
leaveAudio: {
|
|
|
|
id: 'app.audio.leaveAudio',
|
2018-05-03 11:33:28 +08:00
|
|
|
description: 'describes the leave audio shortcut',
|
2018-05-01 03:18:29 +08:00
|
|
|
},
|
2019-04-12 08:08:14 +08:00
|
|
|
togglePan: {
|
|
|
|
id: 'app.shortcut-help.togglePan',
|
|
|
|
description: 'describes the toggle pan shortcut',
|
|
|
|
},
|
2019-04-13 11:48:21 +08:00
|
|
|
nextSlideDesc: {
|
|
|
|
id: 'app.shortcut-help.nextSlideDesc',
|
|
|
|
description: 'describes the next slide shortcut',
|
|
|
|
},
|
|
|
|
previousSlideDesc: {
|
|
|
|
id: 'app.shortcut-help.previousSlideDesc',
|
|
|
|
description: 'describes the previous slide shortcut',
|
|
|
|
},
|
2018-05-01 03:18:29 +08:00
|
|
|
});
|
|
|
|
|
2019-07-18 05:00:33 +08:00
|
|
|
const CHAT_CONFIG = Meteor.settings.public.chat;
|
|
|
|
const CHAT_ENABLED = CHAT_CONFIG.enabled;
|
|
|
|
|
2018-11-01 02:51:56 +08:00
|
|
|
const ShortcutHelpComponent = (props) => {
|
|
|
|
const { intl, shortcuts } = props;
|
|
|
|
const { name } = browser();
|
2018-05-02 08:02:45 +08:00
|
|
|
|
2018-11-01 02:51:56 +08:00
|
|
|
let accessMod = null;
|
2018-05-01 03:18:29 +08:00
|
|
|
|
2018-11-01 02:51:56 +08:00
|
|
|
switch (name) {
|
|
|
|
case 'chrome':
|
|
|
|
case 'edge':
|
|
|
|
accessMod = 'Alt';
|
|
|
|
break;
|
|
|
|
case 'firefox':
|
|
|
|
accessMod = 'Alt + Shift';
|
|
|
|
break;
|
|
|
|
case 'safari':
|
|
|
|
case 'crios':
|
|
|
|
case 'fxios':
|
|
|
|
accessMod = 'Control + Alt';
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2018-05-03 02:55:46 +08:00
|
|
|
|
2019-07-18 05:00:33 +08:00
|
|
|
const shortcutItems = shortcuts.map((shortcut) => {
|
|
|
|
if (!CHAT_ENABLED && shortcut.descId.indexOf('Chat') !== -1) return null;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<tr key={_.uniqueId('hotkey-item-')}>
|
|
|
|
<td className={styles.keyCell}>{`${accessMod} + ${shortcut.accesskey}`}</td>
|
|
|
|
<td className={styles.descCell}>{intl.formatMessage(intlMessages[`${shortcut.descId}`])}</td>
|
|
|
|
</tr>
|
|
|
|
);
|
|
|
|
});
|
2019-04-12 08:08:14 +08:00
|
|
|
|
|
|
|
shortcutItems.push((
|
|
|
|
<tr key={_.uniqueId('hotkey-item-')}>
|
|
|
|
<td className={styles.keyCell}>Spacebar</td>
|
|
|
|
<td className={styles.descCell}>{intl.formatMessage(intlMessages.togglePan)}</td>
|
|
|
|
</tr>
|
|
|
|
));
|
|
|
|
|
2019-04-13 11:48:21 +08:00
|
|
|
shortcutItems.push((
|
|
|
|
<tr key={_.uniqueId('hotkey-item-')}>
|
|
|
|
<td className={styles.keyCell}>Right Arrow</td>
|
|
|
|
<td className={styles.descCell}>{intl.formatMessage(intlMessages.nextSlideDesc)}</td>
|
|
|
|
</tr>
|
|
|
|
));
|
|
|
|
|
|
|
|
shortcutItems.push((
|
|
|
|
<tr key={_.uniqueId('hotkey-item-')}>
|
|
|
|
<td className={styles.keyCell}>Left Arrow</td>
|
|
|
|
<td className={styles.descCell}>{intl.formatMessage(intlMessages.previousSlideDesc)}</td>
|
|
|
|
</tr>
|
|
|
|
));
|
|
|
|
|
2018-11-01 02:51:56 +08:00
|
|
|
return (
|
|
|
|
<Modal
|
|
|
|
title={intl.formatMessage(intlMessages.title)}
|
|
|
|
dismiss={{
|
|
|
|
label: intl.formatMessage(intlMessages.closeLabel),
|
|
|
|
description: intl.formatMessage(intlMessages.closeDesc),
|
|
|
|
}}
|
|
|
|
>
|
2019-04-12 08:08:14 +08:00
|
|
|
{!accessMod ? <p>{intl.formatMessage(intlMessages.accessKeyNotAvailable)}</p>
|
|
|
|
: (
|
|
|
|
<span>
|
|
|
|
<table className={styles.shortcutTable}>
|
|
|
|
<tbody>
|
|
|
|
<tr>
|
|
|
|
<th>{intl.formatMessage(intlMessages.comboLabel)}</th>
|
|
|
|
<th>{intl.formatMessage(intlMessages.functionLabel)}</th>
|
|
|
|
</tr>
|
|
|
|
{shortcutItems}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</span>
|
|
|
|
)
|
2018-11-01 02:51:56 +08:00
|
|
|
}
|
|
|
|
</Modal>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
ShortcutHelpComponent.defaultProps = {
|
|
|
|
intl: intlShape,
|
|
|
|
};
|
|
|
|
|
|
|
|
ShortcutHelpComponent.propTypes = {
|
|
|
|
intl: intlShape,
|
|
|
|
shortcuts: PropTypes.arrayOf(PropTypes.shape({
|
|
|
|
accesskey: PropTypes.string.isRequired,
|
|
|
|
descId: PropTypes.string.isRequired,
|
|
|
|
})).isRequired,
|
|
|
|
};
|
2018-05-01 03:18:29 +08:00
|
|
|
|
2018-11-01 02:51:56 +08:00
|
|
|
export default withShortcutHelper(injectIntl(ShortcutHelpComponent));
|