[AAI-92 Amsterdam] Update license
[aai/sparky-fe.git] / src / generic-components / input / validation / ValidationButtons.jsx
1 /*
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
4  * ================================================================================
5  * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6  * Copyright © 2017 Amdocs
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *       http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  *
21  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22  */
23 /**
24         * Holds the buttons for save/reset for forms.
25         * Used by the ValidationForm that changes the state of the buttons according
26         * to its own state.
27         *
28         * properties:
29         * labledButtons - whether or not to use labeled buttons or icons only
30         */
31 import React from 'react';
32 import i18n from 'utils/i18n/i18n.js';
33 import Button from 'react-bootstrap/lib/Button.js';
34 import FontAwesome from 'react-fontawesome';
35
36 class ValidationButtons extends React.Component {
37                 
38                 static propTypes = {
39                                 labledButtons: React.PropTypes.bool.isRequired,
40                                 isReadOnlyMode: React.PropTypes.bool
41                 };
42                 
43                 state = {
44                                 isValid: this.props.formValid
45                 };
46                 
47                 render() {
48                                 var submitBtn = this.props.labledButtons ? i18n('Save') :
49                                                 <FontAwesome className='check' name='check'/>;
50                                 var closeBtn = this.props.labledButtons ? i18n('Cancel') :
51                                                <FontAwesome className='close' name='close'/>;
52                                 return (
53                                                 <div className='validation-buttons'>
54                                                                 {!this.props.isReadOnlyMode ?
55                                                                  <div>
56                                                                                  <Button bsStyle='primary' ref='submitbutton' type='submit'
57                                                                                          disabled={!this.state.isValid}>{submitBtn}</Button>
58                                                                                  <Button type='reset'>{closeBtn}</Button>
59                                                                  </div>
60                                                                                 : <Button type='reset'>{i18n('Close')}</Button>
61                                                                 }
62                                                 </div>
63                                 );
64                 }
65 }
66 export default ValidationButtons;