import React, { useEffect } from 'react'; import { Alert, DataSourceHttpSettings } from '@grafana/ui'; import { DataSourcePluginOptionsEditorProps } from '@grafana/data'; import { ElasticsearchOptions } from '../types'; import { defaultMaxConcurrentShardRequests, ElasticDetails } from './ElasticDetails'; import { LogsConfig } from './LogsConfig'; import { DataLinks } from './DataLinks'; import { config } from 'app/core/config'; export type Props = DataSourcePluginOptionsEditorProps; export const ConfigEditor = (props: Props) => { const { options, onOptionsChange } = props; // Apply some defaults on initial render useEffect(() => { const esVersion = options.jsonData.esVersion || 5; onOptionsChange({ ...options, jsonData: { ...options.jsonData, timeField: options.jsonData.timeField || '@timestamp', esVersion, maxConcurrentShardRequests: options.jsonData.maxConcurrentShardRequests || defaultMaxConcurrentShardRequests(esVersion), logMessageField: options.jsonData.logMessageField || '', logLevelField: options.jsonData.logLevelField || '', }, }); }, []); return ( <> {options.access === 'direct' && ( Browser access mode in the Elasticsearch datasource is deprecated and will be removed in a future release. )} onOptionsChange({ ...options, jsonData: newValue, }) } /> { onOptionsChange({ ...options, jsonData: { ...options.jsonData, dataLinks: newValue, }, }); }} /> ); };