summaryrefslogtreecommitdiffstats
path: root/web/react/components/confirm_modal.jsx
blob: 12002f33fccf838433a3ad5061c179dd5e142658 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.

export default class ConfirmModal extends React.Component {
    constructor(props) {
        super(props);

        this.handleConfirm = this.handleConfirm.bind(this);

        this.state = {};
    }
    handleConfirm() {
        $('#' + this.props.parent_id).attr('data-confirm', 'true');
        $('#' + this.props.parent_id).modal('hide');
        $('#' + this.props.id).modal('hide');
    }
    render() {
        return (
            <div
                className='modal fade'
                id={this.props.id}
                tabIndex='-1'
                role='dialog'
                aria-hidden='true'
            >
            <div className='modal-dialog'>
                <div className='modal-content'>
                        <div className='modal-header'>
                            <h4 className='modal-title'>{this.props.title}</h4>
                        </div>
                        <div className='modal-body'>
                            {this.props.message}
                        </div>
                        <div className='modal-footer'>
                            <button
                                type='button'
                                className='btn btn-default'
                                data-dismiss='modal'
                            >
                                Cancel
                            </button>
                            <button
                                onClick={this.handleConfirm}
                                type='button'
                                className='btn btn-primary'
                            >
                                {this.props.confirm_button}
                            </button>
                        </div>
                    </div>
                </div>
            </div>
        );
    }
}

ConfirmModal.defaultProps = {
    parent_id: '',
    id: '',
    title: '',
    message: '',
    confirm_button: ''
};
ConfirmModal.propTypes = {
    parent_id: React.PropTypes.string,
    id: React.PropTypes.string,
    title: React.PropTypes.string,
    message: React.PropTypes.string,
    confirm_button: React.PropTypes.string
};