Chore: Remove deprecated dashboardId from panel query runner (#64786)

This commit is contained in:
Ryan McKinley 2023-04-14 16:50:10 -07:00 committed by GitHub
parent d43482a463
commit 39c04a8e36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
27 changed files with 17 additions and 43 deletions

View File

@ -43,7 +43,7 @@ export class AnnotationChangeEvent extends BusEventWithPayload<Partial<Annotatio
// Loaded the first time a dashboard is loaded (not on every render)
export type DashboardLoadedEventPayload<T> = {
dashboardId: string;
dashboardId: string; // eeep, this should be UID
orgId?: number;
userId?: number;
grafanaVersion?: string;

View File

@ -514,8 +514,6 @@ export interface DataQueryRequest<TQuery extends DataQuery = DataQuery> {
rangeRaw?: RawTimeRange;
timeInfo?: string; // The query time description (blue text in the upper right)
panelId?: number;
/** @deprecate */
dashboardId?: number;
dashboardUID?: string;
publicDashboardAccessToken?: string;

View File

@ -15,7 +15,7 @@ export interface QueryRunnerOptions {
datasource: DataSourceRef | DataSourceApi | null;
queries: DataQuery[];
panelId?: number;
dashboardId?: number;
dashboardUID?: string;
timezone: TimeZone;
timeRange: TimeRange;
timeInfo?: string; // String description of time range for display

View File

@ -9,6 +9,7 @@ import { EchoEvent, EchoEventType } from '../services/EchoSrv';
* @public
*/
export interface DashboardInfo {
/** @deprecated -- use UID not internal ID */
dashboardId: number;
dashboardUid: string;
dashboardName: string;

View File

@ -140,7 +140,8 @@ func newTestLive(t *testing.T, store db.DB) *live.GrafanaLive {
func TestDashboardAPIEndpoint(t *testing.T) {
t.Run("Given a dashboard with a parent folder which does not have an ACL", func(t *testing.T) {
fakeDash := dashboards.NewDashboard("Child dash")
fakeDash.ID = 1
fakeDash.SetID(1)
fakeDash.SetUID("test-uid-one")
fakeDash.FolderID = 1
fakeDash.HasACL = false
fakeDashboardVersionService := dashvertest.NewDashboardVersionServiceFake()
@ -188,6 +189,7 @@ func TestDashboardAPIEndpoint(t *testing.T) {
sc.sqlStore = mockSQLStore
dash := getDashboardShouldReturn200WithConfig(t, sc, nil, nil, dashboardService, nil)
assert.Equal(t, fakeDash.UID, dash.Dashboard.Get("uid").MustString())
assert.False(t, dash.Meta.CanEdit)
assert.False(t, dash.Meta.CanSave)
assert.False(t, dash.Meta.CanAdmin)

View File

@ -14,7 +14,7 @@ export function getQueryOptions<TQuery extends DataQuery>(
scopedVars: {},
timezone: 'browser',
panelId: 1,
dashboardId: 1,
dashboardUID: 'test-uid-1',
interval: '60s',
intervalMs: 60000,
maxDataPoints: 500,

View File

@ -194,7 +194,7 @@ class MetricsPanelCtrl extends PanelCtrl {
datasource: panel.datasource,
queries: panel.targets,
panelId: panel.id,
dashboardId: this.dashboard.id,
dashboardUID: this.dashboard.uid,
timezone: this.dashboard.getTimezone(),
timeInfo: this.timeInfo,
timeRange: this.range,

View File

@ -142,7 +142,6 @@ export function buildQueryTransaction(
const request: DataQueryRequest = {
app: CoreApp.Explore,
dashboardId: 0,
// TODO probably should be taken from preferences but does not seem to be used anyway.
timezone: timeZone || DefaultTimeZone,
startTime: Date.now(),

View File

@ -146,7 +146,6 @@ describe('PanelEditorTableView', () => {
// panel queries should have the updated time range
expect(props.panel.runAllPanelQueries).toHaveBeenNthCalledWith(1, {
dashboardId: props.dashboard.id,
dashboardTimezone: '',
dashboardUID: props.dashboard.uid,
timeData: timeRangeUpdated,
@ -167,7 +166,6 @@ describe('PanelEditorTableView', () => {
// panel queries should have the updated time range
expect(props.panel.runAllPanelQueries).toHaveBeenLastCalledWith({
dashboardId: props.dashboard.id,
dashboardTimezone: '',
dashboardUID: props.dashboard.uid,
timeData: timeRangeUpdated2,

View File

@ -34,7 +34,6 @@ export function PanelEditorTableView({ width, height, panel, dashboard }: Props)
const sub = panel.events.subscribe(RefreshEvent, () => {
const timeData = applyPanelTimeOverrides(panel, timeSrv.timeRange());
panel.runAllPanelQueries({
dashboardId: dashboard.id,
dashboardUID: dashboard.uid,
dashboardTimezone: dashboard.getTimezone(),
timeData,

View File

@ -348,7 +348,6 @@ export class PanelStateWrapper extends PureComponent<Props, State> {
this.setState({ refreshWhenInView: false });
}
panel.runAllPanelQueries({
dashboardId: dashboard.id,
dashboardUID: dashboard.uid,
dashboardTimezone: dashboard.getTimezone(),
publicDashboardAccessToken: dashboard.meta.publicDashboardAccessToken,

View File

@ -68,6 +68,7 @@ export interface DashboardLink {
}
export class DashboardModel implements TimeModel {
/** @deprecated use UID */
id: any;
// TODO: use propert type and fix all the places where uid is set to null
uid: any;

View File

@ -45,8 +45,6 @@ export interface GridPos {
}
type RunPanelQueryOptions = {
/** @deprecate */
dashboardId: number;
dashboardUID: string;
dashboardTimezone: string;
timeData: TimeOverrideResult;
@ -340,7 +338,6 @@ export class PanelModel implements DataConfigSource, IPanelModel {
}
runAllPanelQueries({
dashboardId,
dashboardUID,
dashboardTimezone,
timeData,
@ -351,7 +348,6 @@ export class PanelModel implements DataConfigSource, IPanelModel {
datasource: this.datasource,
queries: this.targets,
panelId: this.id,
dashboardId: dashboardId,
dashboardUID: dashboardUID,
publicDashboardAccessToken,
timezone: dashboardTimezone,

View File

@ -4,6 +4,7 @@ import { DashboardModel } from './DashboardModel';
export function emitDashboardViewEvent(dashboard: DashboardModel) {
const eventData: DashboardViewEventPayload = {
/** @deprecated */
dashboardId: dashboard.id,
dashboardName: dashboard.title,
dashboardUid: dashboard.uid,

View File

@ -23,7 +23,6 @@ const makeEmptyQueryResponse = (loadingState: LoadingState) => {
requestId: '1',
intervalMs: 0,
interval: '1s',
dashboardId: 0,
panelId: 1,
range: baseEmptyResponse.timeRange,
scopedVars: {

View File

@ -48,8 +48,6 @@ export interface QueryRunnerOptions<
datasource: DataSourceRef | DataSourceApi<TQuery, TOptions> | null;
queries: TQuery[];
panelId?: number;
/** @deprecate */
dashboardId?: number;
dashboardUID?: string;
publicDashboardAccessToken?: string;
timezone: TimeZone;
@ -205,7 +203,6 @@ export class PanelQueryRunner {
timezone,
datasource,
panelId,
dashboardId,
dashboardUID,
publicDashboardAccessToken,
timeRange,
@ -228,7 +225,6 @@ export class PanelQueryRunner {
requestId: getNextRequestId(),
timezone,
panelId,
dashboardId,
dashboardUID,
publicDashboardAccessToken,
range: timeRange,

View File

@ -42,7 +42,7 @@ export class QueryRunner implements QueryRunnerSrv {
datasource,
panelId,
app,
dashboardId,
dashboardUID,
timeRange,
timeInfo,
cacheTimeout,
@ -61,7 +61,7 @@ export class QueryRunner implements QueryRunnerSrv {
requestId: getNextRequestId(),
timezone,
panelId,
dashboardId,
dashboardUID,
range: timeRange,
timeInfo,
interval: '',

View File

@ -89,7 +89,6 @@ function getTestData(requestApp: string, series: DataFrame[] = []): PanelData {
return {
request: {
app: requestApp,
dashboardId: 1,
panelId: 2,
startTime: now.unix(),
endTime: now.add(1, 's').unix(),
@ -111,7 +110,6 @@ function getTestDataForExplore(requestApp: string, series: DataFrame[] = []): Pa
return {
request: {
app: requestApp,
dashboardId: 0,
startTime: now.unix(),
endTime: now.add(1, 's').unix(),
} as DataQueryRequest,
@ -136,12 +134,11 @@ describe('emitDataRequestEvent - from a dashboard panel', () => {
expect.objectContaining({
eventName: MetaAnalyticsEventName.DataRequest,
datasourceName: datasource.name,
datasourceId: datasource.id,
datasourceUid: datasource.uid,
datasourceType: datasource.type,
source: 'dashboard',
panelId: 2,
dashboardId: 1,
dashboardUid: 'test', // from dashboard srv
dataSize: 0,
duration: 1,
totalQueries: 0,
@ -159,12 +156,11 @@ describe('emitDataRequestEvent - from a dashboard panel', () => {
expect.objectContaining({
eventName: MetaAnalyticsEventName.DataRequest,
datasourceName: datasource.name,
datasourceId: datasource.id,
datasourceUid: datasource.uid,
datasourceType: datasource.type,
source: 'dashboard',
panelId: 2,
dashboardId: 1,
dashboardUid: 'test',
dataSize: 2,
duration: 1,
totalQueries: 2,
@ -182,12 +178,11 @@ describe('emitDataRequestEvent - from a dashboard panel', () => {
expect.objectContaining({
eventName: MetaAnalyticsEventName.DataRequest,
datasourceName: datasource.name,
datasourceId: datasource.id,
datasourceUid: datasource.uid,
datasourceType: datasource.type,
source: 'dashboard',
panelId: 2,
dashboardId: 1,
dashboardUid: 'test', // from dashboard srv
dataSize: 2,
duration: 1,
totalQueries: 1,
@ -227,7 +222,6 @@ describe('emitDataRequestEvent - from Explore', () => {
eventName: MetaAnalyticsEventName.DataRequest,
source: 'explore',
datasourceName: 'test',
datasourceId: 1,
datasourceUid: 'test',
dataSize: 0,
duration: 1,

View File

@ -66,7 +66,6 @@ export function emitDataRequestEvent(datasource: DataSourceApi) {
const cachedQueries = Object.values(queryCacheStatus).filter((val) => val === true).length;
eventData.panelId = data.request!.panelId;
eventData.dashboardId = data.request!.dashboardId;
eventData.totalQueries = totalQueries;
eventData.cachedQueries = cachedQueries;

View File

@ -28,7 +28,6 @@ export default function createMockPanelData(overrides?: DeepPartial<PanelData>)
requestId: 'request',
timezone: 'browser',
panelId: 1,
dashboardId: 0,
timeInfo: '',
interval: '20s',
intervalMs: 20000,

View File

@ -1204,7 +1204,6 @@ describe('addAdhocFilters', () => {
const createElasticQuery = (): DataQueryRequest<ElasticsearchQuery> => {
return {
requestId: '',
dashboardId: 0,
interval: '',
panelId: 0,
intervalMs: 1,

View File

@ -194,7 +194,6 @@ const defaultSettings: DataSourceInstanceSettings<JaegerJsonData> = {
const defaultQuery: DataQueryRequest<JaegerQuery> = {
requestId: '1',
dashboardId: 0,
interval: '0',
intervalMs: 10,
panelId: 0,

View File

@ -352,7 +352,6 @@ const defaultSettings: DataSourceInstanceSettings<JaegerJsonData> = {
const defaultQuery: DataQueryRequest<JaegerQuery> = {
requestId: '1',
dashboardId: 0,
interval: '0',
intervalMs: 10,
panelId: 0,

View File

@ -187,7 +187,6 @@ describe('opentsdb', () => {
requestId: 'Q103',
timezone: 'browser',
panelId: 2,
dashboardId: 189,
dashboardUID: 'tyzmfPIVz',
publicDashboardAccessToken: '',
range: {

View File

@ -2008,7 +2008,7 @@ describe('PrometheusDatasource for POST', () => {
});
describe('When querying prometheus via check headers X-Dashboard-Id X-Panel-Id and X-Dashboard-UID', () => {
const options = { dashboardId: 1, panelId: 2, dashboardUID: 'WFlOM-jM1' } as DataQueryRequest<PromQuery>;
const options = { panelId: 2, dashboardUID: 'WFlOM-jM1' } as DataQueryRequest<PromQuery>;
const httpOptions = {
headers: {} as { [key: string]: number | undefined },
} as PromQueryRequest;
@ -2032,7 +2032,6 @@ describe('PrometheusDatasource for POST', () => {
it('with proxy access tracing headers should be added', () => {
ds._addTracingHeaders(httpOptions, options);
expect(httpOptions.headers['X-Dashboard-Id']).toBe(options.dashboardId);
expect(httpOptions.headers['X-Panel-Id']).toBe(options.panelId);
expect(httpOptions.headers['X-Dashboard-UID']).toBe(options.dashboardUID);
});

View File

@ -195,7 +195,6 @@ export class PrometheusDatasource
_addTracingHeaders(httpOptions: PromQueryRequest, options: DataQueryRequest<PromQuery>) {
httpOptions.headers = {};
if (this.access === 'proxy') {
httpOptions.headers['X-Dashboard-Id'] = options.dashboardId;
httpOptions.headers['X-Dashboard-UID'] = options.dashboardUID;
httpOptions.headers['X-Panel-Id'] = options.panelId;
}
@ -1058,7 +1057,6 @@ export class PrometheusDatasource
targets: [{ refId: 'test', expr: '1+1', instant: true }],
requestId: `${this.id}-health`,
scopedVars: {},
dashboardId: 0,
panelId: 0,
interval: '1m',
intervalMs: 60000,

View File

@ -14,7 +14,7 @@ export function getQueryOptions<TQuery extends DataQuery>(
scopedVars: {},
timezone: 'browser',
panelId: 1,
dashboardId: 1,
dashboardUID: 'test-uid-1',
interval: '60s',
intervalMs: 60000,
maxDataPoints: 500,