Merge branch 'compose-form-features' into 'develop'

Compose form features

See merge request soapbox-pub/soapbox-fe!1074
purgecss
Alex Gleason 2022-03-04 19:17:29 +00:00
commit d496e2a5d4
5 zmienionych plików z 45 dodań i 37 usunięć

Wyświetl plik

@ -83,6 +83,7 @@ export default class ComposeForm extends ImmutablePureComponent {
isModalOpen: PropTypes.bool, isModalOpen: PropTypes.bool,
clickableAreaRef: PropTypes.object, clickableAreaRef: PropTypes.object,
scheduledAt: PropTypes.instanceOf(Date), scheduledAt: PropTypes.instanceOf(Date),
features: PropTypes.object.isRequired,
}; };
static defaultProps = { static defaultProps = {
@ -254,7 +255,7 @@ export default class ComposeForm extends ImmutablePureComponent {
} }
render() { render() {
const { intl, onPaste, showSearch, anyMedia, shouldCondense, autoFocus, isModalOpen, maxTootChars, scheduledStatusCount } = this.props; const { intl, onPaste, showSearch, anyMedia, shouldCondense, autoFocus, isModalOpen, maxTootChars, scheduledStatusCount, features } = this.props;
const condensed = shouldCondense && !this.state.composeFocused && this.isEmpty() && !this.props.isUploading; const condensed = shouldCondense && !this.state.composeFocused && this.isEmpty() && !this.props.isUploading;
const disabled = this.props.isSubmitting; const disabled = this.props.isSubmitting;
const text = [this.props.spoilerText, countableText(this.props.text)].join(''); const text = [this.props.spoilerText, countableText(this.props.text)].join('');
@ -366,12 +367,12 @@ export default class ComposeForm extends ImmutablePureComponent {
<div className='compose-form__buttons-wrapper'> <div className='compose-form__buttons-wrapper'>
<div className='compose-form__buttons'> <div className='compose-form__buttons'>
<UploadButtonContainer /> {features.media && <UploadButtonContainer />}
<PollButtonContainer /> {features.polls && <PollButtonContainer />}
<PrivacyDropdownContainer /> {features.privacyScopes && <PrivacyDropdownContainer />}
<ScheduleButtonContainer /> {features.scheduledStatuses && <ScheduleButtonContainer />}
<SpoilerButtonContainer /> {features.spoilers && <SpoilerButtonContainer />}
<MarkdownButtonContainer /> {features.richText && <MarkdownButtonContainer />}
</div> </div>
{maxTootChars && ( {maxTootChars && (
<div className='compose-form__counter'> <div className='compose-form__counter'>

Wyświetl plik

@ -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'>

Wyświetl plik

@ -1,6 +1,8 @@
import { injectIntl } from 'react-intl'; import { injectIntl } from 'react-intl';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { getFeatures } from 'soapbox/utils/features';
import { import {
changeCompose, changeCompose,
submitCompose, submitCompose,
@ -13,24 +15,29 @@ import {
} from '../../../actions/compose'; } from '../../../actions/compose';
import ComposeForm from '../components/compose_form'; import ComposeForm from '../components/compose_form';
const mapStateToProps = state => ({ const mapStateToProps = state => {
text: state.getIn(['compose', 'text']), const instance = state.get('instance');
suggestions: state.getIn(['compose', 'suggestions']),
spoiler: state.getIn(['compose', 'spoiler']), return {
spoilerText: state.getIn(['compose', 'spoiler_text']), text: state.getIn(['compose', 'text']),
privacy: state.getIn(['compose', 'privacy']), suggestions: state.getIn(['compose', 'suggestions']),
focusDate: state.getIn(['compose', 'focusDate']), spoiler: state.getIn(['compose', 'spoiler']),
caretPosition: state.getIn(['compose', 'caretPosition']), spoilerText: state.getIn(['compose', 'spoiler_text']),
isSubmitting: state.getIn(['compose', 'is_submitting']), privacy: state.getIn(['compose', 'privacy']),
isChangingUpload: state.getIn(['compose', 'is_changing_upload']), focusDate: state.getIn(['compose', 'focusDate']),
isUploading: state.getIn(['compose', 'is_uploading']), caretPosition: state.getIn(['compose', 'caretPosition']),
showSearch: state.getIn(['search', 'submitted']) && !state.getIn(['search', 'hidden']), isSubmitting: state.getIn(['compose', 'is_submitting']),
anyMedia: state.getIn(['compose', 'media_attachments']).size > 0, isChangingUpload: state.getIn(['compose', 'is_changing_upload']),
isModalOpen: state.get('modals').size && state.get('modals').last().modalType === 'COMPOSE', isUploading: state.getIn(['compose', 'is_uploading']),
maxTootChars: state.getIn(['instance', 'configuration', 'statuses', 'max_characters']), showSearch: state.getIn(['search', 'submitted']) && !state.getIn(['search', 'hidden']),
scheduledAt: state.getIn(['compose', 'schedule']), anyMedia: state.getIn(['compose', 'media_attachments']).size > 0,
scheduledStatusCount: state.get('scheduled_statuses').size, isModalOpen: state.get('modals').size && state.get('modals').last().modalType === 'COMPOSE',
}); maxTootChars: state.getIn(['instance', 'configuration', 'statuses', 'max_characters']),
scheduledAt: state.getIn(['compose', 'schedule']),
scheduledStatusCount: state.get('scheduled_statuses').size,
features: getFeatures(instance),
};
};
const mapDispatchToProps = (dispatch) => ({ const mapDispatchToProps = (dispatch) => ({

Wyświetl plik

@ -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,
}; };
}; };

Wyświetl plik

@ -23,6 +23,17 @@ export const getFeatures = createSelector([instance => instance], instance => {
const federation = instance.getIn(['pleroma', 'metadata', 'federation'], ImmutableMap()); const federation = instance.getIn(['pleroma', 'metadata', 'federation'], ImmutableMap());
return Object.assign({ return Object.assign({
media: true,
privacyScopes: true,
spoilers: true,
polls: any([
v.software === MASTODON && gte(v.version, '2.8.0'),
v.software === PLEROMA,
]),
scheduledStatuses: any([
v.software === MASTODON && gte(v.version, '2.7.0'),
v.software === PLEROMA,
]),
bookmarks: any([ bookmarks: any([
v.software === MASTODON && gte(v.compatVersion, '3.1.0'), v.software === MASTODON && gte(v.compatVersion, '3.1.0'),
v.software === PLEROMA && gte(v.version, '0.9.9'), v.software === PLEROMA && gte(v.version, '0.9.9'),