Skip to content

Commit f667914

Browse files
committed
use config section with sigV4
1 parent 48396d9 commit f667914

File tree

3 files changed

+18
-34
lines changed

3 files changed

+18
-34
lines changed

src/configuration/ConfigEditor.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
import { css } from '@emotion/css';
22
import { SIGV4ConnectionConfig } from '@grafana/aws-sdk';
33
import { DataSourcePluginOptionsEditorProps, GrafanaTheme2 } from '@grafana/data';
4-
import { ConfigSection, DataSourceDescription } from '@grafana/experimental';
4+
import { AdvancedHttpSettings, ConfigSection, DataSourceDescription } from '@grafana/experimental';
5+
import { AlertingSettingsOverhaul, PromOptions, PromSettings } from '@grafana/prometheus';
56
import { config } from '@grafana/runtime';
67
import { Alert, FieldValidationMessage, useTheme2 } from '@grafana/ui';
78
import React from 'react';
89

9-
import { PromOptions } from '../types';
10-
11-
import { AlertingSettingsOverhaul } from './AlertingSettingsOverhaul';
1210
import { DataSourcehttpSettingsOverhaul } from './DataSourceHttpSettingsOverhaul';
13-
import { PromSettings } from './PromSettings';
14-
import { AdvancedHttpSettings } from './overhaul/AdvancedHttpSettings';
1511

1612
export const PROM_CONFIG_LABEL_WIDTH = 30;
1713

@@ -37,7 +33,6 @@ export const ConfigEditor = (props: Props) => {
3733
<DataSourcehttpSettingsOverhaul
3834
options={options}
3935
onOptionsChange={onOptionsChange}
40-
sigV4AuthToggleEnabled={config.sigV4AuthEnabled}
4136
renderSigV4Editor={<SIGV4ConnectionConfig {...props}></SIGV4ConnectionConfig>}
4237
secureSocksDSProxyEnabled={config.secureSocksDSProxyEnabled}
4338
/>

src/configuration/DataSourceHttpSettingsOverhaul.tsx

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
import { DataSourceSettings } from '@grafana/data';
22
import { Auth, AuthMethod, ConnectionSettings, convertLegacyAuthProps } from '@grafana/experimental';
3+
import { PromOptions, docsTip, overhaulStyles } from '@grafana/prometheus';
34
import { SecureSocksProxySettings, useTheme2 } from '@grafana/ui';
4-
import React, { useState } from 'react';
5-
6-
import { PromOptions } from '../types';
7-
8-
import { docsTip, overhaulStyles } from './ConfigEditor';
9-
import { CustomMethod } from './overhaul/types';
5+
import React, { ReactElement, useState } from 'react';
106

117
type Props = {
128
options: DataSourceSettings<PromOptions, {}>;
139
onOptionsChange: (options: DataSourceSettings<PromOptions, {}>) => void;
14-
sigV4AuthToggleEnabled: boolean | undefined;
1510
renderSigV4Editor: React.ReactNode;
1611
secureSocksDSProxyEnabled: boolean;
1712
};
@@ -20,7 +15,6 @@ export const DataSourcehttpSettingsOverhaul = (props: Props) => {
2015
const {
2116
options,
2217
onOptionsChange,
23-
sigV4AuthToggleEnabled,
2418
renderSigV4Editor,
2519
secureSocksDSProxyEnabled,
2620
} = props;
@@ -47,9 +41,7 @@ export const DataSourcehttpSettingsOverhaul = (props: Props) => {
4741
component: <>{renderSigV4Editor}</>,
4842
};
4943

50-
if (sigV4AuthToggleEnabled) {
51-
customMethods.push(sigV4Option);
52-
}
44+
customMethods.push(sigV4Option);
5345

5446
function returnSelectedMethod() {
5547
if (sigV4Selected) {
@@ -94,20 +86,10 @@ export const DataSourcehttpSettingsOverhaul = (props: Props) => {
9486
/>
9587
<hr className={`${styles.hrTopSpace} ${styles.hrBottomSpace}`} />
9688
<Auth
97-
// Reshaped legacy props
9889
{...newAuthProps}
99-
// Your custom auth methods
10090
customMethods={customMethods}
101-
// Still need to call `onAuthMethodSelect` function from
102-
// `newAuthProps` to store the legacy data correctly.
103-
// Also make sure to store the data about your component
104-
// being selected/unselected.
10591
onAuthMethodSelect={(method) => {
106-
// handle selecting of custom methods
107-
// sigV4Id
108-
if (sigV4AuthToggleEnabled) {
109-
setSigV4Selected(method === sigV4Id);
110-
}
92+
setSigV4Selected(method === sigV4Id);
11193

11294
onOptionsChange({
11395
...options,
@@ -134,3 +116,12 @@ export const DataSourcehttpSettingsOverhaul = (props: Props) => {
134116
</>
135117
);
136118
};
119+
120+
export type CustomMethodId = `custom-${string}`;
121+
122+
export type CustomMethod = {
123+
id: CustomMethodId;
124+
label: string;
125+
description: string;
126+
component: ReactElement;
127+
};

src/module.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import { DataSourcePlugin } from '@grafana/data';
2-
import { ConfigEditor, PromQueryEditorByApp, PrometheusDatasource, PromCheatSheet } from '@grafana/prometheus';
2+
import { PromQueryEditorByApp, PrometheusDatasource, PromCheatSheet } from '@grafana/prometheus';
33

4-
// import PromCheatSheet from './components/PromCheatSheet';
5-
// import PromQueryEditorByApp from './components/PromQueryEditorByApp';
6-
// import { ConfigEditor } from './configuration/ConfigEditor';
7-
// import { PrometheusDatasource } from './datasource';
4+
// custom config made with sigV4 auth
5+
import { ConfigEditor } from './configuration/ConfigEditor';
86

97
// @ts-ignore
108
export const plugin = new DataSourcePlugin(PrometheusDatasource)

0 commit comments

Comments
 (0)