[v9.4.x] CloudMonitoring: Add project selector for MQL editor[fix] (#65844)

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

(cherry picked from commit 81cb84d098)

Co-authored-by: Alyssa Bull <58453566+alyssabull@users.noreply.github.com>
This commit is contained in:
Grot (@grafanabot)
2023-04-06 20:10:29 +00:00
committed by GitHub
co-authored by Alyssa Bull
parent b0c69c9eec
commit cd323622b7
3 changed files with 17 additions and 1 deletions
@@ -55,4 +55,13 @@ describe('MetricQueryEditor', () => {
const l = await screen.findByLabelText('Project');
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();
});
});
@@ -15,6 +15,7 @@ import {
import { GraphPeriod } from './GraphPeriod';
import { MQLQueryEditor } from './MQLQueryEditor';
import { Project } from './Project';
import { VisualMetricQueryEditor } from './VisualMetricQueryEditor';
export interface Props {
@@ -99,6 +100,13 @@ function Editor({
{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
onChange={(q: string) => onChangeTimeSeriesQuery({ ...query.timeSeriesQuery!, query: q })}
onRunQuery={onRunQuery}
@@ -22,7 +22,6 @@ export function Project({ refId, projectName, datasource, onChange, templateVari
const projectsWithTemplateVariables = useMemo(
() => [
projects,
{
label: 'Template Variables',
options: templateVariableOptions,