Add character limit to channel header edit modal (#7179)
Этот коммит содержится в:
коммит произвёл
Saturnino Abril
родитель
48741434aa
Коммит
33d3818e1f
@@ -85,15 +85,14 @@ class EditChannelHeaderModal extends React.Component {
|
||||
this.props.channel.id,
|
||||
this.state.header,
|
||||
() => {
|
||||
this.setState({serverError: ''});
|
||||
this.setState({serverError: '', submitted: false});
|
||||
this.onHide();
|
||||
},
|
||||
(err) => {
|
||||
if (err.id === 'api.context.invalid_param.app_error') {
|
||||
this.setState({serverError: this.props.intl.formatMessage(holders.error)});
|
||||
} else {
|
||||
this.setState({serverError: err.message});
|
||||
}
|
||||
this.setState({submitted: false});
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -189,6 +188,7 @@ class EditChannelHeaderModal extends React.Component {
|
||||
handlePostError={this.handlePostError}
|
||||
id='edit_textbox'
|
||||
ref='editChannelHeaderTextbox'
|
||||
characterLimit={1024}
|
||||
/>
|
||||
<br/>
|
||||
{serverError}
|
||||
|
||||
@@ -38,13 +38,15 @@ export default class Textbox extends React.Component {
|
||||
suggestionListStyle: PropTypes.string,
|
||||
emojiEnabled: PropTypes.bool,
|
||||
isRHS: PropTypes.bool,
|
||||
popoverMentionKeyClick: React.PropTypes.bool
|
||||
popoverMentionKeyClick: React.PropTypes.bool,
|
||||
characterLimit: React.PropTypes.number
|
||||
};
|
||||
|
||||
static defaultProps = {
|
||||
supportsCommands: true,
|
||||
isRHS: false,
|
||||
popoverMentionKeyClick: false
|
||||
popoverMentionKeyClick: false,
|
||||
characterLimit: Constants.CHARACTER_LIMIT
|
||||
};
|
||||
|
||||
constructor(props) {
|
||||
@@ -93,14 +95,14 @@ export default class Textbox extends React.Component {
|
||||
|
||||
checkMessageLength = (message) => {
|
||||
if (this.props.handlePostError) {
|
||||
if (message.length > Constants.CHARACTER_LIMIT) {
|
||||
if (message.length > this.props.characterLimit) {
|
||||
const errorMessage = (
|
||||
<FormattedMessage
|
||||
id='create_post.error_message'
|
||||
defaultMessage='Your message is too long. Character count: {length}/{limit}'
|
||||
values={{
|
||||
length: message.length,
|
||||
limit: Constants.CHARACTER_LIMIT
|
||||
limit: this.props.characterLimit
|
||||
}}
|
||||
/>);
|
||||
this.props.handlePostError(errorMessage);
|
||||
|
||||
Ссылка в новой задаче
Block a user