1
1
import React , { ChangeEvent , PureComponent } from 'react' ;
2
- import { DataSourceHttpSettings , InlineField , InlineSwitch , Input } from '@grafana/ui' ;
2
+ import { DataSourceHttpSettings , InlineField , InlineSwitch , SecretInput } from '@grafana/ui' ;
3
3
import { DataSourcePluginOptionsEditorProps } from '@grafana/data' ;
4
- import { TrinoDataSourceOptions } from './types' ;
4
+ import { TrinoDataSourceOptions , TrinoSecureJsonData } from './types' ;
5
5
6
- interface Props extends DataSourcePluginOptionsEditorProps < TrinoDataSourceOptions > { }
6
+ interface Props extends DataSourcePluginOptionsEditorProps < TrinoDataSourceOptions , TrinoSecureJsonData > { }
7
7
8
8
interface State { }
9
9
@@ -14,8 +14,11 @@ export class ConfigEditor extends PureComponent<Props, State> {
14
14
onOptionsChange ( { ...options , jsonData : { ...options . jsonData , enableImpersonation : event . target . checked } } )
15
15
}
16
16
const onTokenChange = ( event : ChangeEvent < HTMLInputElement > ) => {
17
- onOptionsChange ( { ...options , jsonData : { ...options . jsonData , accessToken : event . target . value } } )
17
+ onOptionsChange ( { ...options , secureJsonData : { ...options . secureJsonData , accessToken : event . target . value } } )
18
18
}
19
+ const onResetToken = ( ) => {
20
+ onOptionsChange ( { ...options , secureJsonFields : { ...options . secureJsonFields , accessToken : false } , secureJsonData : { ...options . secureJsonData , accessToken : '' } } ) ;
21
+ } ;
19
22
return (
20
23
< div className = "gf-form-group" >
21
24
< DataSourceHttpSettings
@@ -41,14 +44,16 @@ export class ConfigEditor extends PureComponent<Props, State> {
41
44
</ div >
42
45
< div className = "gf-form-inline" >
43
46
< InlineField
44
- label = "Access Token "
45
- tooltip = "If set, use the Access Token for authentication to Trino"
47
+ label = "Access token "
48
+ tooltip = "If set, use the access token for authentication to Trino"
46
49
labelWidth = { 26 }
47
50
>
48
- < Input
49
- value = { options . jsonData ?. accessToken || '' }
51
+ < SecretInput
52
+ value = { options . secureJsonData ?. accessToken ?? '' }
53
+ isConfigured = { options . secureJsonFields ?. accessToken }
50
54
onChange = { onTokenChange }
51
55
width = { 40 }
56
+ onReset = { onResetToken }
52
57
/>
53
58
</ InlineField >
54
59
</ div >
0 commit comments