mirror of
https://github.com/dbgate/dbgate
synced 2024-11-08 04:35:58 +00:00
useExtensions fixed (extensions in context)
This commit is contained in:
parent
5ec39054a3
commit
6ed3eaa896
@ -17,6 +17,7 @@ import { ModalLayerProvider } from './modals/showModal';
|
||||
import UploadsProvider from './utility/UploadsProvider';
|
||||
import ThemeHelmet from './themes/ThemeHelmet';
|
||||
import PluginsProvider from './plugins/PluginsProvider';
|
||||
import { ExtensionsProvider } from './utility/useExtensions';
|
||||
|
||||
function App() {
|
||||
return (
|
||||
@ -29,16 +30,18 @@ function App() {
|
||||
<LeftPanelWidthProvider>
|
||||
<ConnectionsPinger>
|
||||
<PluginsProvider>
|
||||
<ModalLayerProvider>
|
||||
<CurrentArchiveProvider>
|
||||
<CurrentThemeProvider>
|
||||
<UploadsProvider>
|
||||
<ThemeHelmet />
|
||||
<Screen />
|
||||
</UploadsProvider>
|
||||
</CurrentThemeProvider>
|
||||
</CurrentArchiveProvider>
|
||||
</ModalLayerProvider>
|
||||
<ExtensionsProvider>
|
||||
<ModalLayerProvider>
|
||||
<CurrentArchiveProvider>
|
||||
<CurrentThemeProvider>
|
||||
<UploadsProvider>
|
||||
<ThemeHelmet />
|
||||
<Screen />
|
||||
</UploadsProvider>
|
||||
</CurrentThemeProvider>
|
||||
</CurrentArchiveProvider>
|
||||
</ModalLayerProvider>
|
||||
</ExtensionsProvider>
|
||||
</PluginsProvider>
|
||||
</ConnectionsPinger>
|
||||
</LeftPanelWidthProvider>
|
||||
|
@ -354,10 +354,6 @@ export default function ImportExportConfigurator({ uploadedFile = undefined, onC
|
||||
const [previewSource, setPreviewSource] = React.useState(null);
|
||||
const extensions = useExtensions();
|
||||
|
||||
console.log('ImportExportConfigurator', extensions);
|
||||
const installed = useInstalledPlugins();
|
||||
console.log('installed', installed);
|
||||
|
||||
const handleUpload = React.useCallback(
|
||||
(file) => {
|
||||
console.log('UPLOAD', extensions);
|
||||
|
@ -2,14 +2,22 @@ import React from 'react';
|
||||
import { usePlugins } from '../plugins/PluginsProvider';
|
||||
import { buildFileFormats } from './fileformats';
|
||||
|
||||
export default function useExtensions() {
|
||||
const ExtensionsContext = React.createContext(buildExtensions([]));
|
||||
|
||||
export function ExtensionsProvider({ children }) {
|
||||
const plugins = usePlugins();
|
||||
const extensions = React.useMemo(
|
||||
() => ({
|
||||
plugins,
|
||||
fileFormats: buildFileFormats(plugins),
|
||||
}),
|
||||
[plugins]
|
||||
);
|
||||
const extensions = React.useMemo(() => buildExtensions(plugins), [plugins]);
|
||||
return <ExtensionsContext.Provider value={extensions}>{children}</ExtensionsContext.Provider>;
|
||||
}
|
||||
|
||||
export function buildExtensions(plugins) {
|
||||
const extensions = {
|
||||
plugins,
|
||||
fileFormats: buildFileFormats(plugins),
|
||||
};
|
||||
return extensions;
|
||||
}
|
||||
|
||||
export default function useExtensions() {
|
||||
return React.useContext(ExtensionsContext);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user