import React, { useEffect, useRef } from 'react'; import { SIGV4ConnectionConfig } from '@grafana/aws-sdk'; import { DataSourcePluginOptionsEditorProps } from '@grafana/data'; import { Alert, DataSourceHttpSettings, SecureSocksProxySettings } from '@grafana/ui'; import { config } from 'app/core/config'; 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) => { // we decide on whether to show access options or not at the point when the config page opens. // whatever happens while the page is open, this decision does not change. // (we do this to avoid situations where you switch access-mode and suddenly // the access-mode-select-box vanishes) const showAccessOptions = useRef(props.options.access === 'direct'); const { options: originalOptions, onOptionsChange } = props; const options = coerceOptions(originalOptions); useEffect(() => { if (!isValidOptions(originalOptions)) { onOptionsChange(coerceOptions(originalOptions)); } // We can't enforce the eslint rule here because we only want to run this once. // eslint-disable-next-line react-hooks/exhaustive-deps }, []); return ( <> {options.access === 'direct' && ( Browser access mode in the Elasticsearch datasource is no longer available. Switch to server access mode. )} } /> {config.featureToggles.secureSocksDatasourceProxy && ( )} onOptionsChange({ ...options, jsonData: newValue, }) } /> { onOptionsChange({ ...options, jsonData: { ...options.jsonData, dataLinks: newValue, }, }); }} /> ); };