Skip to content

Commit 2e2dc95

Browse files
committed
Remove some deprecated componentes from Grafana UI library
* SecretFormField replaced by SecretInput + InlineField * FormField replaced by Input + InlineField Altought `Select` is deprecated, the replacement component `Combobox` is marked as alpha, so we will keep using Select and AsyncSelect a little more.
1 parent 4f93222 commit 2e2dc95

File tree

3 files changed

+41
-30
lines changed

3 files changed

+41
-30
lines changed

src/ui/ConfigEditor.tsx

Lines changed: 39 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import { DataSourcePluginOptionsEditorProps, SelectableValue } from '@grafana/data';
2-
import { FieldSet, InlineField, LegacyForms, Select } from '@grafana/ui';
2+
/* Select is deprecated, but Combobox is still alpha, so no changes for now */
3+
import { FieldSet, InlineField, Input, SecretInput, Select } from '@grafana/ui';
34
import { EditionFamilyLabel } from 'edition';
45
import React, { ChangeEvent, useCallback } from 'react';
56

67
import { Settings } from '../settings';
78
import { DataSourceOptions, Edition, SecureJsonData } from '../types';
89

9-
const { SecretFormField, FormField } = LegacyForms;
10-
1110
// eslint-disable-next-line @typescript-eslint/no-empty-interface
1211
interface Props extends DataSourcePluginOptionsEditorProps<DataSourceOptions, SecureJsonData> {}
1312

@@ -96,19 +95,23 @@ export const ConfigEditor = (props: Props) => {
9695
<>
9796
<FieldSet label="Monitoring Site">
9897
<div className="gf-form">
99-
<FormField
98+
<InlineField
10099
label="URL"
101-
labelWidth={6}
102-
inputWidth={20}
103-
onChange={onUrlChange}
104-
value={settings.url || ''}
100+
labelWidth={12}
105101
tooltip="Which Checkmk Server to connect to. (Example: https://checkmk.server/site)"
106-
data-test-id="checkmk-url"
107-
/>
102+
>
103+
<Input
104+
label="URL"
105+
width={40}
106+
onChange={onUrlChange}
107+
value={settings.url || ''}
108+
data-test-id="checkmk-url"
109+
/>
110+
</InlineField>
108111
</div>
109112
<InlineField label="Edition" labelWidth={12}>
110113
<Select
111-
width={32}
114+
width={40}
112115
options={cmkEditions}
113116
onChange={onEditionChange}
114117
value={settings.edition}
@@ -120,29 +123,37 @@ export const ConfigEditor = (props: Props) => {
120123
</FieldSet>
121124
<FieldSet label="Authentication">
122125
<div className="gf-form">
123-
<FormField
126+
<InlineField
124127
label="Username"
125-
labelWidth={6}
126-
inputWidth={20}
127-
onChange={onUsernameChange}
128-
value={settings.username}
128+
labelWidth={12}
129129
tooltip="A checkmk monitoring user. Don't use 'automation' user, because it has admin rights."
130-
data-test-id="checkmk-username"
131-
/>
130+
>
131+
<Input
132+
label="Username"
133+
width={40}
134+
onChange={onUsernameChange}
135+
value={settings.username}
136+
data-test-id="checkmk-username"
137+
/>
138+
</InlineField>
132139
</div>
133140
<div className="gf-form">
134-
<SecretFormField
135-
isConfigured={(secureJsonFields && secureJsonFields.secret) as boolean}
136-
value={secureJsonData.secret || ''}
141+
<InlineField
137142
label="Secret"
138-
placeholder=""
139-
labelWidth={6}
140-
inputWidth={20}
141-
onReset={onResetSecret}
142-
onChange={onSecretChange}
143+
labelWidth={12}
143144
tooltip="You can find the secret for your user in your checkmk server under Users."
144-
data-test-id="checkmk-password"
145-
/>
145+
>
146+
<SecretInput
147+
isConfigured={(secureJsonFields && secureJsonFields.secret) as boolean}
148+
value={secureJsonData.secret || ''}
149+
label="Secret"
150+
placeholder=""
151+
width={40}
152+
onReset={onResetSecret}
153+
onChange={onSecretChange}
154+
data-test-id="checkmk-password"
155+
/>
156+
</InlineField>
146157
</div>
147158
</FieldSet>
148159
</>

src/ui/components.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export const CheckMkGenericAsyncSelect = function <Value extends string | (strin
8585
for (const variable of getTemplateSrv().getVariables()) {
8686
const variableId = variable?.id || variable.name;
8787
data.splice(0, 0, {
88-
value: `$${variableId}` as Value,
88+
value: `$${variableId}` as NonNullable<Value>,
8989
label: `$${variableId}`,
9090
isGrafanaVariable: true,
9191
});

tests/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ services:
88
- ./checkmk-docker-hooks:/docker-entrypoint.d
99

1010
grafana:
11-
image: grafana/grafana-oss:latest
11+
image: grafana/grafana-oss:${GRAFANA_VERSION:-latest}
1212
container_name: grafana
1313
volumes:
1414
- ../dist:/var/lib/grafana/plugins/grafana-checkmk-datasource

0 commit comments

Comments
 (0)