mirror of
https://github.com/grafana/grafana.git
synced 2025-07-31 12:52:05 +08:00
PluginExtensions: Made it possible to control modal size from extension (#76232)
* Added possibility to change modal size from UI extension. * added tests for openModal. * fixed typings. * added test to verify default modal size.
This commit is contained in:
@ -63,4 +63,5 @@ export {
|
||||
type PluginExtensionEventHelpers,
|
||||
type PluginExtensionPanelContext,
|
||||
type PluginExtensionDataSourceConfigContext,
|
||||
type PluginExtensionOpenModalOptions,
|
||||
} from './pluginExtensions';
|
||||
|
@ -95,15 +95,21 @@ export type PluginExtensionComponentConfig<Context extends object = object> = {
|
||||
|
||||
export type PluginExtensionConfig = PluginExtensionLinkConfig | PluginExtensionComponentConfig;
|
||||
|
||||
export type PluginExtensionOpenModalOptions = {
|
||||
// The title of the modal
|
||||
title: string;
|
||||
// A React element that will be rendered inside the modal
|
||||
body: React.ElementType<{ onDismiss?: () => void }>;
|
||||
// Width of the modal in pixels or percentage
|
||||
width?: string | number;
|
||||
// Height of the modal in pixels or percentage
|
||||
height?: string | number;
|
||||
};
|
||||
|
||||
export type PluginExtensionEventHelpers<Context extends object = object> = {
|
||||
context?: Readonly<Context>;
|
||||
// Opens a modal dialog and renders the provided React component inside it
|
||||
openModal: (options: {
|
||||
// The title of the modal
|
||||
title: string;
|
||||
// A React element that will be rendered inside the modal
|
||||
body: React.ElementType<{ onDismiss?: () => void }>;
|
||||
}) => void;
|
||||
openModal: (options: PluginExtensionOpenModalOptions) => void;
|
||||
};
|
||||
|
||||
// Extension Points & Contexts
|
||||
|
Reference in New Issue
Block a user