Preferences: conditionally display post format (Markdown) settings
This commit is contained in:
parent
59e7c6538e
commit
5e6058489b
1 changed files with 31 additions and 22 deletions
|
@ -5,6 +5,7 @@ import ImmutablePureComponent from 'react-immutable-pure-component';
|
|||
import PropTypes from 'prop-types';
|
||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||
import { getSettings, changeSetting } from 'soapbox/actions/settings';
|
||||
import { getFeatures } from 'soapbox/utils/features';
|
||||
import Column from '../ui/components/column';
|
||||
import {
|
||||
SimpleForm,
|
||||
|
@ -84,9 +85,14 @@ const messages = defineMessages({
|
|||
display_media_show_all: { id: 'preferences.fields.display_media.show_all', defaultMessage: 'Always show media' },
|
||||
});
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
settings: getSettings(state),
|
||||
});
|
||||
const mapStateToProps = state => {
|
||||
const instance = state.get('instance');
|
||||
|
||||
return {
|
||||
features: getFeatures(instance),
|
||||
settings: getSettings(state),
|
||||
};
|
||||
};
|
||||
|
||||
export default @connect(mapStateToProps)
|
||||
@injectIntl
|
||||
|
@ -95,6 +101,7 @@ class Preferences extends ImmutablePureComponent {
|
|||
static propTypes = {
|
||||
dispatch: PropTypes.func.isRequired,
|
||||
intl: PropTypes.object.isRequired,
|
||||
features: PropTypes.object.isRequired,
|
||||
settings: ImmutablePropTypes.map,
|
||||
};
|
||||
|
||||
|
@ -115,7 +122,7 @@ class Preferences extends ImmutablePureComponent {
|
|||
}
|
||||
|
||||
render() {
|
||||
const { settings, intl } = this.props;
|
||||
const { settings, features, intl } = this.props;
|
||||
|
||||
const displayMediaOptions = {
|
||||
default: intl.formatMessage(messages.display_media_default),
|
||||
|
@ -170,24 +177,26 @@ class Preferences extends ImmutablePureComponent {
|
|||
</RadioGroup>
|
||||
</FieldsGroup>
|
||||
|
||||
<FieldsGroup>
|
||||
<RadioGroup
|
||||
label={<FormattedMessage id='preferences.fields.content_type_label' defaultMessage='Post format' />}
|
||||
onChange={this.onDefaultContentTypeChange}
|
||||
>
|
||||
<RadioItem
|
||||
label={<FormattedMessage id='preferences.options.content_type_plaintext' defaultMessage='Plain text' />}
|
||||
checked={settings.get('defaultContentType') === 'text/plain'}
|
||||
value='text/plain'
|
||||
/>
|
||||
<RadioItem
|
||||
label={<FormattedMessage id='preferences.options.content_type_markdown' defaultMessage='Markdown' />}
|
||||
hint={<FormattedMessage id='preferences.hints.content_type_markdown' defaultMessage='Warning: experimental!' />}
|
||||
checked={settings.get('defaultContentType') === 'text/markdown'}
|
||||
value='text/markdown'
|
||||
/>
|
||||
</RadioGroup>
|
||||
</FieldsGroup>
|
||||
{features.richText && (
|
||||
<FieldsGroup>
|
||||
<RadioGroup
|
||||
label={<FormattedMessage id='preferences.fields.content_type_label' defaultMessage='Post format' />}
|
||||
onChange={this.onDefaultContentTypeChange}
|
||||
>
|
||||
<RadioItem
|
||||
label={<FormattedMessage id='preferences.options.content_type_plaintext' defaultMessage='Plain text' />}
|
||||
checked={settings.get('defaultContentType') === 'text/plain'}
|
||||
value='text/plain'
|
||||
/>
|
||||
<RadioItem
|
||||
label={<FormattedMessage id='preferences.options.content_type_markdown' defaultMessage='Markdown' />}
|
||||
hint={<FormattedMessage id='preferences.hints.content_type_markdown' defaultMessage='Warning: experimental!' />}
|
||||
checked={settings.get('defaultContentType') === 'text/markdown'}
|
||||
value='text/markdown'
|
||||
/>
|
||||
</RadioGroup>
|
||||
</FieldsGroup>
|
||||
)}
|
||||
|
||||
<FieldsGroup>
|
||||
<SettingsCheckbox
|
||||
|
|
Loading…
Reference in a new issue