Files
mostlymatter/webapp/components/form_error.jsx
Asaad Mahmood 3eee51f74e UI fix for errors in signup and login pages and adding space between buttons in the security tab (#3512)
* Fixing the errors style on login and signup pages

* Adding space between login options in the security section
2016-07-06 13:32:27 -08:00

62 строки
1.5 KiB
JavaScript

// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import React from 'react';
export default class FormError extends React.Component {
static get propTypes() {
// accepts either a single error or an array of errors
return {
error: React.PropTypes.node,
margin: React.PropTypes.node,
errors: React.PropTypes.arrayOf(React.PropTypes.node)
};
}
static get defaultProps() {
return {
error: null,
errors: []
};
}
render() {
if (!this.props.error && this.props.errors.length === 0) {
return null;
}
// look for the first truthy error to display
let message = this.props.error;
if (!message) {
for (const error of this.props.errors) {
if (error) {
message = error;
}
}
}
if (!message) {
return null;
}
if (this.props.margin) {
return (
<div className='form-group has-error'>
<label className='control-label'>
{message}
</label>
</div>
);
}
return (
<div className='col-sm-12 has-error'>
<label className='control-label'>
{message}
</label>
</div>
);
}
}