blob: a87c8d6f40a5726ce9a6427672d32aedebf2433c [file] [log] [blame]
Michael Landoefa037d2017-02-19 12:57:33 +02001/**
2 * Holds the buttons for save/reset for forms.
3 * Used by the ValidationForm that changes the state of the buttons according to its own state.
4 *
5 * properties:
6 * labledButtons - whether or not to use labeled buttons or icons only
7 */
8import React from 'react';
9import i18n from 'nfvo-utils/i18n/i18n.js';
10import Button from 'react-bootstrap/lib/Button.js';
11import FontAwesome from 'react-fontawesome';
12
13class ValidationButtons extends React.Component {
14
15 static propTypes = {
16 labledButtons: React.PropTypes.bool.isRequired,
17 isReadOnlyMode: React.PropTypes.bool
18 };
19
20 state = {
21 isValid: this.props.formValid
22 };
23
24 render() {
25 var submitBtn = this.props.labledButtons ? i18n('Save') : <FontAwesome className='check' name='check'/>;
26 var closeBtn = this.props.labledButtons ? i18n('Cancel') : <FontAwesome className='close' name='close'/>;
27 return (
28 <div className='validation-buttons'>
29 {!this.props.isReadOnlyMode ?
30 <div>
31 <Button bsStyle='primary' ref='submitbutton' type='submit' disabled={!this.state.isValid}>{submitBtn}</Button>
32 <Button type='reset'>{closeBtn}</Button>
33 </div>
34 : <Button type='reset'>{i18n('Close')}</Button>
35 }
36 </div>
37 );
38 }
39}
40export default ValidationButtons;