import { css } from '@emotion/css'; import React, { FC, useMemo } from 'react'; import { GrafanaTheme2, SelectableValue } from '@grafana/data'; import { Field, Select, useStyles2 } from '@grafana/ui'; import { AlertManagerDataSource, GRAFANA_RULES_SOURCE_NAME } from '../utils/datasource'; interface Props { onChange: (alertManagerSourceName: string) => void; current?: string; disabled?: boolean; dataSources: AlertManagerDataSource[]; } function getAlertManagerLabel(alertManager: AlertManagerDataSource) { return alertManager.name === GRAFANA_RULES_SOURCE_NAME ? 'Grafana' : alertManager.name.slice(0, 37); } export const AlertManagerPicker: FC = ({ onChange, current, dataSources, disabled = false }) => { const styles = useStyles2(getStyles); const options: Array> = useMemo(() => { return dataSources.map((ds) => ({ label: getAlertManagerLabel(ds), value: ds.name, imgUrl: ds.imgUrl, meta: ds.meta, })); }, [dataSources]); return (