import {Fragment, useState} from 'react'; import {Alert} from 'sentry/components/alert'; import {Button} from 'sentry/components/button'; import ErrorBoundary from 'sentry/components/errorBoundary'; import Footer from 'sentry/components/footer'; import * as Layout from 'sentry/components/layouts/thirds'; import {t, tct} from 'sentry/locale'; import AlertStore from 'sentry/stores/alertStore'; import {Organization} from 'sentry/types'; import useApi from 'sentry/utils/useApi'; import withOrganization from 'sentry/utils/withOrganization'; type OrganizationProps = { organization: Organization; }; type BodyProps = { children?: React.ReactNode; // Organization can be null in account settings organization?: Organization; }; function DeletionInProgress({organization}: OrganizationProps) { return ( {tct( 'The [organization] organization is currently in the process of being deleted from Sentry.', { organization: {organization.slug}, } )} ); } function DeletionPending({organization}: OrganizationProps) { const api = useApi(); const [isRestoring, setIsRestoring] = useState(false); const onRestore = async () => { setIsRestoring(true); try { await api.requestPromise(`/organizations/${organization.slug}/`, { method: 'PUT', data: {cancelDeletion: true}, }); window.location.reload(); } catch { setIsRestoring(false); AlertStore.addAlert({ message: 'We were unable to restore this organization. Please try again or contact support.', type: 'error', }); } }; return (

{t('Deletion Scheduled')}

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

{organization.access.includes('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." )}

); } function OrganizationDetailsBody({children, organization}: BodyProps) { const status = organization?.status?.id; if (organization && status === 'pending_deletion') { return ; } if (organization && status === 'deletion_in_progress') { return ; } return ( {children}