From b1186d693a5a6333d69e8dd7c1d594f9ab865aff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Bedi?= Date: Sat, 3 Oct 2020 11:55:09 +0200 Subject: [PATCH] Stackdriver: fix project name change regression (#27909) * Update stackdriver query editor not to overwrite project name * Fix legacy select form no options didn't show * Update config link to docs --- .../src/components/Forms/Legacy/Select/Select.tsx | 2 +- .../cloud-monitoring/components/MetricQueryEditor.tsx | 6 +++--- .../datasource/cloud-monitoring/components/QueryEditor.tsx | 4 ++-- .../cloud-monitoring/components/SLOQueryEditor.tsx | 6 +++--- .../datasource/cloud-monitoring/partials/config.html | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/grafana-ui/src/components/Forms/Legacy/Select/Select.tsx b/packages/grafana-ui/src/components/Forms/Legacy/Select/Select.tsx index 94a1c05eaaa..fe059064bfc 100644 --- a/packages/grafana-ui/src/components/Forms/Legacy/Select/Select.tsx +++ b/packages/grafana-ui/src/components/Forms/Legacy/Select/Select.tsx @@ -154,7 +154,7 @@ export class Select extends PureComponent> { onBlur={onBlur} openMenuOnFocus={openMenuOnFocus} maxMenuHeight={maxMenuHeight} - noOptionsMessage={() => noOptionsMessage} + noOptionsMessage={noOptionsMessage} isMulti={isMulti} backspaceRemovesValue={backspaceRemovesValue} menuIsOpen={isOpen} diff --git a/public/app/plugins/datasource/cloud-monitoring/components/MetricQueryEditor.tsx b/public/app/plugins/datasource/cloud-monitoring/components/MetricQueryEditor.tsx index 9ebc00e3880..4b23cc69353 100644 --- a/public/app/plugins/datasource/cloud-monitoring/components/MetricQueryEditor.tsx +++ b/public/app/plugins/datasource/cloud-monitoring/components/MetricQueryEditor.tsx @@ -24,8 +24,8 @@ export const defaultState: State = { labels: {}, }; -export const defaultQuery: MetricQuery = { - projectName: '', +export const defaultQuery: (dataSource: CloudMonitoringDatasource) => MetricQuery = dataSource => ({ + projectName: dataSource.getDefaultProject(), metricType: '', metricKind: '', valueType: '', @@ -36,7 +36,7 @@ export const defaultQuery: MetricQuery = { groupBys: [], filters: [], aliasBy: '', -}; +}); function Editor({ refId, diff --git a/public/app/plugins/datasource/cloud-monitoring/components/QueryEditor.tsx b/public/app/plugins/datasource/cloud-monitoring/components/QueryEditor.tsx index d07df06828a..02eb2041cc7 100644 --- a/public/app/plugins/datasource/cloud-monitoring/components/QueryEditor.tsx +++ b/public/app/plugins/datasource/cloud-monitoring/components/QueryEditor.tsx @@ -63,8 +63,8 @@ export class QueryEditor extends PureComponent { render() { const { datasource, query, onRunQuery, onChange } = this.props; - const metricQuery = { ...defaultQuery, ...query.metricQuery, projectName: datasource.getDefaultProject() }; - const sloQuery = { ...defaultSLOQuery, ...query.sloQuery, projectName: datasource.getDefaultProject() }; + const metricQuery = { ...defaultQuery(datasource), ...query.metricQuery }; + const sloQuery = { ...defaultSLOQuery(datasource), ...query.sloQuery }; const queryType = query.queryType || QueryType.METRICS; const meta = this.props.data?.series.length ? this.props.data?.series[0].meta : {}; const usedAlignmentPeriod = meta?.alignmentPeriod; diff --git a/public/app/plugins/datasource/cloud-monitoring/components/SLOQueryEditor.tsx b/public/app/plugins/datasource/cloud-monitoring/components/SLOQueryEditor.tsx index 87145878f88..30e6e5651a5 100644 --- a/public/app/plugins/datasource/cloud-monitoring/components/SLOQueryEditor.tsx +++ b/public/app/plugins/datasource/cloud-monitoring/components/SLOQueryEditor.tsx @@ -15,14 +15,14 @@ export interface Props { datasource: CloudMonitoringDatasource; } -export const defaultQuery: SLOQuery = { - projectName: '', +export const defaultQuery: (dataSource: CloudMonitoringDatasource) => SLOQuery = dataSource => ({ + projectName: dataSource.getDefaultProject(), alignmentPeriod: 'cloud-monitoring-auto', aliasBy: '', selectorName: 'select_slo_health', serviceId: '', sloId: '', -}; +}); export function SLOQueryEditor({ query, diff --git a/public/app/plugins/datasource/cloud-monitoring/partials/config.html b/public/app/plugins/datasource/cloud-monitoring/partials/config.html index b8e0124be79..df4e95a82ca 100644 --- a/public/app/plugins/datasource/cloud-monitoring/partials/config.html +++ b/public/app/plugins/datasource/cloud-monitoring/partials/config.html @@ -34,7 +34,7 @@

Detailed instructions on how to create a Service Account can be found - in the documentation.