diff options
Diffstat (limited to 'webapp/components')
-rw-r--r-- | webapp/components/backstage/add_command.jsx | 48 |
1 files changed, 47 insertions, 1 deletions
diff --git a/webapp/components/backstage/add_command.jsx b/webapp/components/backstage/add_command.jsx index f3208bc5f..c817764aa 100644 --- a/webapp/components/backstage/add_command.jsx +++ b/webapp/components/backstage/add_command.jsx @@ -11,6 +11,7 @@ import {FormattedMessage} from 'react-intl'; import FormError from 'components/form_error.jsx'; import {browserHistory, Link} from 'react-router'; import SpinnerButton from 'components/spinner_button.jsx'; +import Constants from 'utils/constants.jsx'; const REQUEST_POST = 'P'; const REQUEST_GET = 'G'; @@ -92,6 +93,51 @@ export default class AddCommand extends React.Component { return; } + if (command.trigger.indexOf('/') === 0) { + this.setState({ + saving: false, + clientError: ( + <FormattedMessage + id='add_command.triggerInvalidSlash' + defaultMessage='A trigger word cannot begin with a /' + /> + ) + }); + + return; + } + + if (command.trigger.indexOf(' ') !== -1) { + this.setState({ + saving: false, + clientError: ( + <FormattedMessage + id='add_command.triggerInvalidSpace' + defaultMessage='A trigger word must not contain spaces' + /> + ) + }); + return; + } + + if (command.trigger.length < Constants.MIN_TRIGGER_LENGTH || command.trigger.length > Constants.MAX_TRIGGER_LENGTH) { + this.setState({ + saving: false, + clientError: ( + <FormattedMessage + id='add_command.triggerInvalidLength' + defaultMessage='A trigger word must contain between {min} and {max} characters' + values={{ + min: Constants.MIN_TRIGGER_LENGTH, + max: Constants.MAX_TRIGGER_LENGTH + }} + /> + ) + }); + + return; + } + if (!command.url) { this.setState({ saving: false, @@ -323,7 +369,7 @@ export default class AddCommand extends React.Component { <input id='trigger' type='text' - maxLength='128' + maxLength={Constants.MAX_TRIGGER_LENGTH} className='form-control' value={this.state.trigger} onChange={this.updateTrigger} |