1
1
import { DataSourceSettings } from '@grafana/data' ;
2
2
import { Auth , AuthMethod , ConnectionSettings , convertLegacyAuthProps } from '@grafana/experimental' ;
3
+ import { PromOptions , docsTip , overhaulStyles } from '@grafana/prometheus' ;
3
4
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' ;
10
6
11
7
type Props = {
12
8
options : DataSourceSettings < PromOptions , { } > ;
13
9
onOptionsChange : ( options : DataSourceSettings < PromOptions , { } > ) => void ;
14
- sigV4AuthToggleEnabled : boolean | undefined ;
15
10
renderSigV4Editor : React . ReactNode ;
16
11
secureSocksDSProxyEnabled : boolean ;
17
12
} ;
@@ -20,7 +15,6 @@ export const DataSourcehttpSettingsOverhaul = (props: Props) => {
20
15
const {
21
16
options,
22
17
onOptionsChange,
23
- sigV4AuthToggleEnabled,
24
18
renderSigV4Editor,
25
19
secureSocksDSProxyEnabled,
26
20
} = props ;
@@ -47,9 +41,7 @@ export const DataSourcehttpSettingsOverhaul = (props: Props) => {
47
41
component : < > { renderSigV4Editor } </ > ,
48
42
} ;
49
43
50
- if ( sigV4AuthToggleEnabled ) {
51
- customMethods . push ( sigV4Option ) ;
52
- }
44
+ customMethods . push ( sigV4Option ) ;
53
45
54
46
function returnSelectedMethod ( ) {
55
47
if ( sigV4Selected ) {
@@ -94,20 +86,10 @@ export const DataSourcehttpSettingsOverhaul = (props: Props) => {
94
86
/>
95
87
< hr className = { `${ styles . hrTopSpace } ${ styles . hrBottomSpace } ` } />
96
88
< Auth
97
- // Reshaped legacy props
98
89
{ ...newAuthProps }
99
- // Your custom auth methods
100
90
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.
105
91
onAuthMethodSelect = { ( method ) => {
106
- // handle selecting of custom methods
107
- // sigV4Id
108
- if ( sigV4AuthToggleEnabled ) {
109
- setSigV4Selected ( method === sigV4Id ) ;
110
- }
92
+ setSigV4Selected ( method === sigV4Id ) ;
111
93
112
94
onOptionsChange ( {
113
95
...options ,
@@ -134,3 +116,12 @@ export const DataSourcehttpSettingsOverhaul = (props: Props) => {
134
116
</ >
135
117
) ;
136
118
} ;
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
+ } ;
0 commit comments