mirror of
https://github.com/grafana/grafana.git
synced 2024-12-01 04:59:15 -06:00
7cf3c84c92
* fix(pluginsettings): reject with error so datasource plugin loading failures still render ui * feat(pluginpage): handle plugin loading error * refactor(datasources): separate out datasource and meta loading so store has info for deletion * fix(datasourcesettings): introduce loading flag to wait for datasource and meta loading * test(datasourcesettings): fix failing test * test(datasources): assert loading status of datasource settings * test(datasources): update action tests for latest changes
25 lines
622 B
TypeScript
25 lines
622 B
TypeScript
import { getBackendSrv } from '@grafana/runtime';
|
|
import { PluginMeta } from '@grafana/data';
|
|
|
|
type PluginCache = {
|
|
[key: string]: PluginMeta;
|
|
};
|
|
|
|
const pluginInfoCache: PluginCache = {};
|
|
|
|
export function getPluginSettings(pluginId: string): Promise<PluginMeta> {
|
|
const v = pluginInfoCache[pluginId];
|
|
if (v) {
|
|
return Promise.resolve(v);
|
|
}
|
|
return getBackendSrv()
|
|
.get(`/api/plugins/${pluginId}/settings`)
|
|
.then((settings: any) => {
|
|
pluginInfoCache[pluginId] = settings;
|
|
return settings;
|
|
})
|
|
.catch((err: any) => {
|
|
return Promise.reject(new Error('Unknown Plugin'));
|
|
});
|
|
}
|