2023-04-25 13:12:14 +08:00
|
|
|
import {
|
|
|
|
PluginManagerContext,
|
|
|
|
RouteSwitchContext,
|
|
|
|
SettingsCenterContext,
|
|
|
|
SettingsCenterProvider,
|
|
|
|
} from '@nocobase/client';
|
2023-01-11 11:58:47 +08:00
|
|
|
import React, { useContext } from 'react';
|
|
|
|
import { GraphCollectionPane, GraphCollectionShortcut } from './GraphCollectionShortcut';
|
2023-01-13 10:55:04 +08:00
|
|
|
import { useGCMTranslation } from './utils';
|
2023-01-11 11:58:47 +08:00
|
|
|
|
|
|
|
export const GraphCollectionProvider = React.memo((props) => {
|
|
|
|
const ctx = useContext(PluginManagerContext);
|
|
|
|
const { routes, components, ...others } = useContext(RouteSwitchContext);
|
2023-01-13 10:55:04 +08:00
|
|
|
// i18n.addResources('en-US', 'graphPositions', enUS);
|
|
|
|
// i18n.addResources('ja-JP', 'graphPositions', jaJP);
|
|
|
|
// i18n.addResources('zh-CN', 'graphPositions', zhCN);
|
|
|
|
const { t } = useGCMTranslation();
|
2023-01-11 11:58:47 +08:00
|
|
|
const items = useContext(SettingsCenterContext);
|
|
|
|
|
|
|
|
items['collection-manager']['tabs']['graph'] = {
|
2023-04-25 13:12:14 +08:00
|
|
|
title: t('Graphical interface'),
|
2023-01-11 11:58:47 +08:00
|
|
|
component: GraphCollectionPane,
|
2023-04-25 13:12:14 +08:00
|
|
|
};
|
2023-01-11 11:58:47 +08:00
|
|
|
|
|
|
|
return (
|
2023-04-25 13:12:14 +08:00
|
|
|
<SettingsCenterProvider settings={items}>
|
2023-01-11 11:58:47 +08:00
|
|
|
<PluginManagerContext.Provider
|
|
|
|
value={{
|
|
|
|
components: {
|
|
|
|
...ctx?.components,
|
|
|
|
GraphCollectionShortcut,
|
|
|
|
},
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<RouteSwitchContext.Provider value={{ components: { ...components }, ...others, routes }}>
|
|
|
|
{props.children}
|
|
|
|
</RouteSwitchContext.Provider>
|
|
|
|
</PluginManagerContext.Provider>
|
|
|
|
</SettingsCenterProvider>
|
|
|
|
);
|
|
|
|
});
|