mirror of
https://github.com/grafana/grafana.git
synced 2025-02-11 16:15:42 -06:00
* Update dependency prettier to v2.5.1 * prettier fixes * chore(toolkit): bump prettier to 2.5.1 * style(eslint): bump grafana config to 2.5.2 in core and toolkit * style(mssql-datasource): fix no-inferrable-types eslint errors Co-authored-by: Renovate Bot <bot@renovateapp.com> Co-authored-by: Ashley Harrison <ashley.harrison@grafana.com> Co-authored-by: Jack Westbrook <jack.westbrook@gmail.com>
30 lines
995 B
TypeScript
30 lines
995 B
TypeScript
import { GrafanaPlugin, PanelPluginMeta, PluginType } from '@grafana/data';
|
|
import { getPluginSettings } from './pluginSettings';
|
|
import { importAppPlugin, importDataSourcePlugin } from './plugin_loader';
|
|
import { importPanelPluginFromMeta } from './importPanelPlugin';
|
|
|
|
export async function loadPlugin(pluginId: string): Promise<GrafanaPlugin> {
|
|
const info = await getPluginSettings(pluginId);
|
|
let result: GrafanaPlugin | undefined;
|
|
|
|
if (info.type === PluginType.app) {
|
|
result = await importAppPlugin(info);
|
|
}
|
|
if (info.type === PluginType.datasource) {
|
|
result = await importDataSourcePlugin(info);
|
|
}
|
|
if (info.type === PluginType.panel) {
|
|
const panelPlugin = await importPanelPluginFromMeta(info as PanelPluginMeta);
|
|
result = panelPlugin as unknown as GrafanaPlugin;
|
|
}
|
|
if (info.type === PluginType.renderer) {
|
|
result = { meta: info } as GrafanaPlugin;
|
|
}
|
|
|
|
if (!result) {
|
|
throw new Error('Unknown Plugin type: ' + info.type);
|
|
}
|
|
|
|
return result;
|
|
}
|