Commit 31e2b7e7 by Torkel Ödegaard Committed by GitHub

SharedQuery: Error when switching to -- Dashboard -- data source caused "no…

SharedQuery: Error when switching to -- Dashboard -- data source caused "no data" no matter what source panel was selected (#27627)

* SharedQuery: Error when switching to -- Dashboard -- data source made observable subscription error and subsequent data results not update visualization

* added null check just in case
parent c450ffd7
...@@ -93,11 +93,13 @@ export class PanelQueryRunner { ...@@ -93,11 +93,13 @@ export class PanelQueryRunner {
if (withFieldConfig) { if (withFieldConfig) {
// Apply field defaults & overrides // Apply field defaults & overrides
const fieldConfig = this.dataConfigSource.getFieldOverrideOptions(); const fieldConfig = this.dataConfigSource.getFieldOverrideOptions();
const timeZone = data.request?.timezone ?? 'browser';
if (fieldConfig) { if (fieldConfig) {
processedData = { processedData = {
...processedData, ...processedData,
series: applyFieldOverrides({ series: applyFieldOverrides({
timeZone: data.request!.timezone, timeZone: timeZone,
autoMinMax: true, autoMinMax: true,
data: processedData.series, data: processedData.series,
...fieldConfig, ...fieldConfig,
......
...@@ -2,7 +2,7 @@ import { Observable } from 'rxjs'; ...@@ -2,7 +2,7 @@ import { Observable } from 'rxjs';
import { QueryRunnerOptions } from 'app/features/dashboard/state/PanelQueryRunner'; import { QueryRunnerOptions } from 'app/features/dashboard/state/PanelQueryRunner';
import { DashboardQuery, SHARED_DASHBODARD_QUERY } from './types'; import { DashboardQuery, SHARED_DASHBODARD_QUERY } from './types';
import { getDashboardSrv } from 'app/features/dashboard/services/DashboardSrv'; import { getDashboardSrv } from 'app/features/dashboard/services/DashboardSrv';
import { LoadingState, DefaultTimeRange, DataQuery, PanelData, DataSourceApi } from '@grafana/data'; import { LoadingState, DefaultTimeRange, DataQuery, PanelData, DataSourceApi, DataQueryRequest } from '@grafana/data';
export function isSharedDashboardQuery(datasource: string | DataSourceApi | null) { export function isSharedDashboardQuery(datasource: string | DataSourceApi | null) {
if (!datasource) { if (!datasource) {
...@@ -70,6 +70,7 @@ function getQueryError(msg: string): PanelData { ...@@ -70,6 +70,7 @@ function getQueryError(msg: string): PanelData {
return { return {
state: LoadingState.Error, state: LoadingState.Error,
series: [], series: [],
request: {} as DataQueryRequest,
error: { message: msg }, error: { message: msg },
timeRange: DefaultTimeRange, timeRange: DefaultTimeRange,
}; };
......
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