fix: fix the 'Add menu item' button disappears (#1655)

This commit is contained in:
被雨水过滤的空气-Rairn 2023-04-06 16:10:38 +08:00 committed by GitHub
parent 4274f605dd
commit c1057ad52b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 20 additions and 30 deletions

View File

@ -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<any>({});
@ -53,8 +53,10 @@ export const SchemaInitializerPluginContext = createContext(null);
export const SchemaInitializerProvider: React.FC<SchemaInitializerProviderProps> = (props) => {
const { initializers, components, children } = props;
const parentInitializers = useContext(SchemaInitializerContext);
return (
<SchemaInitializerContext.Provider value={{ ...globals, ...initializers }}>
<SchemaInitializerContext.Provider value={{ ...globals, ...parentInitializers, ...initializers }}>
<SchemaComponentOptions components={{ ...items, ...components, ...initializerComponents }}>
{children}
</SchemaComponentOptions>

View File

@ -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 (
<SchemaInitializerProvider
initializers={{
...initializers,
AuditLogsTableActionInitializers,
AuditLogsTableActionColumnInitializers,
AuditLogsTableColumnInitializers,

View File

@ -1,12 +1,12 @@
import { SchemaComponentOptions, SchemaInitializerContext, SchemaInitializerProvider } from '@nocobase/client';
import { SchemaComponentOptions } from '@nocobase/client';
import React from 'react';
import { AuditLogsBlockInitializer } from './AuditLogsBlockInitializer';
import { AuditLogsValue } from './components/AuditLogsValue';
import { AuditLogsField } from './components/AuditLogsField';
import { AuditLogsBlockProvider } from './AuditLogsBlockProvider';
import { AuditLogsTableActionColumnInitializer } from './initializers/AuditLogsTableActionColumnInitializer';
import { AuditLogs } from './deplicated/AuditLogs';
import { AuditLogsField } from './components/AuditLogsField';
import { AuditLogsValue } from './components/AuditLogsValue';
import { AuditLogsViewActionInitializer } from './components/AuditLogsViewActionInitializer';
import { AuditLogs } from './deplicated/AuditLogs';
import { AuditLogsTableActionColumnInitializer } from './initializers/AuditLogsTableActionColumnInitializer';
export const AuditLogsProvider = (props: any) => {
return (

View File

@ -44,6 +44,7 @@ export default function (props) {
});
const ctx = useContext(PluginManagerContext);
return (
<SettingsCenterProvider
settings={{

View File

@ -1,9 +1,4 @@
import {
SchemaComponent,
SchemaComponentOptions,
SchemaInitializerContext,
SchemaInitializerProvider,
} from '@nocobase/client';
import { SchemaComponentOptions, SchemaInitializerContext, SchemaInitializerProvider } from '@nocobase/client';
import React, { useContext, useEffect } from 'react';
import { generateNTemplate } from '../locale';
import { MapActionInitializers } from './MapActionInitializers';
@ -15,7 +10,6 @@ import { MapBlockProvider, useMapBlockProps } from './MapBlockProvider';
export const MapBlockOptions: React.FC = (props) => {
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 (
<SchemaInitializerProvider initializers={{ ...schemaInitializer, MapActionInitializers }}>
<SchemaInitializerProvider initializers={{ MapActionInitializers }}>
<SchemaComponentOptions
scope={{ useMapBlockProps }}
components={{ MapBlockInitializer, MapBlockDesigner, MapBlockProvider, MapBlock }}

View File

@ -3,21 +3,18 @@ import {
CollectionManagerProvider,
registerField,
SchemaComponentOptions,
SchemaInitializerContext,
SchemaInitializerProvider,
SchemaInitializerProvider
} from '@nocobase/client';
import React, { useContext, useEffect } from 'react';
import React, { useEffect } from 'react';
import { AppendsTreeSelect } from './components/AppendsTreeSelect';
import { SnapshotOwnerCollectionFieldsSelect } from './components/SnapshotOwnerCollectionFieldsSelect';
import { snapshot } from './interface';
import { SnapshotRecordPicker } from './SnapshotRecordPicker';
import { SnapshotBlockInitializers } from './SnapshotBlock/SnapshotBlockInitializers/SnapshotBlockInitializers';
import { SnapshotBlockInitializersDetailItem } from './SnapshotBlock/SnapshotBlockInitializers/SnapshotBlockInitializersDetailItem';
import { SnapshotBlockProvider } from './SnapshotBlock/SnapshotBlockProvider';
import { AppendsTreeSelect } from './components/AppendsTreeSelect';
import { SnapshotOwnerCollectionFieldsSelect } from './components/SnapshotOwnerCollectionFieldsSelect';
import { SnapshotRecordPicker } from './SnapshotRecordPicker';
export default React.memo((props) => {
const initializers = useContext(SchemaInitializerContext);
useEffect(() => {
registerField(snapshot.group, snapshot.name as string, snapshot);
}, []);
@ -31,7 +28,6 @@ export default React.memo((props) => {
<CollectionHistoryProvider>
<SchemaInitializerProvider
initializers={{
...initializers,
SnapshotBlockInitializers,
}}
>