diff options
author | Ondřej Hruška <ondra@ondrovo.com> | 2017-09-23 23:38:24 +0200 |
---|---|---|
committer | Ondřej Hruška <ondra@ondrovo.com> | 2017-09-23 23:38:24 +0200 |
commit | 1924a71b5aaa2f32015f3f3a7ee56bb54195f56c (patch) | |
tree | b3c62fc93a0b93d2fa496c21e93f63c1c59619e0 /app/javascript/mastodon/features/compose/components/compose_form.js | |
parent | 67f82775268f57be5506031e65e3155a2618bef9 (diff) |
Make secondary toot button work nicer with file attachments & revert to the original behavior if it's disabled
Diffstat (limited to 'app/javascript/mastodon/features/compose/components/compose_form.js')
-rw-r--r-- | app/javascript/mastodon/features/compose/components/compose_form.js | 44 |
1 files changed, 28 insertions, 16 deletions
diff --git a/app/javascript/mastodon/features/compose/components/compose_form.js b/app/javascript/mastodon/features/compose/components/compose_form.js index 1d60ffe83..56d494dcd 100644 --- a/app/javascript/mastodon/features/compose/components/compose_form.js +++ b/app/javascript/mastodon/features/compose/components/compose_form.js @@ -58,6 +58,7 @@ export default class ComposeForm extends ImmutablePureComponent { onPickEmoji: PropTypes.func.isRequired, showSearch: PropTypes.bool, settings : ImmutablePropTypes.map.isRequired, + filesAttached : PropTypes.bool, }; static defaultProps = { @@ -159,13 +160,14 @@ export default class ComposeForm extends ImmutablePureComponent { } render () { - const { intl, onPaste, showSearch } = this.props; + const { intl, onPaste, showSearch, filesAttached } = this.props; const disabled = this.props.is_submitting; const maybeEye = (this.props.advanced_options && this.props.advanced_options.do_not_federate) ? ' 👁️' : ''; const text = [this.props.spoiler_text, countableText(this.props.text), maybeEye].join(''); - const sideArmVisibility = this.props.settings.get('side_arm'); - let showSideArm = sideArmVisibility !== 'none'; + const secondaryVisibility = this.props.settings.get('side_arm'); + const isWideView = this.props.settings.get('stretch'); + let showSideArm = secondaryVisibility !== 'none'; let publishText = ''; @@ -177,25 +179,35 @@ export default class ComposeForm extends ImmutablePureComponent { direct: 'envelope', }; - publishText = ( - <span> - { - (this.props.settings.get('stretch') || !showSideArm) ? + if (showSideArm) { + publishText = ( + <span> + { <i className={`fa fa-${privacyIcons[this.props.privacy]}`} - style={{ paddingRight: '5px' }} - /> : - '' - } - {intl.formatMessage(messages.publish)} - </span> - ); + style={{ + paddingRight: (filesAttached || !isWideView) ? '0' : '5px', + }} + /> + }{ + (filesAttached || !isWideView) ? '' : + intl.formatMessage(messages.publish) + } + </span> + ); + } else { + if (this.props.privacy === 'private' || this.props.privacy === 'direct') { + publishText = <span className='compose-form__publish-private'><i className='fa fa-lock' /> {intl.formatMessage(messages.publish)}</span>; + } else { + publishText = this.props.privacy !== 'unlisted' ? intl.formatMessage(messages.publishLoud, { publish: intl.formatMessage(messages.publish) }) : intl.formatMessage(messages.publish); + } + } // side-arm let publishText2 = ( <i - className={`fa fa-${privacyIcons[sideArmVisibility]}`} - aria-label={`${intl.formatMessage(messages.publish)}: ${intl.formatMessage({ id: `privacy.${sideArmVisibility}.short` })}`} + className={`fa fa-${privacyIcons[secondaryVisibility]}`} + aria-label={`${intl.formatMessage(messages.publish)}: ${intl.formatMessage({ id: `privacy.${secondaryVisibility}.short` })}`} /> ); |