PluginExtensions: Expose scopedVars via the context to plugins that extends the dashboard panel menu (#67917)

* Exposes the scoped vars to UI extensions via context.

* reverted the interpolation when running a query via the query runner.

* adding scoped vars to test.#
This commit is contained in:
Marcus Andersson 2023-05-11 12:58:19 +02:00 committed by GitHub
parent 94a8d15b29
commit 5605d2f4a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 0 deletions

View File

@ -1,5 +1,6 @@
import { DataQuery } from '@grafana/schema';
import { ScopedVars } from './ScopedVars';
import { RawTimeRange, TimeZone } from './time';
// Plugin Extensions types
@ -76,6 +77,7 @@ export type PluginExtensionPanelContext = {
timeZone: TimeZone;
dashboard: Dashboard;
targets: DataQuery[];
scopedVars?: ScopedVars;
};
type Dashboard = {

View File

@ -201,6 +201,12 @@ describe('getPanelMenu()', () => {
},
},
],
scopedVars: {
a: {
text: 'a',
value: 'a',
},
},
});
const dashboard = createDashboardModelFixture({
@ -238,6 +244,12 @@ describe('getPanelMenu()', () => {
uid: '123',
title: 'My dashboard',
},
scopedVars: {
a: {
text: 'a',
value: 'a',
},
},
};
expect(getPluginExtensions).toBeCalledWith(expect.objectContaining({ context }));

View File

@ -341,5 +341,6 @@ function createExtensionContext(panel: PanelModel, dashboard: DashboardModel): P
tags: Array.from<string>(dashboard.tags),
},
targets: panel.targets,
scopedVars: panel.scopedVars,
};
}