EditTemplateView.tsx 833 B

123456789101112131415161718192021222324252627282930
  1. import React, { FC } from 'react';
  2. import { InfoBox } from '@grafana/ui';
  3. import { AlertManagerCortexConfig } from 'app/plugins/datasource/alertmanager/types';
  4. import { TemplateForm } from './TemplateForm';
  5. interface Props {
  6. templateName: string;
  7. config: AlertManagerCortexConfig;
  8. alertManagerSourceName: string;
  9. }
  10. export const EditTemplateView: FC<Props> = ({ config, templateName, alertManagerSourceName }) => {
  11. const template = config.template_files?.[templateName];
  12. if (!template) {
  13. return (
  14. <InfoBox severity="error" title="Template not found">
  15. Sorry, this template does not seem to exit.
  16. </InfoBox>
  17. );
  18. }
  19. return (
  20. <TemplateForm
  21. alertManagerSourceName={alertManagerSourceName}
  22. config={config}
  23. existing={{ name: templateName, content: template }}
  24. />
  25. );
  26. };