Plugins: Allow command extensions to open modals (#64029)

feat: make it possible to open modals from commands
This commit is contained in:
Levente Balogh
2023-03-08 15:44:48 +01:00
committed by GitHub
parent 09341a0cd6
commit d44dc0f100
4 changed files with 111 additions and 31 deletions

View File

@@ -56,6 +56,17 @@ export interface AppPluginMeta<T extends KeyValue = KeyValue> extends PluginMeta
*/
export type AppPluginExtensionLink = Pick<PluginExtensionLink, 'description' | 'path' | 'title'>;
// A list of helpers that can be used in the command handler
export type AppPluginExtensionCommandHelpers = {
// 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;
};
export type AppPluginExtensionCommand = Pick<PluginExtensionCommand, 'description' | 'title'>;
export type AppPluginExtensionLinkConfig<C extends object = object> = {
@@ -70,7 +81,7 @@ export type AppPluginExtensionCommandConfig<C extends object = object> = {
title: string;
description: string;
placement: string;
handler: (context?: C) => void;
handler: (context?: C, helpers?: AppPluginExtensionCommandHelpers) => void;
configure?: (extension: AppPluginExtensionCommand, context?: C) => Partial<AppPluginExtensionCommand> | undefined;
};