tachybase_todo/packages/plugins/graph-collection-manager/src/client/GraphCollectionProvider.tsx

42 lines
1.3 KiB
TypeScript
Raw Normal View History

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';
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);
// 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'] = {
title: t('Graphical interface'),
2023-01-11 11:58:47 +08:00
component: GraphCollectionPane,
};
2023-01-11 11:58:47 +08:00
return (
<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>
);
});