import {Component, Fragment} from 'react'; import {browserHistory, RouteComponentProps} from 'react-router'; import {switchOrganization} from 'app/actionCreators/organizations'; import AlertActions from 'app/actions/alertActions'; import {Client} from 'app/api'; import Alert from 'app/components/alert'; import Button from 'app/components/button'; import ErrorBoundary from 'app/components/errorBoundary'; import Footer from 'app/components/footer'; import {Body, Main} from 'app/components/layouts/thirds'; import {IconWarning} from 'app/icons'; import {t, tct} from 'app/locale'; import {Organization} from 'app/types'; import getRouteStringFromRoutes from 'app/utils/getRouteStringFromRoutes'; import withOrganization from 'app/utils/withOrganization'; import OrganizationContext from 'app/views/organizationContext'; type InProgressProps = { organization: Organization; }; function DeletionInProgress({organization}: InProgressProps) { return (
}> {tct( 'The [organization] organization is currently in the process of being deleted from Sentry.', { organization: {organization.slug}, } )}
); } type PendingProps = { organization: Organization; }; type PendingState = { submitInProgress: boolean; }; class DeletionPending extends Component { state: PendingState = {submitInProgress: false}; componentWillUnmount() { this.api.clear(); } api = new Client(); onRestore = () => { if (this.state.submitInProgress) { return; } this.setState({submitInProgress: true}); this.api.request(`/organizations/${this.props.organization.slug}/`, { method: 'PUT', data: {cancelDeletion: true}, success: () => { window.location.reload(); }, error: () => { AlertActions.addAlert({ message: 'We were unable to restore this organization. Please try again or contact support.', type: 'error', }); this.setState({submitInProgress: false}); }, }); }; render() { const {organization} = this.props; const access = new Set(organization.access); return (

{t('Deletion Scheduled')}

{tct('The [organization] organization is currently scheduled for deletion.', { organization: {organization.slug}, })}

{access.has('org:admin') ? (

{t( 'Would you like to cancel this process and restore the organization back to the original state?' )}

) : (

{t( 'If this is a mistake, contact an organization owner and ask them to restore this organization.' )}

)}

{t( "Note: Restoration is available until the process begins. Once it does, there's no recovering the data that has been removed." )}

); } } type OrganizationDetailsProps = { organization?: Organization; children?: React.ReactNode; }; const OrganizationDetailsBody = withOrganization(function OrganizationDetailsBody({ children, organization, }: OrganizationDetailsProps) { const status = organization?.status?.id; if (organization && status === 'pending_deletion') { return ; } if (organization && status === 'deletion_in_progress') { return ; } return ( {children}