mirror of
https://github.com/grafana/grafana.git
synced 2025-07-31 03:42:39 +08:00

* feat(plugins): automatically preload plugins This PR enables auto-preloading for plugins when they are used by an extension or extension-point. Once this change is merged plugins that were only using "preload: true" in their plugin.json for using extensions can remove it. * fix: remove unused types * fix: call `setComponentsFromLegacyExports()` after meta is initialised
20 lines
461 B
TypeScript
20 lines
461 B
TypeScript
import { useAsync } from 'react-use';
|
|
|
|
import { preloadPlugins } from '../pluginPreloader';
|
|
|
|
import { getAppPluginConfigs } from './utils';
|
|
|
|
export function useLoadAppPlugins(pluginIds: string[] = []): { isLoading: boolean } {
|
|
const { loading: isLoading } = useAsync(async () => {
|
|
const appConfigs = getAppPluginConfigs(pluginIds);
|
|
|
|
if (!appConfigs.length) {
|
|
return;
|
|
}
|
|
|
|
await preloadPlugins(appConfigs);
|
|
});
|
|
|
|
return { isLoading };
|
|
}
|