39fea970248397e365e58182c3f55f3579c21367
[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 { PropTypes } from 'prop-types';
23 import Button from 'react-bootstrap/lib/Button.js';
24
25 import i18n from 'utils/i18n/i18n.js';
26 import Modal from 'generic-components/modal/Modal.jsx';
27
28 let typeClass = {
29                 'default': 'primary',
30                 error: 'danger',
31                 warning: 'warning',
32                 success: 'success'
33 };
34
35
36 class ConfirmationModalView extends React.Component {
37                 
38                 static propTypes = {
39                                 show: PropTypes.bool,
40                                 type: PropTypes.oneOf(['default', 'error', 'warning', 'success']),
41                                 msg: PropTypes.node,
42                                 title: PropTypes.string,
43                                 confirmationDetails: PropTypes.object
44                 };
45                 
46                 static defaultProps = {
47                                 show: false,
48                                 type: 'warning',
49                                 title: 'Warning',
50                                 msg: ''
51                 };
52                 
53                 render() {
54                                 let {title, type, msg, show} = this.props;
55                                 
56                                 return (
57                                                 <Modal show={show} className={`notification-modal ${typeClass[type]}`}
58                                                        bsSize='small'>
59                                                                 <Modal.Header>
60                                                                                 <Modal.Title>{title}</Modal.Title>
61                                                                 </Modal.Header>
62                                                                 <Modal.Body>{msg}</Modal.Body>
63                                                                 <Modal.Footer>
64                                                                                 <Button bsStyle={typeClass[type]}
65                                                                                         onClick={() => this.props.onDeclined(this.props.confirmationDetails)}>{i18n(
66                                                                                                 'Cancel')}</Button>
67                                                                                 <Button bsStyle={typeClass[type]}
68                                                                                         onClick={() => this.props.onConfirmed(this.props.confirmationDetails)}>{i18n(
69                                                                                                 'Delete')}</Button>
70                                                                 </Modal.Footer>
71                                                 </Modal>
72                                 );
73                 };
74 }
75
76 export default ConfirmationModalView;