import React from 'react'; import superagent from 'superagent'; import { Accordion, Segment, Grid, Header, Image, Icon, Button, Table, Form, Divider, Label, Modal } from 'semantic-ui-react' import * as AccountUtils from "../AccountUtils"; const DISABLE_CHECK_TEXT = "Disable this account!" export default class AccountDangerZone extends React.Component { constructor(props) { super(props); this.state = { showDisableDialog: false, showDisconnectDialog: false, disableCheckText: "", }; } async onChange(e, { name, value }) { this.setState({ [name]: value }) } // Disconnect onDisconnect(e) { e.preventDefault(); this.setState({showDisconnectDialog: true }); } closeDisconnectModal(e) { this.setState({showDisconnectDialog: false}); } async onConfirmDisconnect(e) { e.preventDefault(); try { const result = await superagent.get(`/cloud/admin/account/${this.props.account.id}/disconnect`).accept('json'); } catch (e) { console.log(e); } this.setState({showDisconnectDialog: false}); } // Disable account dialog onDisable(e) { e.preventDefault(); this.setState({showDisableDialog: true, disableCheckText: ""}); } onUpdateDisableCheckText(event, {name, value}) { event.preventDefault(); this.setState({disableCheckText: value}); } closeDisableModal(e) { this.setState({showDisableDialog: false}); } async onConfirmDisable(e) { e.preventDefault(); if (this.state.disableCheckText === DISABLE_CHECK_TEXT) { try { const result = await superagent.put(`/api/admin/account/${this.props.account.id}/disable`).accept('json'); console.log(result.body); await this.getAccountInfo(); } catch (e) { console.log(e); } } this.setState({showDisableDialog: false}); } async onAddAccessPolicy(e) { e.preventDefault(); try { } catch (e) { console.log(e); } } render() { if (this.props.account) { let bannedInfo = this.props.account.status == "Banned" ? (
This account has been banned
) : null; let accountStatus = this.props.account.status == "Banned" ? (
) : ( ) return (
{ (this.props.account) &&

Disconnect {this.props.account.username}?

Use wisely, but this has no permanent effect. The user will be inconvenienced for a few seconds while waiting for a reconnection attempt, though in some cases they will have to restart their app. This will have no effect if they are offline.

}
{ (this.props.account) &&

Enter the text "{DISABLE_CHECK_TEXT}" to permanently disable {this.props.account.username}'s account:

}

Note: this action can not be undone!

{this.props.account.isStaff && This is a Bigscreen Staff Account } {bannedInfo}
Danger Zone
Disconnect Account Disable Account
); } else { return null; } } }