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 UploadsProvider from './utility/UploadsProvider';
|
||||||
import ThemeHelmet from './themes/ThemeHelmet';
|
import ThemeHelmet from './themes/ThemeHelmet';
|
||||||
import PluginsProvider from './plugins/PluginsProvider';
|
import PluginsProvider from './plugins/PluginsProvider';
|
||||||
|
import { ExtensionsProvider } from './utility/useExtensions';
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
return (
|
return (
|
||||||
@ -29,16 +30,18 @@ function App() {
|
|||||||
<LeftPanelWidthProvider>
|
<LeftPanelWidthProvider>
|
||||||
<ConnectionsPinger>
|
<ConnectionsPinger>
|
||||||
<PluginsProvider>
|
<PluginsProvider>
|
||||||
<ModalLayerProvider>
|
<ExtensionsProvider>
|
||||||
<CurrentArchiveProvider>
|
<ModalLayerProvider>
|
||||||
<CurrentThemeProvider>
|
<CurrentArchiveProvider>
|
||||||
<UploadsProvider>
|
<CurrentThemeProvider>
|
||||||
<ThemeHelmet />
|
<UploadsProvider>
|
||||||
<Screen />
|
<ThemeHelmet />
|
||||||
</UploadsProvider>
|
<Screen />
|
||||||
</CurrentThemeProvider>
|
</UploadsProvider>
|
||||||
</CurrentArchiveProvider>
|
</CurrentThemeProvider>
|
||||||
</ModalLayerProvider>
|
</CurrentArchiveProvider>
|
||||||
|
</ModalLayerProvider>
|
||||||
|
</ExtensionsProvider>
|
||||||
</PluginsProvider>
|
</PluginsProvider>
|
||||||
</ConnectionsPinger>
|
</ConnectionsPinger>
|
||||||
</LeftPanelWidthProvider>
|
</LeftPanelWidthProvider>
|
||||||
|
@ -354,10 +354,6 @@ export default function ImportExportConfigurator({ uploadedFile = undefined, onC
|
|||||||
const [previewSource, setPreviewSource] = React.useState(null);
|
const [previewSource, setPreviewSource] = React.useState(null);
|
||||||
const extensions = useExtensions();
|
const extensions = useExtensions();
|
||||||
|
|
||||||
console.log('ImportExportConfigurator', extensions);
|
|
||||||
const installed = useInstalledPlugins();
|
|
||||||
console.log('installed', installed);
|
|
||||||
|
|
||||||
const handleUpload = React.useCallback(
|
const handleUpload = React.useCallback(
|
||||||
(file) => {
|
(file) => {
|
||||||
console.log('UPLOAD', extensions);
|
console.log('UPLOAD', extensions);
|
||||||
|
@ -2,14 +2,22 @@ import React from 'react';
|
|||||||
import { usePlugins } from '../plugins/PluginsProvider';
|
import { usePlugins } from '../plugins/PluginsProvider';
|
||||||
import { buildFileFormats } from './fileformats';
|
import { buildFileFormats } from './fileformats';
|
||||||
|
|
||||||
export default function useExtensions() {
|
const ExtensionsContext = React.createContext(buildExtensions([]));
|
||||||
|
|
||||||
|
export function ExtensionsProvider({ children }) {
|
||||||
const plugins = usePlugins();
|
const plugins = usePlugins();
|
||||||
const extensions = React.useMemo(
|
const extensions = React.useMemo(() => buildExtensions(plugins), [plugins]);
|
||||||
() => ({
|
return <ExtensionsContext.Provider value={extensions}>{children}</ExtensionsContext.Provider>;
|
||||||
plugins,
|
}
|
||||||
fileFormats: buildFileFormats(plugins),
|
|
||||||
}),
|
export function buildExtensions(plugins) {
|
||||||
[plugins]
|
const extensions = {
|
||||||
);
|
plugins,
|
||||||
|
fileFormats: buildFileFormats(plugins),
|
||||||
|
};
|
||||||
return extensions;
|
return extensions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default function useExtensions() {
|
||||||
|
return React.useContext(ExtensionsContext);
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user