forked from grafana.jool/grafana-jool
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
16 lines
436 B
16 lines
436 B
import { useAsync } from 'react-use';
|
|
import { CatalogPlugin } from '../types';
|
|
import { loadPlugin } from '../../utils';
|
|
|
|
export const usePluginConfig = (plugin?: CatalogPlugin) => {
|
|
return useAsync(async () => {
|
|
if (!plugin) {
|
|
return null;
|
|
}
|
|
|
|
if (plugin.isInstalled && !plugin.isDisabled) {
|
|
return loadPlugin(plugin.id);
|
|
}
|
|
return null;
|
|
}, [plugin?.id, plugin?.isInstalled, plugin?.isDisabled]);
|
|
};
|
|
|