The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/public/app/features/alerting/unified/components/NoAlertManagerWarning.tsx

42 lines
1.3 KiB

import React from 'react';
import { Alert } from '@grafana/ui';
import { useAlertManagerSourceName } from '../hooks/useAlertManagerSourceName';
import { AlertManagerDataSource } from '../utils/datasource';
import { AlertManagerPicker } from './AlertManagerPicker';
interface Props {
availableAlertManagers: AlertManagerDataSource[];
}
const NoAlertManagersAvailable = () => (
<Alert title="No Alertmanager found" severity="warning">
We could not find any external Alertmanagers and you may not have access to the built-in Grafana Alertmanager.
</Alert>
);
const OtherAlertManagersAvailable = () => (
<Alert title="Selected Alertmanager not found. Select a different Alertmanager." severity="warning">
Selected Alertmanager no longer exists or you may not have permission to access it.
</Alert>
);
export const NoAlertManagerWarning = ({ availableAlertManagers }: Props) => {
const [_, setAlertManagerSourceName] = useAlertManagerSourceName(availableAlertManagers);
const hasOtherAMs = availableAlertManagers.length > 0;
return (
<div>
{hasOtherAMs ? (
<>
<AlertManagerPicker onChange={setAlertManagerSourceName} dataSources={availableAlertManagers} />
<OtherAlertManagersAvailable />
</>
) : (
<NoAlertManagersAvailable />
)}
</div>
);
};