CloudMonitoring: Add project selector for MQL editor[fix] (#65567)

This commit is contained in:
Alyssa Bull 2023-04-03 08:32:37 -06:00 committed by GitHub
parent 8f282b8a6e
commit 81cb84d098
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 1 deletions

View File

@ -55,4 +55,13 @@ describe('MetricQueryEditor', () => {
const l = await screen.findByLabelText('Project'); const l = await screen.findByLabelText('Project');
expect(l).toBeInTheDocument(); expect(l).toBeInTheDocument();
}); });
it('renders a Project dropdown', async () => {
const query = createMockQuery();
query.queryType = QueryType.TIME_SERIES_QUERY;
render(<MetricQueryEditor {...defaultProps} />);
const projectDropdown = await screen.findByLabelText('Project');
expect(projectDropdown).toBeInTheDocument();
});
}); });

View File

@ -15,6 +15,7 @@ import {
import { GraphPeriod } from './GraphPeriod'; import { GraphPeriod } from './GraphPeriod';
import { MQLQueryEditor } from './MQLQueryEditor'; import { MQLQueryEditor } from './MQLQueryEditor';
import { Project } from './Project';
import { VisualMetricQueryEditor } from './VisualMetricQueryEditor'; import { VisualMetricQueryEditor } from './VisualMetricQueryEditor';
export interface Props { export interface Props {
@ -99,6 +100,13 @@ function Editor({
{query.queryType === QueryType.TIME_SERIES_QUERY && query.timeSeriesQuery && ( {query.queryType === QueryType.TIME_SERIES_QUERY && query.timeSeriesQuery && (
<> <>
<Project
refId={refId}
datasource={datasource}
onChange={(projectName) => onChangeTimeSeriesQuery({ ...query.timeSeriesQuery!, projectName: projectName })}
templateVariableOptions={variableOptionGroup.options}
projectName={query.timeSeriesQuery.projectName!}
/>
<MQLQueryEditor <MQLQueryEditor
onChange={(q: string) => onChangeTimeSeriesQuery({ ...query.timeSeriesQuery!, query: q })} onChange={(q: string) => onChangeTimeSeriesQuery({ ...query.timeSeriesQuery!, query: q })}
onRunQuery={onRunQuery} onRunQuery={onRunQuery}

View File

@ -22,7 +22,6 @@ export function Project({ refId, projectName, datasource, onChange, templateVari
const projectsWithTemplateVariables = useMemo( const projectsWithTemplateVariables = useMemo(
() => [ () => [
projects,
{ {
label: 'Template Variables', label: 'Template Variables',
options: templateVariableOptions, options: templateVariableOptions,