sforkowany z mirror/soapbox
MarkdownButton: don't do the availability check in the component itself
rodzic
d98c54de4f
commit
664dfa2688
|
@ -17,7 +17,6 @@ class MarkdownButton extends React.PureComponent {
|
||||||
active: PropTypes.bool,
|
active: PropTypes.bool,
|
||||||
onClick: PropTypes.func.isRequired,
|
onClick: PropTypes.func.isRequired,
|
||||||
intl: PropTypes.object.isRequired,
|
intl: PropTypes.object.isRequired,
|
||||||
unavailable: PropTypes.bool,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
handleClick = () => {
|
handleClick = () => {
|
||||||
|
@ -25,11 +24,7 @@ class MarkdownButton extends React.PureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { intl, active, unavailable } = this.props;
|
const { intl, active } = this.props;
|
||||||
|
|
||||||
if (unavailable) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='compose-form__markdown-button'>
|
<div className='compose-form__markdown-button'>
|
||||||
|
|
|
@ -1,17 +1,11 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
|
|
||||||
import { getFeatures } from 'soapbox/utils/features';
|
|
||||||
|
|
||||||
import { changeComposeContentType } from '../../../actions/compose';
|
import { changeComposeContentType } from '../../../actions/compose';
|
||||||
import MarkdownButton from '../components/markdown_button';
|
import MarkdownButton from '../components/markdown_button';
|
||||||
|
|
||||||
const mapStateToProps = (state, { intl }) => {
|
const mapStateToProps = (state, { intl }) => {
|
||||||
const instance = state.get('instance');
|
|
||||||
const features = getFeatures(instance);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
active: state.getIn(['compose', 'content_type']) === 'text/markdown',
|
active: state.getIn(['compose', 'content_type']) === 'text/markdown',
|
||||||
unavailable: !features.richText,
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue