Skip to content
This repository was archived by the owner on Aug 4, 2025. It is now read-only.

Commit 71736c4

Browse files
committed
remove apikey
1 parent edab064 commit 71736c4

2 files changed

Lines changed: 5 additions & 46 deletions

File tree

src/ConfigEditor.tsx

Lines changed: 4 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,15 @@
11
import React, { ChangeEvent, PureComponent } from 'react';
22
import { LegacyForms } from '@grafana/ui';
33
import { DataSourcePluginOptionsEditorProps } from '@grafana/data';
4-
import { MyDataSourceOptions, MySecureJsonData } from './types';
4+
import { MyDataSourceOptions } from './types';
55

6-
const { SecretFormField, FormField } = LegacyForms;
6+
const { FormField } = LegacyForms;
77

88
interface Props extends DataSourcePluginOptionsEditorProps<MyDataSourceOptions> {}
99

1010
interface State {}
1111

1212
export class ConfigEditor extends PureComponent<Props, State> {
13-
// Secure field (only sent to the backend)
14-
onAPIKeyChange = (event: ChangeEvent<HTMLInputElement>) => {
15-
const { onOptionsChange, options } = this.props;
16-
onOptionsChange({
17-
...options,
18-
secureJsonData: {
19-
apiKey: event.target.value,
20-
},
21-
});
22-
};
23-
24-
onResetAPIKey = () => {
25-
const { onOptionsChange, options } = this.props;
26-
onOptionsChange({
27-
...options,
28-
secureJsonFields: {
29-
...options.secureJsonFields,
30-
apiKey: false,
31-
},
32-
secureJsonData: {
33-
...options.secureJsonData,
34-
apiKey: '',
35-
},
36-
});
37-
};
3813
onURLChange = (event: ChangeEvent<HTMLInputElement>) => {
3914
const { onOptionsChange, options } = this.props;
4015
const jsonData = {
@@ -46,8 +21,8 @@ export class ConfigEditor extends PureComponent<Props, State> {
4621

4722
render() {
4823
const { options } = this.props;
49-
const { jsonData, secureJsonFields } = options;
50-
const secureJsonData = (options.secureJsonData || {}) as MySecureJsonData;
24+
const { jsonData } = options;
25+
//const secureJsonData = (options.secureJsonData || {}) as MySecureJsonData;
5126

5227
return (
5328
<div className="gf-form-group">
@@ -59,20 +34,6 @@ export class ConfigEditor extends PureComponent<Props, State> {
5934
placeholder="http://localhost:5000"
6035
/>
6136
</div>
62-
<div className="gf-form-inline">
63-
<div className="gf-form">
64-
<SecretFormField
65-
isConfigured={(secureJsonFields && secureJsonFields.apiKey) as boolean}
66-
value={secureJsonData.apiKey || ''}
67-
label="API Key"
68-
placeholder="secure json field (backend only)"
69-
labelWidth={6}
70-
inputWidth={20}
71-
onReset={this.onResetAPIKey}
72-
onChange={this.onAPIKeyChange}
73-
/>
74-
</div>
75-
</div>
7637
</div>
7738
);
7839
}

src/types.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,4 @@ export interface MyDataSourceOptions extends DataSourceJsonData {
1616
/**
1717
* Value that is used in the backend, but never sent over HTTP to the frontend
1818
*/
19-
export interface MySecureJsonData {
20-
apiKey?: string;
21-
}
19+
export interface MySecureJsonData {}

0 commit comments

Comments
 (0)