import {Fragment} from 'react'; import type {RouteComponentProps} from 'react-router'; import {browserHistory} from 'react-router'; import styled from '@emotion/styled'; import {addSuccessMessage} from 'sentry/actionCreators/indicator'; import Alert from 'sentry/components/alert'; import {Button} from 'sentry/components/button'; import ApiForm from 'sentry/components/forms/apiForm'; import HiddenField from 'sentry/components/forms/fields/hiddenField'; import LoadingIndicator from 'sentry/components/loadingIndicator'; import NarrowLayout from 'sentry/components/narrowLayout'; import SentryDocumentTitle from 'sentry/components/sentryDocumentTitle'; import {t, tct} from 'sentry/locale'; import {space} from 'sentry/styles/space'; import type {Organization} from 'sentry/types'; import {useApiQuery} from 'sentry/utils/queryClient'; import {useParams} from 'sentry/utils/useParams'; import {normalizeUrl} from 'sentry/utils/withDomainRequired'; type Props = RouteComponentProps<{orgId: string}, {}>; function OrganizationRestore(_props: Props) { const params = useParams<{orgId: string}>(); return (

{t('Deletion Scheduled')}

); } type BodyProps = { orgSlug: string; }; function OrganizationRestoreBody({orgSlug}: BodyProps) { const endpoint = `/organizations/${orgSlug}/`; const {isLoading, isError, data} = useApiQuery([endpoint], { staleTime: 0, }); if (isLoading) { return ; } if (isError) { return ( {t('There was an error loading your organization.')} ); } if (data.status.id === 'active') { browserHistory.replace(normalizeUrl(`/organizations/${orgSlug}/issues/`)); return null; } if (data.status.id === 'pending_deletion') { return ; } return (

{t( 'Sorry, but this organization is currently in progress of being deleted. No turning back.' )}

); } type RestoreFormProps = { endpoint: string; organization: Organization; }; function RestoreForm({endpoint, organization}: RestoreFormProps) { return ( { addSuccessMessage(t('Organization Restored')); // Use window.location to ensure page reloads window.location.assign( normalizeUrl(`/organizations/${organization.slug}/issues/`) ); }} initialData={{cancelDeletion: 1}} hideFooter >

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

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

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

); } const ButtonWrapper = styled('div')` margin-bottom: ${space(2)}; `; export default OrganizationRestore;