From 45edce90d37b6fc9efcbc4a1d8a25329a43cbd07 Mon Sep 17 00:00:00 2001 From: kay delaney <45561153+kaydelaney@users.noreply.github.com> Date: Wed, 12 Oct 2022 09:43:41 +0100 Subject: [PATCH] VariableEditor: Use new form styles (#56326) --- .betterer.results | 7 +- .../new-constant-variable.spec.ts | 4 +- .../new-custom-variable.spec.ts | 8 +- .../new-datasource-variable.spec.ts | 8 +- .../new-interval-variable.spec.ts | 4 +- .../new-query-variable.spec.ts | 64 ++++---- .../new-text-box-variable.spec.ts | 4 +- .../variables/adhoc/AdHocVariableEditor.tsx | 22 +-- .../constant/ConstantVariableEditor.tsx | 12 +- .../variables/custom/CustomVariableEditor.tsx | 46 +++--- .../DataSourceVariableEditor.test.tsx | 4 +- .../datasource/DataSourceVariableEditor.tsx | 77 ++++----- .../features/variables/datasource/adapter.ts | 2 +- .../editor/LegacyVariableQueryEditor.tsx | 44 ++--- .../editor/SelectionOptionsEditor.tsx | 55 +++---- .../editor/VariableCheckboxField.tsx | 33 ++++ .../variables/editor/VariableEditorEditor.tsx | 122 ++++++-------- .../variables/editor/VariableHideSelect.tsx | 27 ++- .../variables/editor/VariableLegend.tsx | 19 +++ .../variables/editor/VariableSelectField.tsx | 17 +- .../variables/editor/VariableSwitchField.tsx | 32 ---- .../editor/VariableTextAreaField.tsx | 43 +++-- .../variables/editor/VariableTextField.tsx | 34 ++-- .../variables/editor/VariableTypeSelect.tsx | 4 +- .../editor/VariableValuesPreview.tsx | 37 +++-- .../interval/IntervalVariableEditor.tsx | 150 +++++++++-------- .../query/QueryVariableEditor.test.tsx | 2 +- .../variables/query/QueryVariableEditor.tsx | 155 +++++++++--------- .../query/QueryVariableRefreshSelect.tsx | 26 ++- .../query/QueryVariableSortSelect.tsx | 4 +- .../textbox/TextBoxVariableEditor.tsx | 12 +- public/app/features/variables/utils.ts | 3 +- 32 files changed, 521 insertions(+), 560 deletions(-) create mode 100644 public/app/features/variables/editor/VariableCheckboxField.tsx create mode 100644 public/app/features/variables/editor/VariableLegend.tsx delete mode 100644 public/app/features/variables/editor/VariableSwitchField.tsx diff --git a/.betterer.results b/.betterer.results index 75c82e48e5a..0f144b2aac5 100644 --- a/.betterer.results +++ b/.betterer.results @@ -5301,16 +5301,11 @@ exports[`better eslint`] = { [0, 0, 0, "Do not use any type assertions.", "1"] ], "public/app/features/variables/editor/VariableEditorEditor.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"] + [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], "public/app/features/variables/editor/VariableSelectField.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], - "public/app/features/variables/editor/VariableTextAreaField.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"] - ], "public/app/features/variables/editor/getVariableQueryEditor.test.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"], diff --git a/e2e/dashboards-suite/new-constant-variable.spec.ts b/e2e/dashboards-suite/new-constant-variable.spec.ts index 9df1d069df1..928cfb62a61 100644 --- a/e2e/dashboards-suite/new-constant-variable.spec.ts +++ b/e2e/dashboards-suite/new-constant-variable.spec.ts @@ -10,7 +10,9 @@ describe('Variables - Constant', () => { // Create a new "Constant" variable e2e.components.CallToActionCard.buttonV2('Add variable').click(); - e2e.pages.Dashboard.Settings.Variables.Edit.General.generalTypeSelectV2().type('Constant{enter}'); + e2e.pages.Dashboard.Settings.Variables.Edit.General.generalTypeSelectV2().within(() => { + e2e().get('input').type('Constant{enter}'); + }); e2e.pages.Dashboard.Settings.Variables.Edit.General.generalNameInputV2().clear().type('VariableUnderTest').blur(); e2e.pages.Dashboard.Settings.Variables.Edit.General.generalLabelInputV2().type('Variable under test').blur(); e2e.pages.Dashboard.Settings.Variables.Edit.ConstantVariable.constantOptionsQueryInputV2().type('pesto').blur(); diff --git a/e2e/dashboards-suite/new-custom-variable.spec.ts b/e2e/dashboards-suite/new-custom-variable.spec.ts index 85b85fc6387..f5f8018015e 100644 --- a/e2e/dashboards-suite/new-custom-variable.spec.ts +++ b/e2e/dashboards-suite/new-custom-variable.spec.ts @@ -3,7 +3,9 @@ import { e2e } from '@grafana/e2e'; const PAGE_UNDER_TEST = 'kVi2Gex7z/test-variable-output'; function fillInCustomVariable(name: string, label: string, value: string) { - e2e.pages.Dashboard.Settings.Variables.Edit.General.generalTypeSelectV2().type('Custom{enter}'); + e2e.pages.Dashboard.Settings.Variables.Edit.General.generalTypeSelectV2().within(() => { + e2e().get('input').type('Custom{enter}'); + }); e2e.pages.Dashboard.Settings.Variables.Edit.General.generalNameInputV2().clear().type(name).blur(); e2e.pages.Dashboard.Settings.Variables.Edit.General.generalLabelInputV2().type(label).blur(); e2e.pages.Dashboard.Settings.Variables.Edit.CustomVariable.customValueInput().type(value).blur(); @@ -42,7 +44,9 @@ describe('Variables - Custom', () => { // Create a new "Custom" variable e2e.components.CallToActionCard.buttonV2('Add variable').click(); - e2e.pages.Dashboard.Settings.Variables.Edit.General.generalTypeSelectV2().type('Custom{enter}'); + e2e.pages.Dashboard.Settings.Variables.Edit.General.generalTypeSelectV2().within(() => { + e2e().get('input').type('Custom{enter}'); + }); // Set its name, label, and content fillInCustomVariable('VariableUnderTest', 'Variable under test', 'One : 1,Two : 2, Three : 3'); diff --git a/e2e/dashboards-suite/new-datasource-variable.spec.ts b/e2e/dashboards-suite/new-datasource-variable.spec.ts index 0818e7ff4db..8493c03a008 100644 --- a/e2e/dashboards-suite/new-datasource-variable.spec.ts +++ b/e2e/dashboards-suite/new-datasource-variable.spec.ts @@ -9,13 +9,17 @@ describe('Variables - Datasource', () => { // Create a new "Datasource" variable e2e.components.CallToActionCard.buttonV2('Add variable').click(); - e2e.pages.Dashboard.Settings.Variables.Edit.General.generalTypeSelectV2().type('Data source{enter}'); + e2e.pages.Dashboard.Settings.Variables.Edit.General.generalTypeSelectV2().within(() => { + e2e().get('input').type('Data source{enter}'); + }); e2e.pages.Dashboard.Settings.Variables.Edit.General.generalNameInputV2().clear().type('VariableUnderTest').blur(); e2e.pages.Dashboard.Settings.Variables.Edit.General.generalLabelInputV2().type('Variable under test').blur(); // If this is failing, but sure to check there are Prometheus datasources named "gdev-prometheus" and "gdev-slow-prometheus" // Or, just update is to match some gdev datasources to test with :) - e2e.pages.Dashboard.Settings.Variables.Edit.DatasourceVariable.datasourceSelect().type('Prometheus{enter}'); + e2e.pages.Dashboard.Settings.Variables.Edit.DatasourceVariable.datasourceSelect().within(() => { + e2e().get('input').type('Prometheus{enter}'); + }); e2e.pages.Dashboard.Settings.Variables.Edit.General.previewOfValuesOption() .eq(0) .should('have.text', 'gdev-prometheus'); diff --git a/e2e/dashboards-suite/new-interval-variable.spec.ts b/e2e/dashboards-suite/new-interval-variable.spec.ts index c22f40ba865..a3c50d9ec86 100644 --- a/e2e/dashboards-suite/new-interval-variable.spec.ts +++ b/e2e/dashboards-suite/new-interval-variable.spec.ts @@ -16,7 +16,9 @@ describe('Variables - Interval', () => { // Create a new "Interval" variable e2e.components.CallToActionCard.buttonV2('Add variable').click(); - e2e.pages.Dashboard.Settings.Variables.Edit.General.generalTypeSelectV2().type('Interval{enter}'); + e2e.pages.Dashboard.Settings.Variables.Edit.General.generalTypeSelectV2().within(() => { + e2e().get('input').type('Interval{enter}'); + }); e2e.pages.Dashboard.Settings.Variables.Edit.General.generalNameInputV2().clear().type('VariableUnderTest').blur(); e2e.pages.Dashboard.Settings.Variables.Edit.General.generalLabelInputV2().type('Variable under test').blur(); diff --git a/e2e/dashboards-suite/new-query-variable.spec.ts b/e2e/dashboards-suite/new-query-variable.spec.ts index dbc5d16f068..79cbfc9a8c4 100644 --- a/e2e/dashboards-suite/new-query-variable.spec.ts +++ b/e2e/dashboards-suite/new-query-variable.spec.ts @@ -12,7 +12,7 @@ describe('Variables - Query - Add variable', () => { e2e.pages.Dashboard.Settings.Variables.Edit.General.generalNameInputV2() .should('be.visible') .within((input) => { - expect(input.attr('placeholder')).equals('name'); + expect(input.attr('placeholder')).equals('Variable name'); expect(input.val()).equals('query0'); }); e2e.pages.Dashboard.Settings.Variables.Edit.General.generalTypeSelectV2() @@ -23,21 +23,17 @@ describe('Variables - Query - Add variable', () => { e2e.pages.Dashboard.Settings.Variables.Edit.General.generalLabelInputV2() .should('be.visible') .within((input) => { - expect(input.attr('placeholder')).equals('optional display name'); + expect(input.attr('placeholder')).equals('Label name'); expect(input.val()).equals(''); }); e2e() - .get('#Description') + .get('[placeholder="Descriptive text"]') .should('be.visible') .within((input) => { - expect(input.attr('placeholder')).equals('descriptive text'); + expect(input.attr('placeholder')).equals('Descriptive text'); expect(input.val()).equals(''); }); - e2e.pages.Dashboard.Settings.Variables.Edit.General.generalHideSelectV2() - .should('be.visible') - .within((select) => { - e2e.components.Select.singleValue().should('have.text', ''); - }); + e2e().get('label').contains('Show on dashboard').should('be.visible'); e2e.pages.Dashboard.Settings.Variables.Edit.QueryVariable.queryOptionsDataSourceSelect() .should('be.visible') @@ -45,11 +41,9 @@ describe('Variables - Query - Add variable', () => { e2e.components.Select.singleValue().should('have.text', 'gdev-testdata'); }); - e2e.pages.Dashboard.Settings.Variables.Edit.QueryVariable.queryOptionsRefreshSelectV2() - .should('be.visible') - .within((select) => { - e2e.components.Select.singleValue().should('have.text', 'On dashboard load'); - }); + e2e().get('label').contains('Refresh').scrollIntoView().should('be.visible'); + e2e().get('label').contains('On dashboard load').scrollIntoView().should('be.visible'); + e2e.pages.Dashboard.Settings.Variables.Edit.QueryVariable.queryOptionsRegExInputV2() .should('be.visible') .within((input) => { @@ -62,8 +56,18 @@ describe('Variables - Query - Add variable', () => { .within((select) => { e2e.components.Select.singleValue().should('have.text', 'Disabled'); }); - e2e.pages.Dashboard.Settings.Variables.Edit.General.selectionOptionsMultiSwitch().should('not.be.checked'); - e2e.pages.Dashboard.Settings.Variables.Edit.General.selectionOptionsIncludeAllSwitch().should('not.be.checked'); + + e2e() + .contains('label', 'Multi-value') + .within(() => { + e2e().get('input[type="checkbox"]').should('not.be.checked'); + }); + + e2e() + .contains('label', 'Include All option') + .within(() => { + e2e().get('input[type="checkbox"]').should('not.be.checked'); + }); e2e.pages.Dashboard.Settings.Variables.Edit.General.previewOfValuesOption().should('not.exist'); e2e.pages.Dashboard.Settings.Variables.Edit.General.selectionOptionsCustomAllInputV2().should('not.exist'); @@ -80,9 +84,9 @@ describe('Variables - Query - Add variable', () => { .clear() .type('a label'); - e2e().get('#Description').should('be.visible').clear().type('a description'); + e2e().get('[placeholder="Descriptive text"]').should('be.visible').clear().type('a description'); - e2e.components.DataSourcePicker.container().should('be.visible').type('gdev-testdata{enter}'); + e2e.components.DataSourcePicker.inputV2().should('be.visible').type('gdev-testdata{enter}'); e2e.pages.Dashboard.Settings.Variables.Edit.QueryVariable.queryOptionsQueryInput() .should('be.visible') @@ -96,7 +100,7 @@ describe('Variables - Query - Add variable', () => { e2e.pages.Dashboard.Settings.Variables.Edit.General.previewOfValuesOption().should('exist'); - e2e.pages.Dashboard.Settings.Variables.Edit.General.submitButton().should('be.visible').click(); + e2e.pages.Dashboard.Settings.Variables.Edit.General.submitButton().scrollIntoView().should('be.visible').click(); e2e().wait(1500); @@ -130,9 +134,9 @@ describe('Variables - Query - Add variable', () => { .clear() .type('a label'); - e2e().get('#Description').should('be.visible').clear().type('a description'); + e2e().get('[placeholder="Descriptive text"]').should('be.visible').clear().type('a description'); - e2e.components.DataSourcePicker.container().type('gdev-testdata{enter}'); + e2e.components.DataSourcePicker.inputV2().type('gdev-testdata{enter}'); e2e.pages.Dashboard.Settings.Variables.Edit.QueryVariable.queryOptionsQueryInput() .should('be.visible') @@ -144,13 +148,17 @@ describe('Variables - Query - Add variable', () => { .type('/.*C.*/') .blur(); - e2e.pages.Dashboard.Settings.Variables.Edit.General.selectionOptionsMultiSwitch() - .click({ force: true }) - .should('be.checked'); + e2e() + .contains('label', 'Multi-value') + .within(() => { + e2e().get('input[type="checkbox"]').click({ force: true }).should('be.checked'); + }); - e2e.pages.Dashboard.Settings.Variables.Edit.General.selectionOptionsIncludeAllSwitch() - .click({ force: true }) - .should('be.checked'); + e2e() + .contains('label', 'Include All option') + .within(() => { + e2e().get('input[type="checkbox"]').click({ force: true }).should('be.checked'); + }); e2e.pages.Dashboard.Settings.Variables.Edit.General.selectionOptionsCustomAllInputV2().within((input) => { expect(input.attr('placeholder')).equals('blank = auto'); @@ -159,7 +167,7 @@ describe('Variables - Query - Add variable', () => { e2e.pages.Dashboard.Settings.Variables.Edit.General.previewOfValuesOption().should('exist'); - e2e.pages.Dashboard.Settings.Variables.Edit.General.submitButton().should('be.visible').click(); + e2e.pages.Dashboard.Settings.Variables.Edit.General.submitButton().scrollIntoView().should('be.visible').click(); e2e().wait(500); diff --git a/e2e/dashboards-suite/new-text-box-variable.spec.ts b/e2e/dashboards-suite/new-text-box-variable.spec.ts index 7882bc4d128..20b34080900 100644 --- a/e2e/dashboards-suite/new-text-box-variable.spec.ts +++ b/e2e/dashboards-suite/new-text-box-variable.spec.ts @@ -10,7 +10,9 @@ describe('Variables - Text box', () => { // Create a new "text box" variable e2e.components.CallToActionCard.buttonV2('Add variable').click(); - e2e.pages.Dashboard.Settings.Variables.Edit.General.generalTypeSelectV2().type('Text box{enter}'); + e2e.pages.Dashboard.Settings.Variables.Edit.General.generalTypeSelectV2().within(() => { + e2e().get('input').type('Text box{enter}'); + }); e2e.pages.Dashboard.Settings.Variables.Edit.General.generalNameInputV2().clear().type('VariableUnderTest').blur(); e2e.pages.Dashboard.Settings.Variables.Edit.General.generalLabelInputV2().type('Variable under test').blur(); e2e.pages.Dashboard.Settings.Variables.Edit.TextBoxVariable.textBoxOptionsQueryInputV2().type('cat-dog').blur(); diff --git a/public/app/features/variables/adhoc/AdHocVariableEditor.tsx b/public/app/features/variables/adhoc/AdHocVariableEditor.tsx index c82c671d6c9..c5f02f0d712 100644 --- a/public/app/features/variables/adhoc/AdHocVariableEditor.tsx +++ b/public/app/features/variables/adhoc/AdHocVariableEditor.tsx @@ -3,10 +3,10 @@ import { connect, ConnectedProps } from 'react-redux'; import { DataSourceInstanceSettings, getDataSourceRef } from '@grafana/data'; import { DataSourcePicker } from '@grafana/runtime'; -import { Alert, InlineField, InlineFieldRow, VerticalGroup } from '@grafana/ui'; +import { Alert, Field } from '@grafana/ui'; import { StoreState } from 'app/types'; -import { VariableSectionHeader } from '../editor/VariableSectionHeader'; +import { VariableLegend } from '../editor/VariableLegend'; import { initialVariableEditorState } from '../editor/reducer'; import { getAdhocVariableEditorState } from '../editor/selectors'; import { VariableEditorProps } from '../editor/types'; @@ -61,18 +61,14 @@ export class AdHocVariableEditorUnConnected extends PureComponent { const infoText = extended?.infoText ?? null; return ( - - - - - - - - + <> + Ad-hoc options + + + - {infoText ? : null} - - + {infoText ? : null} + ); } } diff --git a/public/app/features/variables/constant/ConstantVariableEditor.tsx b/public/app/features/variables/constant/ConstantVariableEditor.tsx index d5cb25d0e5f..abb49bbd8b8 100644 --- a/public/app/features/variables/constant/ConstantVariableEditor.tsx +++ b/public/app/features/variables/constant/ConstantVariableEditor.tsx @@ -1,9 +1,8 @@ import React, { FormEvent, PureComponent } from 'react'; import { selectors } from '@grafana/e2e-selectors'; -import { VerticalGroup } from '@grafana/ui'; -import { VariableSectionHeader } from '../editor/VariableSectionHeader'; +import { VariableLegend } from '../editor/VariableLegend'; import { VariableTextField } from '../editor/VariableTextField'; import { VariableEditorProps } from '../editor/types'; import { ConstantVariableModel } from '../types'; @@ -28,19 +27,18 @@ export class ConstantVariableEditor extends PureComponent { render() { return ( - - + <> + Constant options - + ); } } diff --git a/public/app/features/variables/custom/CustomVariableEditor.tsx b/public/app/features/variables/custom/CustomVariableEditor.tsx index bdc179bf10a..c64c5a29fe1 100644 --- a/public/app/features/variables/custom/CustomVariableEditor.tsx +++ b/public/app/features/variables/custom/CustomVariableEditor.tsx @@ -2,12 +2,11 @@ import React, { FormEvent, PureComponent } from 'react'; import { MapDispatchToProps, MapStateToProps } from 'react-redux'; import { selectors } from '@grafana/e2e-selectors'; -import { VerticalGroup } from '@grafana/ui'; import { connectWithStore } from 'app/core/utils/connectWithReduxStore'; import { StoreState } from 'app/types'; import { SelectionOptionsEditor } from '../editor/SelectionOptionsEditor'; -import { VariableSectionHeader } from '../editor/VariableSectionHeader'; +import { VariableLegend } from '../editor/VariableLegend'; import { VariableTextAreaField } from '../editor/VariableTextAreaField'; import { OnPropChangeArguments, VariableEditorProps } from '../editor/types'; import { changeVariableMultiValue } from '../state/actions'; @@ -45,29 +44,26 @@ class CustomVariableEditorUnconnected extends PureComponent { render() { return ( - - - - - - - {' '} - - + <> + Custom options + + + Selection options + + ); } } diff --git a/public/app/features/variables/datasource/DataSourceVariableEditor.test.tsx b/public/app/features/variables/datasource/DataSourceVariableEditor.test.tsx index 2c5cd3c3178..661a8671669 100644 --- a/public/app/features/variables/datasource/DataSourceVariableEditor.test.tsx +++ b/public/app/features/variables/datasource/DataSourceVariableEditor.test.tsx @@ -41,13 +41,13 @@ describe('DataSourceVariableEditor', () => { it('has a regex filter field', () => { render(); - const field = screen.getByLabelText('Instance name filter'); + const field = screen.getByLabelText(/Instance name filter/); expect(field).toBeInTheDocument(); }); it('calls the handler when the regex filter is changed', () => { render(); - const field = screen.getByLabelText('Instance name filter'); + const field = screen.getByLabelText(/Instance name filter/); fireEvent.change(field, { target: { value: '/prod/' } }); expect(props.onPropChange).toBeCalledWith({ propName: 'regex', propValue: '/prod/' }); }); diff --git a/public/app/features/variables/datasource/DataSourceVariableEditor.tsx b/public/app/features/variables/datasource/DataSourceVariableEditor.tsx index eacd5f98139..6185d257e9f 100644 --- a/public/app/features/variables/datasource/DataSourceVariableEditor.tsx +++ b/public/app/features/variables/datasource/DataSourceVariableEditor.tsx @@ -3,11 +3,10 @@ import { connect, ConnectedProps } from 'react-redux'; import { SelectableValue } from '@grafana/data'; import { selectors } from '@grafana/e2e-selectors'; -import { InlineFieldRow, VerticalGroup } from '@grafana/ui'; import { StoreState } from '../../../types'; import { SelectionOptionsEditor } from '../editor/SelectionOptionsEditor'; -import { VariableSectionHeader } from '../editor/VariableSectionHeader'; +import { VariableLegend } from '../editor/VariableLegend'; import { VariableSelectField } from '../editor/VariableSelectField'; import { VariableTextField } from '../editor/VariableTextField'; import { initialVariableEditorState } from '../editor/reducer'; @@ -103,48 +102,40 @@ export class DataSourceVariableEditorUnConnected extends PureComponent { const typeValue = typeOptions.find((o) => o.value === variable.query) ?? typeOptions[0]; return ( - - - - - - - - - - Regex filter for which data source instances to choose from in the variable value list. Leave empty - for all. -
-
- Example: /^prod/ - - } - /> -
-
+ <> + Data source options + - -
-
+ + Regex filter for which data source instances to choose from in the variable value list. Leave empty for + all. +
+
+ Example: /^prod/ + + } + /> + + Selection options + + ); } } diff --git a/public/app/features/variables/datasource/adapter.ts b/public/app/features/variables/datasource/adapter.ts index d43b82f403c..e7dea3b79fe 100644 --- a/public/app/features/variables/datasource/adapter.ts +++ b/public/app/features/variables/datasource/adapter.ts @@ -15,7 +15,7 @@ import { dataSourceVariableReducer, initialDataSourceVariableModelState } from ' export const createDataSourceVariableAdapter = (): VariableAdapter => { return { id: 'datasource', - description: 'Enabled you to dynamically switch the data source for multiple panels.', + description: 'Enables you to dynamically switch the data source for multiple panels.', name: 'Data source', initialState: initialDataSourceVariableModelState, reducer: dataSourceVariableReducer, diff --git a/public/app/features/variables/editor/LegacyVariableQueryEditor.tsx b/public/app/features/variables/editor/LegacyVariableQueryEditor.tsx index cee7cae4083..857b43c3ded 100644 --- a/public/app/features/variables/editor/LegacyVariableQueryEditor.tsx +++ b/public/app/features/variables/editor/LegacyVariableQueryEditor.tsx @@ -1,18 +1,17 @@ -import { css } from '@emotion/css'; +import { useId } from '@react-aria/utils'; import React, { FC, useCallback, useState } from 'react'; -import { GrafanaTheme } from '@grafana/data'; import { selectors } from '@grafana/e2e-selectors'; -import { useStyles } from '@grafana/ui'; +import { TextArea, useStyles2 } from '@grafana/ui'; import { VariableQueryEditorProps } from '../types'; -import { VariableTextAreaField } from './VariableTextAreaField'; +import { getStyles } from './VariableTextAreaField'; export const LEGACY_VARIABLE_QUERY_EDITOR_NAME = 'Grafana-LegacyVariableQueryEditor'; export const LegacyVariableQueryEditor: FC = ({ onChange, query }) => { - const styles = useStyles(getStyles); + const styles = useStyles2(getStyles); const [value, setValue] = useState(query); const onValueChange = (event: React.FormEvent) => { setValue(event.currentTarget.value); @@ -25,29 +24,22 @@ export const LegacyVariableQueryEditor: FC = ({ onChan [onChange] ); + const id = useId(); + return ( -
- -
+