mirror of
https://github.com/grafana/grafana.git
synced 2025-02-10 23:55:47 -06:00
* reactify user sessions * all reactified * more cleanup * comment edit * Profile: Fix casing * Profile: Add Page wrapper * Profile: New form styles for UserProfileEditForm * Profile: Use new form styles for SharedPreferences * Profile: Use radioButtonGroup for SharedPreferences * Grafana UI: Add FieldSet * Grafana UI: Add story * Grafana UI: Add docs * Grafana UI: Export FieldSet * Profile: USe FieldSet * Profile: Sort sessions Co-authored-by: Clarity-89 <homes89@ukr.net>
68 lines
2.0 KiB
TypeScript
68 lines
2.0 KiB
TypeScript
import React, { PureComponent } from 'react';
|
|
import { User, UserSession } from 'app/types';
|
|
import { LoadingPlaceholder, Button, Icon } from '@grafana/ui';
|
|
|
|
export interface Props {
|
|
user: User;
|
|
sessions: UserSession[];
|
|
isLoading: boolean;
|
|
loadSessions: () => void;
|
|
revokeUserSession: (tokenId: number) => void;
|
|
}
|
|
|
|
export class UserSessions extends PureComponent<Props> {
|
|
componentDidMount() {
|
|
this.props.loadSessions();
|
|
}
|
|
|
|
render() {
|
|
const { isLoading, sessions, revokeUserSession } = this.props;
|
|
|
|
if (isLoading) {
|
|
return <LoadingPlaceholder text="Loading sessions..." />;
|
|
}
|
|
|
|
return (
|
|
<>
|
|
{sessions.length > 0 && (
|
|
<>
|
|
<h3 className="page-sub-heading">Sessions</h3>
|
|
<div className="gf-form-group">
|
|
<table className="filter-table form-inline">
|
|
<thead>
|
|
<tr>
|
|
<th>Last seen</th>
|
|
<th>Logged on</th>
|
|
<th>IP address</th>
|
|
<th>Browser & OS</th>
|
|
<th></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{sessions.map((session: UserSession, index) => (
|
|
<tr key={index}>
|
|
{session.isActive ? <td>Now</td> : <td>{session.seenAt}</td>}
|
|
<td>{session.createdAt}</td>
|
|
<td>{session.clientIp}</td>
|
|
<td>
|
|
{session.browser} on {session.os} {session.osVersion}
|
|
</td>
|
|
<td>
|
|
<Button size="sm" variant="destructive" onClick={() => revokeUserSession(session.id)}>
|
|
<Icon name="power" />
|
|
</Button>
|
|
</td>
|
|
</tr>
|
|
))}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</>
|
|
)}
|
|
</>
|
|
);
|
|
}
|
|
}
|
|
|
|
export default UserSessions;
|