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:
Marcus Andersson
2023-10-12 10:56:08 +02:00
committed by GitHub
parent 420fb56fda
commit f012b75a3a
4 changed files with 123 additions and 14 deletions

View File

@ -63,4 +63,5 @@ export {
type PluginExtensionEventHelpers,
type PluginExtensionPanelContext,
type PluginExtensionDataSourceConfigContext,
type PluginExtensionOpenModalOptions,
} from './pluginExtensions';

View File

@ -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