mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
UI Extensions: Rename placement to extensionPointId (#65841)
* UI Extensions: Rename `placement` to `extensionPointId` * Fix tests. * Fix conflicts and review notes * Remove `placement` from some other places
This commit is contained in:
@@ -54,7 +54,7 @@ export * from './accesscontrol';
|
||||
export * from './icon';
|
||||
export {
|
||||
PluginExtensionTypes,
|
||||
PluginExtensionPlacements,
|
||||
PluginExtensionPoints,
|
||||
type PluginExtension,
|
||||
type PluginExtensionLink,
|
||||
type PluginExtensionConfig,
|
||||
|
||||
@@ -29,11 +29,11 @@ export type PluginExtensionConfig<Context extends object = object, ExtraProps ex
|
||||
'title' | 'description'
|
||||
> &
|
||||
ExtraProps & {
|
||||
// The unique name of the placement
|
||||
// Core Grafana placements are available in the `PluginExtensionPlacements` enum
|
||||
placement: string;
|
||||
// The unique identifier of the Extension Point
|
||||
// (Core Grafana extension point ids are available in the `PluginExtensionPoints` enum)
|
||||
extensionPointId: string;
|
||||
|
||||
// (Optional) A function that can be used to configure the extension dynamically based on the placement's context
|
||||
// (Optional) A function that can be used to configure the extension dynamically based on the extension point's context
|
||||
configure?: (
|
||||
context?: Readonly<Context>
|
||||
) => Partial<{ title: string; description: string } & ExtraProps> | undefined;
|
||||
@@ -58,11 +58,11 @@ export type PluginExtensionEventHelpers<Context extends object = object> = {
|
||||
}) => void;
|
||||
};
|
||||
|
||||
// Placements & Contexts
|
||||
// Extension Points & Contexts
|
||||
// --------------------------------------------------------
|
||||
|
||||
// Placements available in core Grafana
|
||||
export enum PluginExtensionPlacements {
|
||||
// Extension Points available in core Grafana
|
||||
export enum PluginExtensionPoints {
|
||||
DashboardPanelMenu = 'grafana/dashboard/panel/menu',
|
||||
}
|
||||
|
||||
|
||||
@@ -9,10 +9,10 @@ describe('Plugin Extensions / Get Plugin Extensions', () => {
|
||||
const getter: GetPluginExtensions = jest.fn().mockReturnValue({ extensions: [] });
|
||||
|
||||
setPluginExtensionGetter(getter);
|
||||
getPluginExtensions({ placement: 'panel-menu' });
|
||||
getPluginExtensions({ extensionPointId: 'panel-menu' });
|
||||
|
||||
expect(getter).toHaveBeenCalledTimes(1);
|
||||
expect(getter).toHaveBeenCalledWith({ placement: 'panel-menu' });
|
||||
expect(getter).toHaveBeenCalledWith({ extensionPointId: 'panel-menu' });
|
||||
});
|
||||
|
||||
test('should throw an error when trying to redefine the app-wide extension-getter function', () => {
|
||||
@@ -33,7 +33,7 @@ describe('Plugin Extensions / Get Plugin Extensions', () => {
|
||||
setPluginExtensionGetter(undefined);
|
||||
|
||||
expect(() => {
|
||||
getPluginExtensions({ placement: 'panel-menu' });
|
||||
getPluginExtensions({ extensionPointId: 'panel-menu' });
|
||||
}).toThrowError();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { PluginExtension } from '@grafana/data';
|
||||
|
||||
export type GetPluginExtensions = ({
|
||||
placement,
|
||||
extensionPointId,
|
||||
context,
|
||||
}: {
|
||||
placement: string;
|
||||
extensionPointId: string;
|
||||
context?: object | Record<string | symbol, unknown>;
|
||||
}) => {
|
||||
extensions: PluginExtension[];
|
||||
|
||||
Reference in New Issue
Block a user