diff --git a/packages/grafana-ui/src/components/DataSourceSettings/AlertingSettings.test.tsx b/packages/grafana-ui/src/components/DataSourceSettings/AlertingSettings.test.tsx new file mode 100644 index 00000000000..e68e6829975 --- /dev/null +++ b/packages/grafana-ui/src/components/DataSourceSettings/AlertingSettings.test.tsx @@ -0,0 +1,51 @@ +import { render, screen } from '@testing-library/react'; +import React from 'react'; + +import { AlertingSettings } from '@grafana/ui'; + +import { Props, AlertingConfig } from './AlertingSettings'; + +const setup = () => { + const onOptionsChange = jest.fn(); + const props: Props = { + options: { + id: 4, + uid: 'x', + orgId: 1, + name: 'test', + type: 'test', + typeName: 'test', + typeLogoUrl: '', + access: 'direct', + url: 'http://localhost:8086', + user: 'grafana', + database: 'site', + basicAuth: false, + basicAuthUser: '', + withCredentials: false, + isDefault: false, + jsonData: {}, + secureJsonData: { + password: true, + }, + secureJsonFields: {}, + readOnly: true, + }, + onOptionsChange, + }; + + render(); +}; + +describe('Alerting Settings', () => { + //see https://github.com/grafana/grafana/issues/51417 + it('should not show the option to select alertmanager data sources', () => { + setup(); + expect(screen.queryByText('Alertmanager data source')).toBeNull(); + }); + + it('should show the option to Manage alerts via Alerting UI', () => { + setup(); + expect(screen.getByText('Manage alerts via Alerting UI')).toBeVisible(); + }); +}); diff --git a/packages/grafana-ui/src/components/DataSourceSettings/AlertingSettings.tsx b/packages/grafana-ui/src/components/DataSourceSettings/AlertingSettings.tsx index d07838de220..51e1ce51fff 100644 --- a/packages/grafana-ui/src/components/DataSourceSettings/AlertingSettings.tsx +++ b/packages/grafana-ui/src/components/DataSourceSettings/AlertingSettings.tsx @@ -1,37 +1,18 @@ -import React, { useMemo } from 'react'; +import React from 'react'; -import { DataSourceInstanceSettings, DataSourceJsonData, DataSourcePluginOptionsEditorProps } from '@grafana/data'; +import { DataSourceJsonData, DataSourcePluginOptionsEditorProps } from '@grafana/data'; import { InlineSwitch } from '../../components/Switch/Switch'; import { InlineField } from '../Forms/InlineField'; -import { InlineFieldRow } from '../Forms/InlineFieldRow'; -import { Select } from '../Select/Select'; -interface Props - extends Pick, 'options' | 'onOptionsChange'> { - alertmanagerDataSources: Array>; -} +export interface Props + extends Pick, 'options' | 'onOptionsChange'> {} -interface AlertingConfig extends DataSourceJsonData { +export interface AlertingConfig extends DataSourceJsonData { manageAlerts?: boolean; } -export function AlertingSettings({ - alertmanagerDataSources, - options, - onOptionsChange, -}: Props): JSX.Element { - const alertmanagerOptions = useMemo( - () => - alertmanagerDataSources.map((ds) => ({ - label: ds.name, - value: ds.uid, - imgUrl: ds.meta.info.logos.small, - meta: ds.meta, - })), - [alertmanagerDataSources] - ); - +export function AlertingSettings({ options, onOptionsChange }: Props): JSX.Element { return ( <>

Alerting

@@ -51,22 +32,6 @@ export function AlertingSettings({ - - -