mirror of
https://github.com/grafana/grafana.git
synced 2025-02-16 18:34:52 -06:00
* Feature Flags: introduce a flag for enabling the Data Connections page * Feature Flags: generate schemas * Navigation: add navigation weight for the Data Connections page * NavLink: add a comment pointing out where icon names can be looked up * NavTree: add a new page called Data Connections * fix(Api): prefix the navigation IDs with the parent ("data-connections") * feat(Frontend): add a basic page with four tabs * feat(Plugins): add a hook for importing an app plugin * feat(Plugins): add a component for loading app plugins anywhere * feat(Data Connections): load the cloud-onboarding app under the "Cloud onboarding" tab * feat(Data Connections): generate a proper nav model to highlight active tabs * test(Data Connections): add tests * refactor(Data Connections): update temporary text content This is only used as a placeholder until the tabs are under development. * refactor(Data Cnnnections): move /pages to /tabs * refactor(Data Connections): remove the `types.ts` file as it is not referenced by any module * feat(Data Connections): only register routes if feature is enabled
27 lines
706 B
TypeScript
27 lines
706 B
TypeScript
import useAsync from 'react-use/lib/useAsync';
|
|
|
|
import { PluginType } from '@grafana/data';
|
|
|
|
import { getPluginSettings } from '../pluginSettings';
|
|
import { importAppPlugin } from '../plugin_loader';
|
|
|
|
export const useImportAppPlugin = (id: string) => {
|
|
return useAsync(async () => {
|
|
const pluginMeta = await getPluginSettings(id);
|
|
|
|
if (!pluginMeta) {
|
|
throw new Error(`Unknown plugin: "${id}"`);
|
|
}
|
|
|
|
if (pluginMeta.type !== PluginType.app) {
|
|
throw new Error(`Plugin must be an app (currently "${pluginMeta.type}")`);
|
|
}
|
|
|
|
if (!pluginMeta.enabled) {
|
|
throw new Error(`Application "${id}" is not enabled`);
|
|
}
|
|
|
|
return await importAppPlugin(pluginMeta);
|
|
});
|
|
};
|