import {Fragment} from 'react'; import {Alert} from 'sentry/components/alert'; import {Button} from 'sentry/components/button'; import ButtonBar from 'sentry/components/buttonBar'; import EmptyMessage from 'sentry/components/emptyMessage'; import FeatureBadge from 'sentry/components/featureBadge'; import LoadingError from 'sentry/components/loadingError'; import {Panel} from 'sentry/components/panels'; import {t, tct} from 'sentry/locale'; import {Group, Organization, Project} from 'sentry/types'; type ErrorCode = | 'issue_not_hierarchical' | 'project_not_hierarchical' | 'no_events' | 'merged_issues' | 'missing_feature'; type Error = { status: number; responseJSON?: { detail: { code: ErrorCode; extra: Record; message: string; }; }; }; type Props = { error: Error | string; groupId: Group['id']; hasProjectWriteAccess: boolean; onRetry: () => void; orgSlug: Organization['slug']; projSlug: Project['slug']; className?: string; }; function ErrorMessage({ error, groupId, onRetry, orgSlug, projSlug, hasProjectWriteAccess, className, }: Props) { function getErrorDetails(errorCode: ErrorCode) { switch (errorCode) { case 'merged_issues': return { title: t('Grouping breakdown is not available in this issue'), subTitle: t( 'This issue needs to be fully unmerged before grouping breakdown is available' ), action: ( ), }; case 'missing_feature': return { title: t( 'This project does not have the grouping breakdown available. Is your organization still an early adopter?' ), }; case 'no_events': return { title: t('This issue has no events'), }; case 'issue_not_hierarchical': return { title: t('Grouping breakdown is not available in this issue'), subTitle: t( 'Only new issues with the latest grouping strategy have this feature available' ), }; case 'project_not_hierarchical': return { title: ( {t('Update your Grouping Config')} ), subTitle: (

{t( 'Enable advanced grouping insights and functionality by updating this project to the latest Grouping Config:' )}

), leftAligned: true, action: ( ), }; default: return {}; } } if (typeof error === 'string') { return ( {error} ); } if (error.status === 403 && error.responseJSON?.detail) { const {code, message} = error.responseJSON.detail; const {action, title, subTitle, leftAligned} = getErrorDetails(code); return ( ); } return ( ); } export default ErrorMessage;