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>> {
onBlur={onBlur}
openMenuOnFocus={openMenuOnFocus}
maxMenuHeight={maxMenuHeight}
noOptionsMessage={() => noOptionsMessage}
noOptionsMessage={noOptionsMessage}
isMulti={isMulti}
backspaceRemovesValue={backspaceRemovesValue}
menuIsOpen={isOpen}
......
......@@ -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,
......
......@@ -63,8 +63,8 @@ export class QueryEditor extends PureComponent<Props, State> {
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;
......
......@@ -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,
......
......@@ -34,7 +34,7 @@
<p>
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
>
</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