import { useEffect } from 'react'; import { SIGV4ConnectionConfig } from '@grafana/aws-sdk'; import { DataSourcePluginOptionsEditorProps } from '@grafana/data'; import { AdvancedHttpSettings, Auth, AuthMethod, ConfigSection, ConnectionSettings, convertLegacyAuthProps, DataSourceDescription, } from '@grafana/plugin-ui'; import { config } from '@grafana/runtime'; import { Alert, SecureSocksProxySettings, Divider, Stack } from '@grafana/ui'; import { ElasticsearchOptions } from '../types'; import { DataLinks } from './DataLinks'; import { ElasticDetails } from './ElasticDetails'; import { LogsConfig } from './LogsConfig'; import { coerceOptions, isValidOptions } from './utils'; export type Props = DataSourcePluginOptionsEditorProps; export const ConfigEditor = (props: Props) => { const { options, onOptionsChange } = props; useEffect(() => { if (!isValidOptions(options)) { onOptionsChange(coerceOptions(options)); } }, [onOptionsChange, options]); const authProps = convertLegacyAuthProps({ config: options, onChange: onOptionsChange, }); if (config.sigV4AuthEnabled) { authProps.customMethods = [ { id: 'custom-sigv4', label: 'SigV4 auth', description: 'AWS Signature Version 4 authentication', component: , }, ]; authProps.selectedMethod = options.jsonData.sigV4Auth ? 'custom-sigv4' : authProps.selectedMethod; } return ( <> {options.access === 'direct' && ( Browser access mode in the Elasticsearch datasource is no longer available. Switch to server access mode. )} { onOptionsChange({ ...options, basicAuth: method === AuthMethod.BasicAuth, withCredentials: method === AuthMethod.CrossSiteCredentials, jsonData: { ...options.jsonData, sigV4Auth: method === 'custom-sigv4', oauthPassThru: method === AuthMethod.OAuthForward, }, }); }} /> {config.secureSocksDSProxyEnabled && ( )} onOptionsChange({ ...options, jsonData: newValue, }) } /> { onOptionsChange({ ...options, jsonData: { ...options.jsonData, dataLinks: newValue, }, }); }} /> ); };