Add new code new version
[sdc.git] / openecomp-ui / src / nfvo-components / input / validation / ValidationButtons.jsx
1 /**
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  */
8 import React from 'react';
9 import i18n from 'nfvo-utils/i18n/i18n.js';
10 import Button from 'react-bootstrap/lib/Button.js';
11 import FontAwesome from 'react-fontawesome';
12
13 class 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 }
40 export default ValidationButtons;