diff options
3 files changed, 34 insertions, 3 deletions
diff --git a/app/javascript/flavours/glitch/features/compose/components/compose_form.js b/app/javascript/flavours/glitch/features/compose/components/compose_form.js index 5a1949e90..ec1f9aa7c 100644 --- a/app/javascript/flavours/glitch/features/compose/components/compose_form.js +++ b/app/javascript/flavours/glitch/features/compose/components/compose_form.js @@ -52,6 +52,7 @@ class ComposeForm extends ImmutablePureComponent { isUploading: PropTypes.bool, onChange: PropTypes.func, onSubmit: PropTypes.func, + onClearAll: PropTypes.func, onClearSuggestions: PropTypes.func, onFetchSuggestions: PropTypes.func, onSuggestionSelected: PropTypes.func, @@ -111,6 +112,7 @@ class ComposeForm extends ImmutablePureComponent { text, mediaDescriptionConfirmation, onMediaDescriptionConfirm, + onClearAll, } = this.props; // If something changes inside the textarea, then we update the @@ -168,6 +170,10 @@ class ComposeForm extends ImmutablePureComponent { this.handleSubmit(); } + handleClearAll = () => { + this.props.onClearAll(); + } + // Selects a suggestion from the autofill. onSuggestionSelected = (tokenStart, token, value) => { this.props.onSuggestionSelected(tokenStart, token, value, ['text']); @@ -279,6 +285,7 @@ class ComposeForm extends ImmutablePureComponent { handleSelect, handleSubmit, handleRefTextarea, + handleClearAll, } = this; const { advancedOptions, @@ -376,6 +383,7 @@ class ComposeForm extends ImmutablePureComponent { disabled={disabledButton} onSecondarySubmit={handleSecondarySubmit} onSubmit={handleSubmit} + onClearAll={handleClearAll} privacy={privacy} sideArm={sideArm} /> diff --git a/app/javascript/flavours/glitch/features/compose/components/publisher.js b/app/javascript/flavours/glitch/features/compose/components/publisher.js index e283b32b9..effb3bfb6 100644 --- a/app/javascript/flavours/glitch/features/compose/components/publisher.js +++ b/app/javascript/flavours/glitch/features/compose/components/publisher.js @@ -23,6 +23,10 @@ const messages = defineMessages({ defaultMessage: '{publish}!', id: 'compose_form.publish_loud', }, + clear: { + defaultMessage: 'Clear', + id: 'compose_form.clear', + }, }); export default @injectIntl @@ -34,12 +38,13 @@ class Publisher extends ImmutablePureComponent { intl: PropTypes.object.isRequired, onSecondarySubmit: PropTypes.func, onSubmit: PropTypes.func, - privacy: PropTypes.oneOf(['direct', 'private', 'unlisted', 'public']), - sideArm: PropTypes.oneOf(['none', 'direct', 'private', 'unlisted', 'public']), + onClearAll: PropTypes.func, + privacy: PropTypes.oneOf(['direct', 'private', 'unlisted', 'local', 'public']), + sideArm: PropTypes.oneOf(['none', 'direct', 'private', 'unlisted', 'local', 'public']), }; render () { - const { countText, disabled, intl, onSecondarySubmit, onSubmit, privacy, sideArm } = this.props; + const { countText, disabled, intl, onSecondarySubmit, onSubmit, onClearAll, privacy, sideArm } = this.props; const diff = maxChars - length(countText || ''); const computedClass = classNames('composer--publisher', { @@ -49,6 +54,17 @@ class Publisher extends ImmutablePureComponent { return ( <div className={computedClass}> + <Button + className='clear' + onClick={onClearAll} + text={ + <span> + <Icon icon='trash-o' /> + {' '} + <FormattedMessage {...messages.clear} /> + </span> + } + /> <span className='count'>{diff}</span> {sideArm && sideArm !== 'none' ? ( <Button @@ -61,6 +77,7 @@ class Publisher extends ImmutablePureComponent { <Icon icon={{ public: 'globe', + local: 'users', unlisted: 'unlock', private: 'lock', direct: 'envelope', @@ -86,6 +103,7 @@ class Publisher extends ImmutablePureComponent { private: 'lock', public: 'globe', unlisted: 'unlock', + local: 'users', }[privacy]} /> {' '} diff --git a/app/javascript/flavours/glitch/features/compose/containers/compose_form_container.js b/app/javascript/flavours/glitch/features/compose/containers/compose_form_container.js index 880778220..6d8763d29 100644 --- a/app/javascript/flavours/glitch/features/compose/containers/compose_form_container.js +++ b/app/javascript/flavours/glitch/features/compose/containers/compose_form_container.js @@ -14,6 +14,7 @@ import { submitCompose, unmountCompose, uploadCompose, + resetCompose, } from 'flavours/glitch/actions/compose'; import { openModal, @@ -134,6 +135,10 @@ const mapDispatchToProps = (dispatch, { intl }) => ({ })); }, + onClearAll() { + dispatch(resetCompose()); + } + }); export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(ComposeForm)); |