mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-05-03 00:13:57 +00:00
usePlugins
This commit is contained in:
@@ -38,3 +38,15 @@ export default function PluginsProvider({ children }) {
|
|||||||
}, [installedPlugins]);
|
}, [installedPlugins]);
|
||||||
return <PluginsContext.Provider value={plugins}>{children}</PluginsContext.Provider>;
|
return <PluginsContext.Provider value={plugins}>{children}</PluginsContext.Provider>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function usePlugins() {
|
||||||
|
const installed = useInstalledPlugins();
|
||||||
|
const loaded = React.useContext(PluginsContext);
|
||||||
|
return installed
|
||||||
|
.map((manifest) => ({
|
||||||
|
packageName: manifest.name,
|
||||||
|
manifest,
|
||||||
|
content: loaded[manifest.name],
|
||||||
|
}))
|
||||||
|
.filter((x) => x.content);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user