// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/configuration/DataSourceHttpSettingsOverhaul.tsx import { DataSourceSettings } from '@grafana/data'; import { Auth, AuthMethod, ConnectionSettings, convertLegacyAuthProps } from '@grafana/plugin-ui'; import { SecureSocksProxySettings, useTheme2 } from '@grafana/ui'; import { PromOptions } from '../types'; import { docsTip, overhaulStyles } from './ConfigEditor'; export type DataSourceHttpSettingsProps = { options: DataSourceSettings; onOptionsChange: (options: DataSourceSettings) => void; secureSocksDSProxyEnabled: boolean; }; export const DataSourceHttpSettingsOverhaul = (props: DataSourceHttpSettingsProps) => { const { options, onOptionsChange, secureSocksDSProxyEnabled } = props; const newAuthProps = convertLegacyAuthProps({ config: options, onChange: onOptionsChange, }); const theme = useTheme2(); const styles = overhaulStyles(theme); function returnSelectedMethod() { return newAuthProps.selectedMethod; } // Do we need this switch anymore? Update the language. let urlTooltip; switch (options.access) { case 'direct': urlTooltip = ( <> Your access method is Browser, this means the URL needs to be accessible from the browser. {docsTip()} ); break; case 'proxy': urlTooltip = ( <> Your access method is Server, this means the URL needs to be accessible from the grafana backend/server. {docsTip()} ); break; default: urlTooltip = <>Specify a complete HTTP URL (for example http://your_server:8080) {docsTip()}; } return ( <>
{ onOptionsChange({ ...options, basicAuth: method === AuthMethod.BasicAuth, withCredentials: method === AuthMethod.CrossSiteCredentials, jsonData: { ...options.jsonData, oauthPassThru: method === AuthMethod.OAuthForward, }, }); }} // If your method is selected pass its id to `selectedMethod`, // otherwise pass the id from converted legacy data selectedMethod={returnSelectedMethod()} />
{secureSocksDSProxyEnabled && ( <>
)} ); };