From b023b891550cd8fb2f874e822f05921d13f51fb2 Mon Sep 17 00:00:00 2001 From: David Meza Date: Tue, 1 Aug 2017 07:12:25 -0500 Subject: Use Constants.MAX_CHANNELNAME_LENGTH where a fixed number like 22 or 64 is used for max length of channel names. (#7041) --- webapp/components/change_url_modal.jsx | 2 +- webapp/components/rename_channel_modal.jsx | 14 +++++++------- webapp/i18n/en.json | 2 +- webapp/utils/constants.jsx | 2 ++ 4 files changed, 11 insertions(+), 9 deletions(-) (limited to 'webapp') diff --git a/webapp/components/change_url_modal.jsx b/webapp/components/change_url_modal.jsx index a94a33ad3..88304a4a7 100644 --- a/webapp/components/change_url_modal.jsx +++ b/webapp/components/change_url_modal.jsx @@ -191,7 +191,7 @@ export default class ChangeUrlModal extends React.Component { type='text' ref='urlinput' className='form-control' - maxLength='22' + maxLength={Constants.MAX_CHANNELNAME_LENGTH} onChange={this.onURLChanged} value={this.state.currentURL} autoFocus={true} diff --git a/webapp/components/rename_channel_modal.jsx b/webapp/components/rename_channel_modal.jsx index d4cddb9db..8d36e15c7 100644 --- a/webapp/components/rename_channel_modal.jsx +++ b/webapp/components/rename_channel_modal.jsx @@ -21,7 +21,7 @@ const holders = defineMessages({ }, maxLength: { id: 'rename_channel.maxLength', - defaultMessage: 'This field must be less than 22 characters' + defaultMessage: 'This field must be less than {maxLength, number} characters' }, lowercase: { id: 'rename_channel.lowercase', @@ -136,8 +136,8 @@ export class RenameChannelModal extends React.Component { if (!channel.display_name) { state.displayNameError = formatMessage(holders.required); state.invalid = true; - } else if (channel.display_name.length > 22) { - state.displayNameError = formatMessage(holders.maxLength); + } else if (channel.display_name.length > Constants.MAX_CHANNELNAME_LENGTH) { + state.displayNameError = formatMessage(holders.maxLength, {maxLength: Constants.MAX_CHANNELNAME_LENGTH}); state.invalid = true; } else { state.displayNameError = ''; @@ -147,8 +147,8 @@ export class RenameChannelModal extends React.Component { if (!channel.name) { state.nameError = formatMessage(holders.required); state.invalid = true; - } else if (channel.name.length > 22) { - state.nameError = formatMessage(holders.maxLength); + } else if (channel.name.length > Constants.MAX_CHANNELNAME_LENGTH) { + state.nameError = formatMessage(holders.maxLength, {maxLength: Constants.MAX_CHANNELNAME_LENGTH}); state.invalid = true; } else { const cleanedName = cleanUpUrlable(channel.name); @@ -264,7 +264,7 @@ export class RenameChannelModal extends React.Component { className='form-control' placeholder={formatMessage(holders.displayNameHolder)} value={this.state.displayName} - maxLength='64' + maxLength={Constants.MAX_CHANNELNAME_LENGTH} /> {displayNameError} @@ -287,7 +287,7 @@ export class RenameChannelModal extends React.Component { ref='channelName' placeholder={formatMessage(holders.handleHolder)} value={this.state.channelName} - maxLength='64' + maxLength={Constants.MAX_CHANNELNAME_LENGTH} readOnly={readOnlyHandleInput} /> diff --git a/webapp/i18n/en.json b/webapp/i18n/en.json index e2fdde1b0..55fc3cd74 100755 --- a/webapp/i18n/en.json +++ b/webapp/i18n/en.json @@ -1982,7 +1982,7 @@ "rename_channel.displayNameHolder": "Enter display name", "rename_channel.handleHolder": "lowercase alphanumeric characters", "rename_channel.lowercase": "Must be lowercase alphanumeric characters", - "rename_channel.maxLength": "This field must be less than 22 characters", + "rename_channel.maxLength": "This field must be less than {maxLength, number} characters", "rename_channel.required": "This field is required", "rename_channel.save": "Save", "rename_channel.title": "Rename Channel", diff --git a/webapp/utils/constants.jsx b/webapp/utils/constants.jsx index 2b6b17503..f3d1520c7 100644 --- a/webapp/utils/constants.jsx +++ b/webapp/utils/constants.jsx @@ -1,6 +1,8 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See License.txt for license information. +/* eslint-disable no-magic-numbers */ + import keyMirror from 'key-mirror'; import audioIcon from 'images/icons/audio.png'; -- cgit v1.2.3-1-g7c22