2017-06-08_509bba0/509bba0_unpacked_with_node_modules/discord_app/components/user_settings/UserSettingsTextImages.js
2022-07-26 10:06:20 -07:00

112 lines
3.9 KiB
JavaScript
Executable file

/* @flow */
import React from 'react';
import Flux from '../../lib/flux';
import UserSettingsStore from '../../stores/UserSettingsStore';
import UserSettingsActionCreators from '../../actions/UserSettingsActionCreators';
import TTS from '../../lib/TTS';
import i18n from '../../i18n';
import MarkupUtils from '../../utils/MarkupUtils';
import FormSection from '../../uikit/form/FormSection';
import FormTitle, {Tags} from '../../uikit/form/FormTitle';
import SwitchItem from '../../uikit/SwitchItem';
class UserSettingsTextImages extends React.PureComponent {
props: {
inlineAttachmentMedia: boolean,
inlineEmbedMedia: boolean,
renderEmbeds: boolean,
renderReactions: boolean,
enableTTSCommand: boolean,
convertEmoticons: boolean,
};
onFieldChange(key, value) {
UserSettingsActionCreators.updateRemoteSettings({[key]: value});
}
renderTTSControl() {
if (TTS.supported) {
return (
<FormSection>
<FormTitle className="margin-bottom-8">
{i18n.Messages.FORM_LABEL_TTS}
</FormTitle>
<SwitchItem
className="margin-top-8"
value={this.props.enableTTSCommand}
onChange={event => this.onFieldChange('enableTTSCommand', event.target.checked)}>
{i18n.Messages.ALLOW_TTS_COMMAND}
</SwitchItem>
</FormSection>
);
}
}
render() {
const {inlineEmbedMedia, inlineAttachmentMedia, renderEmbeds, renderReactions, convertEmoticons} = this.props;
return (
<FormSection tag={Tags.H2} title={i18n.Messages.TEXT_AND_IMAGES}>
<FormTitle className="margin-bottom-8">
{i18n.Messages.INLINE_MEDIA_LABEL}
</FormTitle>
<SwitchItem
className="margin-top-8 margin-bottom-20"
value={inlineEmbedMedia}
onChange={event => this.onFieldChange('inlineEmbedMedia', event.target.checked)}>
{i18n.Messages.INLINE_EMBED_MEDIA}
</SwitchItem>
<SwitchItem
className="margin-bottom-40"
value={inlineAttachmentMedia}
note={i18n.Messages.INLINE_ATTACHMENT_MEDIA_HELP.format({maxSize: 10})}
onChange={event => this.onFieldChange('inlineAttachmentMedia', event.target.checked)}>
{i18n.Messages.INLINE_ATTACHMENT_MEDIA}
</SwitchItem>
<FormTitle className="margin-bottom-8">
{i18n.Messages.RENDER_EMBEDS_LABEL}
</FormTitle>
<SwitchItem
className="margin-top-8 margin-bottom-40"
value={renderEmbeds}
onChange={event => this.onFieldChange('renderEmbeds', event.target.checked)}>
{i18n.Messages.RENDER_EMBEDS}
</SwitchItem>
<FormTitle className="margin-bottom-8">
{i18n.Messages.EMOJI}
</FormTitle>
<SwitchItem
className="margin-top-8 margin-bottom-20"
value={renderReactions}
onChange={event => this.onFieldChange('renderReactions', event.target.checked)}>
{i18n.Messages.RENDER_REACTIONS}
</SwitchItem>
<SwitchItem
className="margin-bottom-40"
value={convertEmoticons}
note={MarkupUtils.parse(i18n.Messages.CONVERT_EMOTICONS_HELP)}
onChange={event => this.onFieldChange('convertEmoticons', event.target.checked)}>
{i18n.Messages.CONVERT_EMOTICONS}
</SwitchItem>
{this.renderTTSControl()}
</FormSection>
);
}
}
export default Flux.connectStores([UserSettingsStore], () => {
return {
inlineAttachmentMedia: UserSettingsStore.inlineAttachmentMedia,
inlineEmbedMedia: UserSettingsStore.inlineEmbedMedia,
renderEmbeds: UserSettingsStore.renderEmbeds,
renderReactions: UserSettingsStore.renderReactions,
enableTTSCommand: UserSettingsStore.enableTTSCommand,
convertEmoticons: UserSettingsStore.convertEmoticons,
};
})(UserSettingsTextImages);
// WEBPACK FOOTER //
// ./discord_app/components/user_settings/UserSettingsTextImages.js