EditReceiverView.tsx 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. import React, { FC } from 'react';
  2. import { InfoBox } from '@grafana/ui';
  3. import { AlertManagerCortexConfig } from 'app/plugins/datasource/alertmanager/types';
  4. import { GRAFANA_RULES_SOURCE_NAME } from '../../utils/datasource';
  5. import { CloudReceiverForm } from './form/CloudReceiverForm';
  6. import { GrafanaReceiverForm } from './form/GrafanaReceiverForm';
  7. interface Props {
  8. receiverName: string;
  9. config: AlertManagerCortexConfig;
  10. alertManagerSourceName: string;
  11. }
  12. export const EditReceiverView: FC<Props> = ({ config, receiverName, alertManagerSourceName }) => {
  13. const receiver = config.alertmanager_config.receivers?.find(({ name }) => name === receiverName);
  14. if (!receiver) {
  15. return (
  16. <InfoBox severity="error" title="Receiver not found">
  17. Sorry, this receiver does not seem to exit.
  18. </InfoBox>
  19. );
  20. }
  21. if (alertManagerSourceName === GRAFANA_RULES_SOURCE_NAME) {
  22. return <GrafanaReceiverForm config={config} alertManagerSourceName={alertManagerSourceName} existing={receiver} />;
  23. } else {
  24. return <CloudReceiverForm config={config} alertManagerSourceName={alertManagerSourceName} existing={receiver} />;
  25. }
  26. };