// Package imports. import classNames from 'classnames'; import PropTypes from 'prop-types'; import React from 'react'; import { defineMessages, FormattedMessage, injectIntl } from 'react-intl'; import { length } from 'stringz'; import ImmutablePureComponent from 'react-immutable-pure-component'; // Components. import Button from 'flavours/glitch/components/button'; import Icon from 'flavours/glitch/components/icon'; // Utils. import { maxChars } from 'flavours/glitch/util/initial_state'; // Messages. const messages = defineMessages({ publish: { defaultMessage: 'Toot', id: 'compose_form.publish', }, publishLoud: { defaultMessage: '{publish}!', id: 'compose_form.publish_loud', }, clear: { defaultMessage: 'Double-click to clear', id: 'compose_form.clear', }, }); export default @injectIntl class Publisher extends ImmutablePureComponent { static propTypes = { countText: PropTypes.string, disabled: PropTypes.bool, intl: PropTypes.object.isRequired, onSecondarySubmit: PropTypes.func, onSubmit: PropTypes.func, onClearAll: PropTypes.func, privacy: PropTypes.oneOf(['direct', 'private', 'unlisted', 'public']), privacyWarning: PropTypes.bool, sideArm: PropTypes.oneOf(['none', 'direct', 'private', 'unlisted', 'public']), sideArmWarning: PropTypes.bool, }; handleSubmit = () => { this.props.onSubmit(); }; render () { const { countText, disabled, intl, onClearAll, onSecondarySubmit, privacy, privacyWarning, sideArm, sideArmWarning } = this.props; const diff = maxChars - length(countText || ''); const computedClass = classNames('composer--publisher', { disabled: disabled || diff < 0, over: diff < 0, }); return (