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 { generateCopiedName } from '../../utils/duplicate';
import { stringifyErrorLike } from '../../utils/misc';
import { updateDefinesWithUniqueValue } from '../../utils/templates';
import { createRelativeUrl } from '../../utils/url';
import { withPageErrorBoundary } from '../../withPageErrorBoundary';
import { AlertmanagerPageWrapper } from '../AlertingPageWrapper';
import { TemplateForm } from '../receivers/TemplateForm';
import { ActiveTab } from './ContactPoints';
import { useGetNotificationTemplate, useNotificationTemplates } from './useNotificationTemplates';
const notFoundComponent = ;
const DuplicateMessageTemplateComponent = () => {
const { selectedAlertmanager } = useAlertmanager();
const { name } = useParams<{ name: string }>();
const templateUid = name ? decodeURIComponent(name) : undefined;
const {
currentData: template,
isLoading: isLoadingTemplate,
error: templateFetchError,
} = useGetNotificationTemplate({ alertmanager: selectedAlertmanager ?? '', uid: templateUid ?? '' });
const {
currentData: templates,
isLoading: templatesLoading,
error: templatesFetchError,
} = useNotificationTemplates({ alertmanager: selectedAlertmanager ?? '' });
const isLoading = isLoadingTemplate || templatesLoading;
const error = templateFetchError || templatesFetchError;
if (!selectedAlertmanager) {
return ;
}
if (!templateUid) {
return ;
}
if (isLoading) {
return ;
}
if (error) {
return isNotFoundError(error) ? (
notFoundComponent
) : (
{stringifyErrorLike(error)}
);
}
if (!template) {
return notFoundComponent;
}
const duplicatedName = generateCopiedName(template.title, templates?.map((t) => t.title) ?? []);
return (
);
};
function DuplicateMessageTemplate() {
return (
);
}
export default withPageErrorBoundary(DuplicateMessageTemplate);