import React, { PureComponent } from 'react'; import { css } from '@emotion/css'; import { ConfirmButton, ConfirmModal, Button } from '@grafana/ui'; import { UserSession } from 'app/types'; interface Props { sessions: UserSession[]; onSessionRevoke: (id: number) => void; onAllSessionsRevoke: () => void; } interface State { showLogoutModal: boolean; } export class UserSessions extends PureComponent { state: State = { showLogoutModal: false, }; showLogoutConfirmationModal = (show: boolean) => () => { this.setState({ showLogoutModal: show }); }; onSessionRevoke = (id: number) => { return () => { this.props.onSessionRevoke(id); }; }; onAllSessionsRevoke = () => { this.setState({ showLogoutModal: false }); this.props.onAllSessionsRevoke(); }; render() { const { sessions } = this.props; const { showLogoutModal } = this.state; const logoutFromAllDevicesClass = css` margin-top: 0.8rem; `; return ( <>

Sessions

{sessions && sessions.map((session, index) => ( ))}
Last seen Logged on IP address Browser and OS
{session.isActive ? 'Now' : session.seenAt} {session.createdAt} {session.clientIp} {`${session.browser} on ${session.os} ${session.osVersion}`}
Force logout
{sessions.length > 0 && ( )}
); } }