From c1057ad52bb06391de0447578d98383150b97eb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A2=AB=E9=9B=A8=E6=B0=B4=E8=BF=87=E6=BB=A4=E7=9A=84?= =?UTF-8?q?=E7=A9=BA=E6=B0=94-Rairn?= <958414905@qq.com> Date: Thu, 6 Apr 2023 16:10:38 +0800 Subject: [PATCH] fix: fix the 'Add menu item' button disappears (#1655) --- .../SchemaInitializerProvider.tsx | 8 +++++--- .../src/client/AuditLogsBlockProvider.tsx | 7 ++----- .../audit-logs/src/client/AuditLogsProvider.tsx | 10 +++++----- packages/plugins/file-manager/src/client/index.tsx | 1 + packages/plugins/map/src/client/block/index.tsx | 10 ++-------- .../plugins/snapshot-field/src/client/index.tsx | 14 +++++--------- 6 files changed, 20 insertions(+), 30 deletions(-) diff --git a/packages/core/client/src/schema-initializer/SchemaInitializerProvider.tsx b/packages/core/client/src/schema-initializer/SchemaInitializerProvider.tsx index 42bf02437..02c63f6d5 100644 --- a/packages/core/client/src/schema-initializer/SchemaInitializerProvider.tsx +++ b/packages/core/client/src/schema-initializer/SchemaInitializerProvider.tsx @@ -1,12 +1,12 @@ import { useFieldSchema } from '@formily/react'; import { isPlainObj } from '@formily/shared'; +import get from 'lodash/get'; import React, { createContext, useContext } from 'react'; import { SchemaComponentOptions } from '../schema-component'; -import get from 'lodash/get'; +import { SchemaInitializer } from './SchemaInitializer'; import * as globals from './buttons'; import * as initializerComponents from './components'; import * as items from './items'; -import { SchemaInitializer } from './SchemaInitializer'; export const SchemaInitializerContext = createContext({}); @@ -53,8 +53,10 @@ export const SchemaInitializerPluginContext = createContext(null); export const SchemaInitializerProvider: React.FC = (props) => { const { initializers, components, children } = props; + const parentInitializers = useContext(SchemaInitializerContext); + return ( - + {children} diff --git a/packages/plugins/audit-logs/src/client/AuditLogsBlockProvider.tsx b/packages/plugins/audit-logs/src/client/AuditLogsBlockProvider.tsx index 7aeafefc7..1ad3de35f 100644 --- a/packages/plugins/audit-logs/src/client/AuditLogsBlockProvider.tsx +++ b/packages/plugins/audit-logs/src/client/AuditLogsBlockProvider.tsx @@ -1,17 +1,15 @@ import { CollectionManagerProvider, - SchemaInitializerContext, SchemaInitializerProvider, - TableBlockProvider, + TableBlockProvider } from '@nocobase/client'; -import React, { useContext } from 'react'; +import React from 'react'; import { useAuditChangesCollection, useAuditLogsCollection, useCollectionsCollection } from './collections'; import { AuditLogsTableActionColumnInitializers } from './initializers/AuditLogsTableActionColumnInitializers'; import { AuditLogsTableActionInitializers } from './initializers/AuditLogsTableActionInitializers'; import { AuditLogsTableColumnInitializers } from './initializers/AuditLogsTableColumnInitializers'; export const AuditLogsBlockProvider: React.FC = ({ children, ...restProps }) => { - const initializers = useContext(SchemaInitializerContext); const auditChangesCollection = useAuditChangesCollection(); const auditLogsCollection = useAuditLogsCollection(); const collectionsCollection = useCollectionsCollection(); @@ -19,7 +17,6 @@ export const AuditLogsBlockProvider: React.FC = ({ children, ...restProps }) => return ( { return ( diff --git a/packages/plugins/file-manager/src/client/index.tsx b/packages/plugins/file-manager/src/client/index.tsx index d01c5fdad..be7f4d20c 100644 --- a/packages/plugins/file-manager/src/client/index.tsx +++ b/packages/plugins/file-manager/src/client/index.tsx @@ -44,6 +44,7 @@ export default function (props) { }); const ctx = useContext(PluginManagerContext); + return ( { const items = useContext(SchemaInitializerContext); const children = items.BlockInitializers.items[0].children; - const schemaInitializer = useContext(SchemaInitializerContext); useEffect(() => { if (!children.find((item) => item.component === 'MapBlockInitializer')) { @@ -29,7 +23,7 @@ export const MapBlockOptions: React.FC = (props) => { }, []); return ( - + { - const initializers = useContext(SchemaInitializerContext); - useEffect(() => { registerField(snapshot.group, snapshot.name as string, snapshot); }, []); @@ -31,7 +28,6 @@ export default React.memo((props) => {