changed the header and license
[aai/sparky-fe.git] / src / generic-components / confirmations / ConfirmationModalView.jsx
1 /*
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
4  * ================================================================================
5  * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6  * Copyright © 2017-2018 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 import React from 'react';
22 import Button from 'react-bootstrap/lib/Button.js';
23
24 import i18n from 'utils/i18n/i18n.js';
25 import Modal from 'generic-components/modal/Modal.jsx';
26
27 let typeClass = {
28                 'default': 'primary',
29                 error: 'danger',
30                 warning: 'warning',
31                 success: 'success'
32 };
33
34
35 class ConfirmationModalView extends React.Component {
36                 
37                 static propTypes = {
38                                 show: React.PropTypes.bool,
39                                 type: React.PropTypes.oneOf(['default', 'error', 'warning', 'success']),
40                                 msg: React.PropTypes.node,
41                                 title: React.PropTypes.string,
42                                 confirmationDetails: React.PropTypes.object
43                 };
44                 
45                 static defaultProps = {
46                                 show: false,
47                                 type: 'warning',
48                                 title: 'Warning',
49                                 msg: ''
50                 };
51                 
52                 render() {
53                                 let {title, type, msg, show} = this.props;
54                                 
55                                 return (
56                                                 <Modal show={show} className={`notification-modal ${typeClass[type]}`}
57                                                        bsSize='small'>
58                                                                 <Modal.Header>
59                                                                                 <Modal.Title>{title}</Modal.Title>
60                                                                 </Modal.Header>
61                                                                 <Modal.Body>{msg}</Modal.Body>
62                                                                 <Modal.Footer>
63                                                                                 <Button bsStyle={typeClass[type]}
64                                                                                         onClick={() => this.props.onDeclined(this.props.confirmationDetails)}>{i18n(
65                                                                                                 'Cancel')}</Button>
66                                                                                 <Button bsStyle={typeClass[type]}
67                                                                                         onClick={() => this.props.onConfirmed(this.props.confirmationDetails)}>{i18n(
68                                                                                                 'Delete')}</Button>
69                                                                 </Modal.Footer>
70                                                 </Modal>
71                                 );
72                 };
73 }
74
75 export default ConfirmationModalView;