import {Fragment} from 'react'; import {browserHistory, RouteComponentProps} from 'react-router'; import {addLoadingMessage} from 'sentry/actionCreators/indicator'; import { changeOrganizationSlug, removeAndRedirectToRemainingOrganization, updateOrganization, } from 'sentry/actionCreators/organizations'; import Button from 'sentry/components/button'; import Confirm from 'sentry/components/confirm'; import Field from 'sentry/components/forms/field'; import List from 'sentry/components/list'; import ListItem from 'sentry/components/list/listItem'; import {Panel, PanelHeader} from 'sentry/components/panels'; import SentryDocumentTitle from 'sentry/components/sentryDocumentTitle'; import {t, tct} from 'sentry/locale'; import {Organization, Project} from 'sentry/types'; import useApi from 'sentry/utils/useApi'; import withOrganization from 'sentry/utils/withOrganization'; import withProjects from 'sentry/utils/withProjects'; import SettingsPageHeader from 'sentry/views/settings/components/settingsPageHeader'; import TextBlock from 'sentry/views/settings/components/text/textBlock'; import PermissionAlert from 'sentry/views/settings/organization/permissionAlert'; import OrganizationSettingsForm from './organizationSettingsForm'; type Props = { organization: Organization; projects: Project[]; } & RouteComponentProps<{orgId: string}, {}>; function OrganizationGeneralSettings(props: Props) { const api = useApi(); const {organization, projects, params} = props; const {orgId} = params; const access = new Set(organization.access); const removeConfirmMessage = ( {tct( 'Removing the organization, [name] is permanent and cannot be undone! Are you sure you want to continue?', { name: organization && {organization.name}, } )} {!!projects.length && ( {t('This will also remove the following associated projects:')} {projects.map(project => ( {project.slug} ))} )} ); const handleSaveForm: React.ComponentProps< typeof OrganizationSettingsForm >['onSave'] = (prevData: Organization, data: Partial) => { if (data.slug && data.slug !== prevData.slug) { changeOrganizationSlug( prevData, data as Partial & Pick ); browserHistory.replace(`/settings/${data.slug}/`); } else { // This will update OrganizationStore (as well as OrganizationsStore // which is slightly incorrect because it has summaries vs a detailed org) updateOrganization(data); } }; const handleConfirmRemoveOrg = () => { if (!organization) { return; } addLoadingMessage(); removeAndRedirectToRemainingOrganization(api, { orgId: params.orgId, successMessage: `${organization.name} is queued for deletion.`, errorMessage: `Error removing the ${organization.name} organization`, }); }; return (
{access.has('org:admin') && !organization.isDefault && ( {t('Remove Organization')}
)}
); } export default withProjects(withOrganization(OrganizationGeneralSettings));