[v11.2.x] Prometheus: Variable query editor, display selected label when using query type of label values (#92932)
Prometheus: Variable query editor, display selected label when using query type of label values (#92513)
display label, add test
(cherry picked from commit 4bf350cc62)
Co-authored-by: Brendan O'Handley <brendan.ohandley@grafana.com>
This commit is contained in:
co-authored by
Brendan O'Handley
parent
53508d4a84
commit
0a0e41a085
@@ -265,6 +265,8 @@ describe('PromVariableQueryEditor', () => {
|
|||||||
const labelSelect = screen.getByLabelText('label-select');
|
const labelSelect = screen.getByLabelText('label-select');
|
||||||
await userEvent.type(labelSelect, 'this');
|
await userEvent.type(labelSelect, 'this');
|
||||||
await selectOptionInTest(labelSelect, 'this');
|
await selectOptionInTest(labelSelect, 'this');
|
||||||
|
//display label in label select
|
||||||
|
await waitFor(() => expect(screen.getByText('this')).toBeInTheDocument());
|
||||||
|
|
||||||
await waitFor(() =>
|
await waitFor(() =>
|
||||||
expect(onChange).toHaveBeenCalledWith({
|
expect(onChange).toHaveBeenCalledWith({
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
import debounce from 'debounce-promise';
|
import debounce from 'debounce-promise';
|
||||||
import { FormEvent, useCallback, useEffect, useState } from 'react';
|
import { FormEvent, useCallback, useEffect, useState } from 'react';
|
||||||
|
|
||||||
import { QueryEditorProps, SelectableValue } from '@grafana/data';
|
import { QueryEditorProps, SelectableValue, toOption } from '@grafana/data';
|
||||||
import { selectors } from '@grafana/e2e-selectors';
|
import { selectors } from '@grafana/e2e-selectors';
|
||||||
import { AsyncSelect, InlineField, InlineFieldRow, Input, Select, TextArea } from '@grafana/ui';
|
import { AsyncSelect, InlineField, InlineFieldRow, Input, Select, TextArea } from '@grafana/ui';
|
||||||
|
|
||||||
@@ -286,7 +286,7 @@ export const PromVariableQueryEditor = ({ onChange, query, datasource, range }:
|
|||||||
<AsyncSelect
|
<AsyncSelect
|
||||||
aria-label="label-select"
|
aria-label="label-select"
|
||||||
onChange={onLabelChange}
|
onChange={onLabelChange}
|
||||||
value={label}
|
value={label ? toOption(label) : null}
|
||||||
defaultOptions={truncatedLabelOptions}
|
defaultOptions={truncatedLabelOptions}
|
||||||
width={25}
|
width={25}
|
||||||
allowCustomValue
|
allowCustomValue
|
||||||
|
|||||||
Reference in New Issue
Block a user