import { useParams } from 'react-router-dom-v5-compat'; import { Alert, LoadingPlaceholder } from '@grafana/ui'; import { EntityNotFound } from 'app/core/components/PageNotFound/EntityNotFound'; import { t } from 'app/core/internationalization'; import { isNotFoundError } from '../../api/util'; import { useAlertmanager } from '../../state/AlertmanagerContext'; import { stringifyErrorLike } from '../../utils/misc'; import { createRelativeUrl } from '../../utils/url'; import { withPageErrorBoundary } from '../../withPageErrorBoundary'; import { AlertmanagerPageWrapper } from '../AlertingPageWrapper'; import { TemplateForm } from '../receivers/TemplateForm'; import { ActiveTab } from './ContactPoints'; import { useGetNotificationTemplate } from './useNotificationTemplates'; const notFoundComponent = ; const EditMessageTemplateComponent = () => { const { name } = useParams<{ name: string }>(); const templateUid = name ? decodeURIComponent(name) : undefined; const { selectedAlertmanager } = useAlertmanager(); const { currentData, isLoading, error, isUninitialized } = useGetNotificationTemplate({ alertmanager: selectedAlertmanager ?? '', uid: templateUid ?? '', }); if (!templateUid) { return ; } if (isLoading || isUninitialized) { return ; } if (error) { return isNotFoundError(error) ? ( notFoundComponent ) : ( {stringifyErrorLike(error)} ); } if (!currentData) { return notFoundComponent; } return ; }; function EditMessageTemplate() { return ( ); } export default withPageErrorBoundary(EditMessageTemplate);