mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* add history links for monaco completion provider folder * add history links for monaco query field folder * add history links for components folder * add history links for configuration folder * add history links for dashboard json folder * add history links for gcopypaste folder * add history link for variableMigration * add history link for querybuilder/components/metrics-modal folder * add history link for querybuilder/components/promqail folder * add history links for querybuilder/components folder * add history links for querybuilder/hooks folder * add history links for querybuilder/shared folder * add history links for querybuilder folder * add history links for querycache folder * add history links for src folder * use frontend package and custom auth in module.ts * remove files and fix import issues * remove usePrometheusFrontendPackage * remove extra files * update betterer * remove extra files after rebase * fix betterer for rebase * fix e2e flakiness
99 lines
3.2 KiB
TypeScript
99 lines
3.2 KiB
TypeScript
// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/configuration/DataSourceHttpSettingsOverhaul.tsx
|
|
import React from 'react';
|
|
|
|
import { DataSourceSettings } from '@grafana/data';
|
|
import { Auth, AuthMethod, ConnectionSettings, convertLegacyAuthProps } from '@grafana/experimental';
|
|
import { SecureSocksProxySettings, useTheme2 } from '@grafana/ui';
|
|
|
|
import { PromOptions } from '../types';
|
|
|
|
import { docsTip, overhaulStyles } from './ConfigEditor';
|
|
|
|
export type DataSourceHttpSettingsProps = {
|
|
options: DataSourceSettings<PromOptions, {}>;
|
|
onOptionsChange: (options: DataSourceSettings<PromOptions, {}>) => 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 <em>Browser</em>, this means the URL needs to be accessible from the browser.
|
|
{docsTip()}
|
|
</>
|
|
);
|
|
break;
|
|
case 'proxy':
|
|
urlTooltip = (
|
|
<>
|
|
Your access method is <em>Server</em>, 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 (
|
|
<>
|
|
<ConnectionSettings
|
|
urlPlaceholder="http://localhost:9090"
|
|
config={options}
|
|
onChange={onOptionsChange}
|
|
urlLabel="Prometheus server URL"
|
|
urlTooltip={urlTooltip}
|
|
/>
|
|
<hr className={`${styles.hrTopSpace} ${styles.hrBottomSpace}`} />
|
|
<Auth
|
|
// Reshaped legacy props
|
|
{...newAuthProps}
|
|
// Still need to call `onAuthMethodSelect` function from
|
|
// `newAuthProps` to store the legacy data correctly.
|
|
// Also make sure to store the data about your component
|
|
// being selected/unselected.
|
|
onAuthMethodSelect={(method) => {
|
|
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()}
|
|
/>
|
|
<div className={styles.sectionBottomPadding} />
|
|
{secureSocksDSProxyEnabled && (
|
|
<>
|
|
<SecureSocksProxySettings options={options} onOptionsChange={onOptionsChange} />
|
|
<div className={styles.sectionBottomPadding} />
|
|
</>
|
|
)}
|
|
</>
|
|
);
|
|
};
|