Commit b1186d69 by Zoltán Bedi Committed by GitHub

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
parent b00755a2
...@@ -154,7 +154,7 @@ export class Select<T> extends PureComponent<LegacySelectProps<T>> { ...@@ -154,7 +154,7 @@ export class Select<T> extends PureComponent<LegacySelectProps<T>> {
onBlur={onBlur} onBlur={onBlur}
openMenuOnFocus={openMenuOnFocus} openMenuOnFocus={openMenuOnFocus}
maxMenuHeight={maxMenuHeight} maxMenuHeight={maxMenuHeight}
noOptionsMessage={() => noOptionsMessage} noOptionsMessage={noOptionsMessage}
isMulti={isMulti} isMulti={isMulti}
backspaceRemovesValue={backspaceRemovesValue} backspaceRemovesValue={backspaceRemovesValue}
menuIsOpen={isOpen} menuIsOpen={isOpen}
......
...@@ -24,8 +24,8 @@ export const defaultState: State = { ...@@ -24,8 +24,8 @@ export const defaultState: State = {
labels: {}, labels: {},
}; };
export const defaultQuery: MetricQuery = { export const defaultQuery: (dataSource: CloudMonitoringDatasource) => MetricQuery = dataSource => ({
projectName: '', projectName: dataSource.getDefaultProject(),
metricType: '', metricType: '',
metricKind: '', metricKind: '',
valueType: '', valueType: '',
...@@ -36,7 +36,7 @@ export const defaultQuery: MetricQuery = { ...@@ -36,7 +36,7 @@ export const defaultQuery: MetricQuery = {
groupBys: [], groupBys: [],
filters: [], filters: [],
aliasBy: '', aliasBy: '',
}; });
function Editor({ function Editor({
refId, refId,
......
...@@ -63,8 +63,8 @@ export class QueryEditor extends PureComponent<Props, State> { ...@@ -63,8 +63,8 @@ export class QueryEditor extends PureComponent<Props, State> {
render() { render() {
const { datasource, query, onRunQuery, onChange } = this.props; const { datasource, query, onRunQuery, onChange } = this.props;
const metricQuery = { ...defaultQuery, ...query.metricQuery, projectName: datasource.getDefaultProject() }; const metricQuery = { ...defaultQuery(datasource), ...query.metricQuery };
const sloQuery = { ...defaultSLOQuery, ...query.sloQuery, projectName: datasource.getDefaultProject() }; const sloQuery = { ...defaultSLOQuery(datasource), ...query.sloQuery };
const queryType = query.queryType || QueryType.METRICS; const queryType = query.queryType || QueryType.METRICS;
const meta = this.props.data?.series.length ? this.props.data?.series[0].meta : {}; const meta = this.props.data?.series.length ? this.props.data?.series[0].meta : {};
const usedAlignmentPeriod = meta?.alignmentPeriod; const usedAlignmentPeriod = meta?.alignmentPeriod;
......
...@@ -15,14 +15,14 @@ export interface Props { ...@@ -15,14 +15,14 @@ export interface Props {
datasource: CloudMonitoringDatasource; datasource: CloudMonitoringDatasource;
} }
export const defaultQuery: SLOQuery = { export const defaultQuery: (dataSource: CloudMonitoringDatasource) => SLOQuery = dataSource => ({
projectName: '', projectName: dataSource.getDefaultProject(),
alignmentPeriod: 'cloud-monitoring-auto', alignmentPeriod: 'cloud-monitoring-auto',
aliasBy: '', aliasBy: '',
selectorName: 'select_slo_health', selectorName: 'select_slo_health',
serviceId: '', serviceId: '',
sloId: '', sloId: '',
}; });
export function SLOQueryEditor({ export function SLOQueryEditor({
query, query,
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
<p> <p>
Detailed instructions on how to create a Service Account can be found Detailed instructions on how to create a Service Account can be found
<a class="external-link" target="_blank" href="http://docs.grafana.org/datasources/cloudmonitoring/" <a class="external-link" target="_blank" href="https://grafana.com/docs/grafana/latest/datasources/cloudmonitoring/"
>in the documentation.</a >in the documentation.</a
> >
</p> </p>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment