mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Extensions: Simplify the configure() function (#64958)
refactor: stop passing the extension to the `configure()` function
This commit is contained in:
@@ -74,7 +74,7 @@ export type AppPluginExtensionLinkConfig<C extends object = object> = {
|
||||
description: string;
|
||||
placement: string;
|
||||
path: string;
|
||||
configure?: (extension: AppPluginExtensionLink, context?: C) => Partial<AppPluginExtensionLink> | undefined;
|
||||
configure?: (context?: C) => Partial<AppPluginExtensionLink> | undefined;
|
||||
};
|
||||
|
||||
export type AppPluginExtensionCommandConfig<C extends object = object> = {
|
||||
@@ -82,7 +82,7 @@ export type AppPluginExtensionCommandConfig<C extends object = object> = {
|
||||
description: string;
|
||||
placement: string;
|
||||
handler: (context?: C, helpers?: AppPluginExtensionCommandHelpers) => void;
|
||||
configure?: (extension: AppPluginExtensionCommand, context?: C) => Partial<AppPluginExtensionCommand> | undefined;
|
||||
configure?: (context?: C) => Partial<AppPluginExtensionCommand> | undefined;
|
||||
};
|
||||
|
||||
export class AppPlugin<T extends KeyValue = KeyValue> extends GrafanaPlugin<AppPluginMeta<T>> {
|
||||
|
||||
@@ -20,9 +20,12 @@ export function getPluginExtensions<T extends object = {}>(
|
||||
|
||||
const extensions = configureFuncs.reduce<PluginExtension[]>((result, configure) => {
|
||||
const extension = configure(context);
|
||||
|
||||
// If the configure() function returns `undefined`, the extension is not displayed
|
||||
if (extension) {
|
||||
result.push(extension);
|
||||
}
|
||||
|
||||
return result;
|
||||
}, []);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user