Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import { produce } from 'immer';
import { DatasourceSelect, DatasourceSelectProps, useDatasource, useDatasourceClient } from '@perses-dev/plugin-system';
import { useId } from '@perses-dev/components';
import { FormControl, InputLabel, Stack, TextField } from '@mui/material';
import { ReactElement } from 'react';
import {
Expand All @@ -39,7 +40,7 @@ export function PrometheusTimeSeriesQueryEditor(props: PrometheusTimeSeriesQuery
const { onChange, value } = props;
const { datasource } = value;
const selectedDatasource = datasource ?? DEFAULT_PROM;
const datasourceSelectLabelID = `prom-datasource-label-${selectedDatasource.name || 'default'}`;
const datasourceSelectLabelID = useId('prom-datasource-label'); // for panels with multiple queries, this component is rendered multiple times on the same page

const { data: client } = useDatasourceClient<PrometheusClient>(selectedDatasource);
const promURL = client?.options.datasourceUrl;
Expand Down Expand Up @@ -71,13 +72,16 @@ export function PrometheusTimeSeriesQueryEditor(props: PrometheusTimeSeriesQuery
return (
<Stack spacing={2}>
<FormControl margin="dense" fullWidth={false}>
<InputLabel id={datasourceSelectLabelID}>Prometheus Datasource</InputLabel>
<InputLabel id={datasourceSelectLabelID} shrink>
Prometheus Datasource
</InputLabel>
<DatasourceSelect
datasourcePluginKind={PROM_DATASOURCE_KIND}
value={selectedDatasource}
onChange={handleDatasourceChange}
labelId={datasourceSelectLabelID}
label="Prometheus Datasource"
notched
/>
</FormControl>
<PromQLEditor
Expand Down
11 changes: 7 additions & 4 deletions tempo/src/plugins/tempo-trace-query/TempoTraceQueryEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// limitations under the License.

import { DatasourceSelect, DatasourceSelectProps, useDatasourceClient } from '@perses-dev/plugin-system';
import { useId } from '@perses-dev/components';
import { produce } from 'immer';
import { FormControl, InputLabel, Stack, TextField } from '@mui/material';
import { ReactElement } from 'react';
Expand All @@ -29,6 +30,7 @@ export function TempoTraceQueryEditor(props: TraceQueryEditorProps): ReactElemen
const { onChange, value } = props;
const { datasource } = value;
const selectedDatasource = datasource ?? DEFAULT_TEMPO;
const datasourceSelectLabelID = useId('tempo-datasource-label'); // for panels with multiple queries, this component is rendered multiple times on the same page

const { data: client } = useDatasourceClient<TempoClient>(selectedDatasource);

Expand All @@ -53,15 +55,16 @@ export function TempoTraceQueryEditor(props: TraceQueryEditorProps): ReactElemen
return (
<Stack spacing={2}>
<FormControl margin="dense" fullWidth={false}>
{/* TODO: How do we ensure unique ID values if there are multiple of these? Can we use React 18 useId and
maintain 17 compatibility somehow with a polyfill/shim? */}
<InputLabel id="tempo-datasource-label">Tempo Datasource</InputLabel>
<InputLabel id={datasourceSelectLabelID} shrink>
Tempo Datasource
</InputLabel>
<DatasourceSelect
datasourcePluginKind={TEMPO_DATASOURCE_KIND}
value={selectedDatasource}
onChange={handleDatasourceChange}
labelId="tempo-datasource-label"
labelId={datasourceSelectLabelID}
label="Tempo Datasource"
notched
/>
</FormControl>
<Stack direction="row" spacing={2}>
Expand Down