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-toolbar';
export * from './PluginSettingsManager';
export { ApplicationContext } from './context';

View File

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