fix: fix the 'Add menu item' button disappears (#1655)
This commit is contained in:
parent
4274f605dd
commit
c1057ad52b
@ -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>
|
||||
|
@ -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,
|
||||
|
@ -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 (
|
||||
|
@ -44,6 +44,7 @@ export default function (props) {
|
||||
});
|
||||
|
||||
const ctx = useContext(PluginManagerContext);
|
||||
|
||||
return (
|
||||
<SettingsCenterProvider
|
||||
settings={{
|
||||
|
@ -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 }}
|
||||
|
@ -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,
|
||||
}}
|
||||
>
|
||||
|
Loading…
Reference in New Issue
Block a user