mirror of
https://github.com/grafana/grafana.git
synced 2025-07-30 14:22:48 +08:00
Prometheus: Create Prometheus library (#81641)
* Move to the library * copy from library * move them in src * have additional files * add unmigrated/dulicated code and files * migrate from brendan's pr module.ts, query_hints.ts, tracking.ts, and remove plugin.json * migrate from brendan's pr metric_find_query.test.ts * migrate from brendan's pr language_utils.test.ts * migrate from brendan's pr index.ts in root and in configuration * migrate from brendan's pr datasource.test.ts * migrate from brendan's pr typings folder * migrate from brendan's pr querycache folder * migrate from brendan's pr monaco-query-field folder * migrate from brendan's pr components folder without monaco-query-field folder * migrate from brendan's pr configuration/overhaul folder * migrate from brendan's pr AlertingSettingsOverhaul.tsx * Remove azure related code * migrate from brendan's pr ConfigEditor.tsx, DataSourceHttpSettingsOverhaul.tsx, ExemplarSetting.tsx, configuration/mocks.ts, PromSettings.test.tsx, PromSettings.tsx * migrate from brendan's pr useFlag.ts * migrate from brendan's pr metrics-modal folder * migrate from brendan's pr files inside components folder * migrate from brendan's pr LabelFilters* files because they are now under components folder * migrate from brendan's pr files under querybuilder/shared folder * migrate from brendan's pr aggregations.ts, QueryPattern.tsx, QueryPatternsModal.tsx, state.ts, testUtils.ts under querybuilder folder * Apply Ivana's PR https://github.com/grafana/grafana/pull/81656 * Apply jack's suggestions in this PR https://github.com/grafana/grafana/pull/77762 * Apply Ivana's PR https://github.com/grafana/grafana/pull/81656 * Fix type import * add monaco-promql to transformIgnorePatterns to run prometheus frontend library tests * remove Loki specific tests because we removed Loki code to decouple Loki * add prometheus specific references * We are moving these betterer issues from core Prometheus to the Library and we promise to remove all issues in the future, thank you * include prometheus library in package.json * add yarn lock with prometheus frontend library * decouple final core import from metric_find_query.test.ts * run prettier * fix core imports in promqail * fix lint errors * run prettier * add grafana-ui to devdeps to fix lint errors * update yarn.lock * grafana-ui fix * trying to fix grafana-ui type errors with lerna drone check * trying to fix grafana-ui type errors with lerna drone check * trying to fix grafana-ui type errors with lerna drone check * trying to fix grafana-ui type errors with lerna drone check * try to pass typecheck --------- Co-authored-by: Brendan O'Handley <brendan.ohandley@grafana.com>
This commit is contained in:
@ -0,0 +1,97 @@
|
||||
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';
|
||||
|
||||
type Props = {
|
||||
options: DataSourceSettings<PromOptions, {}>;
|
||||
onOptionsChange: (options: DataSourceSettings<PromOptions, {}>) => void;
|
||||
secureSocksDSProxyEnabled: boolean;
|
||||
};
|
||||
|
||||
export const DataSourcehttpSettingsOverhaul = (props: Props) => {
|
||||
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} />
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
Reference in New Issue
Block a user