forked from mattermost/mattermost-webapp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
access_history_modal.jsx
111 lines (97 loc) · 3.07 KB
/
access_history_modal.jsx
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import PropTypes from 'prop-types';
import React from 'react';
import {Modal} from 'react-bootstrap';
import {FormattedMessage} from 'react-intl';
import AuditTable from 'components/audit_table';
import LoadingScreen from 'components/loading_screen';
export default class AccessHistoryModal extends React.PureComponent {
static propTypes = {
/**
* Function that's called when modal is closed
*/
onHide: PropTypes.func.isRequired,
actions: PropTypes.shape({
/**
* Function to fetch the user's audits
*/
getUserAudits: PropTypes.func.isRequired,
}).isRequired,
/**
* The current user's audits
*/
userAudits: PropTypes.array.isRequired,
/**
* The current user id
*/
currentUserId: PropTypes.string.isRequired,
}
constructor(props) {
super(props);
this.state = {
show: true,
};
}
onShow = () => {
this.props.actions.getUserAudits(this.props.currentUserId, 0, 200);
}
onHide = () => {
this.setState({show: false});
}
componentDidMount() {
this.onShow();
}
render() {
let content;
if (this.props.userAudits.length === 0) {
content = (<LoadingScreen/>);
} else {
content = (
<AuditTable
audits={this.props.userAudits}
showIp={true}
showSession={true}
/>
);
}
return (
<Modal
dialogClassName='a11y__modal modal--scroll'
show={this.state.show}
onHide={this.onHide}
onExited={this.props.onHide}
bsSize='large'
role='dialog'
aria-labelledby='accessHistoryModalLabel'
>
<Modal.Header closeButton={true}>
<Modal.Title
componentClass='h1'
id='accessHistoryModalLabel'
>
<FormattedMessage
id='access_history.title'
defaultMessage='Access History'
/>
</Modal.Title>
</Modal.Header>
<Modal.Body ref='modalBody'>
{content}
</Modal.Body>
<Modal.Footer className='modal-footer--invisible'>
<button
id='closeModalButton'
type='button'
className='btn btn-link'
>
<FormattedMessage
id='general_button.close'
defaultMessage='Close'
/>
</button>
</Modal.Footer>
</Modal>
);
}
}