import React from 'react'; import { DataSourcePluginOptionsEditorProps, DataSourceSettings } from '@grafana/data'; import { AlertingSettings, DataSourceHttpSettings } from '@grafana/ui'; import { getAllAlertmanagerDataSources } from 'app/features/alerting/unified/utils/alertmanager'; import { LokiOptions } from '../types'; import { DerivedFields } from './DerivedFields'; import { MaxLinesField } from './MaxLinesField'; export type Props = DataSourcePluginOptionsEditorProps; const makeJsonUpdater = (field: keyof LokiOptions) => (options: DataSourceSettings, value: T): DataSourceSettings => { return { ...options, jsonData: { ...options.jsonData, [field]: value, }, }; }; const setMaxLines = makeJsonUpdater('maxLines'); const setDerivedFields = makeJsonUpdater('derivedFields'); export const ConfigEditor = (props: Props) => { const { options, onOptionsChange } = props; const alertmanagers = getAllAlertmanagerDataSources(); return ( <> alertmanagerDataSources={alertmanagers} options={options} onOptionsChange={onOptionsChange} />
onOptionsChange(setMaxLines(options, value))} />
onOptionsChange(setDerivedFields(options, value))} /> ); };