fix(graph-collection-manager): application context missing (#3224)

* fix: appicationContext

* fix: appicationContext

* fix: update position
This commit is contained in:
katherinehhh 2023-12-18 20:19:36 +08:00 committed by GitHub
parent de902c538b
commit 5a55987033
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 3 deletions

View File

@ -8,3 +8,4 @@ export * from './schema-initializer';
export * from './schema-settings'; export * from './schema-settings';
export * from './schema-toolbar'; export * from './schema-toolbar';
export * from './PluginSettingsManager'; export * from './PluginSettingsManager';
export { ApplicationContext } from './context';

View File

@ -23,6 +23,8 @@ import {
useCompile, useCompile,
useCurrentAppInfo, useCurrentAppInfo,
useGlobalTheme, useGlobalTheme,
useApp,
ApplicationContext,
} from '@nocobase/client'; } from '@nocobase/client';
import { App, Button, ConfigProvider, Layout, Spin, Switch, Tooltip } from 'antd'; import { App, Button, ConfigProvider, Layout, Spin, Switch, Tooltip } from 'antd';
import dagre from 'dagre'; import dagre from 'dagre';
@ -341,7 +343,10 @@ const handelResetLayout = (isTemporaryLayout?) => {
}); });
targetGraph.positionCell(nodes[0], 'top-left', { padding: 100 }); targetGraph.positionCell(nodes[0], 'top-left', { padding: 100 });
if (!isTemporaryLayout) { if (!isTemporaryLayout) {
targetGraph.updatePositionAction(updatePositionData, true); targetGraph.updatePositionAction(
updatePositionData.filter((v) => v.id),
true,
);
} }
}; };
@ -360,6 +365,7 @@ export const GraphDrawPage = React.memo(() => {
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const { refreshCM, collections } = useCollectionManager(); const { refreshCM, collections } = useCollectionManager();
const currentAppInfo = useCurrentAppInfo(); const currentAppInfo = useCurrentAppInfo();
const app = useApp();
const { const {
data: { database }, data: { database },
} = currentAppInfo; } = currentAppInfo;
@ -453,7 +459,6 @@ export const GraphDrawPage = React.memo(() => {
}, },
true, true,
); );
register({ register({
shape: 'er-rect', shape: 'er-rect',
width: NODE_WIDTH, width: NODE_WIDTH,
@ -499,7 +504,9 @@ export const GraphDrawPage = React.memo(() => {
<ConfigProvider theme={theme}> <ConfigProvider theme={theme}>
<div style={{ height: 'auto' }}> <div style={{ height: 'auto' }}>
<App> <App>
<Entity {...props} setTargetNode={setTargetNode} targetGraph={targetGraph} /> <ApplicationContext.Provider value={app}>
<Entity {...props} setTargetNode={setTargetNode} targetGraph={targetGraph} />
</ApplicationContext.Provider>
</App> </App>
</div> </div>
</ConfigProvider> </ConfigProvider>