import {Component} from 'react'; import {RouteComponentProps} from 'react-router'; import moment from 'moment'; import {Client} from 'sentry/api'; import LinkWithConfirmation from 'sentry/components/links/linkWithConfirmation'; import ResultGrid from 'sentry/components/resultGrid'; import {t} from 'sentry/locale'; import withApi from 'sentry/utils/withApi'; const prettyDate = (x: string) => moment(x).format('ll LTS'); type Props = RouteComponentProps<{}, {}> & {api: Client}; type State = { loading: boolean; }; type RelayRow = { firstSeen: string; id: string; lastSeen: string; publicKey: string; relayId: string; }; class AdminRelays extends Component { state: State = { loading: false, }; onDelete(key: string) { this.setState({loading: true}); this.props.api.request(`/relays/${key}/`, { method: 'DELETE', success: () => this.setState({loading: false}), error: () => this.setState({loading: false}), }); } getRow(row: RelayRow) { return [ {row.relayId} , {row.publicKey}, {prettyDate(row.firstSeen)} , {prettyDate(row.lastSeen)} , this.onDelete(row.id)} > {t('Remove')} , ]; } render() { const columns = [ Relay , Public Key, First seen , Last seen , , ]; return (

{t('Relays')}

); } } export {AdminRelays}; export default withApi(AdminRelays);