import { capitalize } from 'lodash'; import { Badge, Button, Card, Stack, Text, TextLink } from '@grafana/ui'; import { Trans, t } from 'app/core/internationalization'; import alertmanagerLogo from 'app/plugins/datasource/alertmanager/img/logo.svg'; import { ConnectionStatus } from '../../hooks/useExternalAmSelector'; import { ProvisioningBadge } from '../Provisioning'; import { WithReturnButton } from '../WithReturnButton'; interface Props { name: string; href?: string; url?: string; logo?: string; provisioned?: boolean; readOnly?: boolean; showStatus?: boolean; implementation?: string; receiving?: boolean; status?: ConnectionStatus; // functions onEditConfiguration: () => void; onDisable?: () => void; onEnable?: () => void; } export function AlertmanagerCard({ name, href, url, logo = alertmanagerLogo, provisioned = false, readOnly = provisioned, showStatus = true, implementation, receiving = false, status = 'unknown', onEditConfiguration, onEnable, onDisable, }: Props) { const showActions = !provisioned && Boolean(onEnable) && Boolean(onDisable); return ( {href ? ( {name} } /> ) : ( name )} {provisioned && } {`logo {/* sadly we have to resort to "mimicking" the Card.Description in here because "
"s can not be child elements of "

" – which is what the description element wrapper is */} {implementation && capitalize(implementation)} {url && url} {/* if forwarding is diabled, still show status for the "canonical" Alertmanager */} {showStatus ? ( <> {!receiving ? ( Not receiving Grafana managed alerts ) : ( <> {status === 'pending' && ( )} {status === 'active' && ( )} {status === 'dropped' && ( )} {status === 'inconclusive' && ( )} )} ) : null} {/* we'll use the "tags" area to append buttons and actions */} {/* ⚠️ provisioned Data sources cannot have their "enable" / "disable" actions but we should still allow editing of the configuration */} {showActions ? ( <> {receiving ? ( ) : ( )} ) : null} ); }