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 { useFieldSchema } from '@formily/react';
|
||||||
import { isPlainObj } from '@formily/shared';
|
import { isPlainObj } from '@formily/shared';
|
||||||
|
import get from 'lodash/get';
|
||||||
import React, { createContext, useContext } from 'react';
|
import React, { createContext, useContext } from 'react';
|
||||||
import { SchemaComponentOptions } from '../schema-component';
|
import { SchemaComponentOptions } from '../schema-component';
|
||||||
import get from 'lodash/get';
|
import { SchemaInitializer } from './SchemaInitializer';
|
||||||
import * as globals from './buttons';
|
import * as globals from './buttons';
|
||||||
import * as initializerComponents from './components';
|
import * as initializerComponents from './components';
|
||||||
import * as items from './items';
|
import * as items from './items';
|
||||||
import { SchemaInitializer } from './SchemaInitializer';
|
|
||||||
|
|
||||||
export const SchemaInitializerContext = createContext<any>({});
|
export const SchemaInitializerContext = createContext<any>({});
|
||||||
|
|
||||||
@ -53,8 +53,10 @@ export const SchemaInitializerPluginContext = createContext(null);
|
|||||||
|
|
||||||
export const SchemaInitializerProvider: React.FC<SchemaInitializerProviderProps> = (props) => {
|
export const SchemaInitializerProvider: React.FC<SchemaInitializerProviderProps> = (props) => {
|
||||||
const { initializers, components, children } = props;
|
const { initializers, components, children } = props;
|
||||||
|
const parentInitializers = useContext(SchemaInitializerContext);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SchemaInitializerContext.Provider value={{ ...globals, ...initializers }}>
|
<SchemaInitializerContext.Provider value={{ ...globals, ...parentInitializers, ...initializers }}>
|
||||||
<SchemaComponentOptions components={{ ...items, ...components, ...initializerComponents }}>
|
<SchemaComponentOptions components={{ ...items, ...components, ...initializerComponents }}>
|
||||||
{children}
|
{children}
|
||||||
</SchemaComponentOptions>
|
</SchemaComponentOptions>
|
||||||
|
@ -1,17 +1,15 @@
|
|||||||
import {
|
import {
|
||||||
CollectionManagerProvider,
|
CollectionManagerProvider,
|
||||||
SchemaInitializerContext,
|
|
||||||
SchemaInitializerProvider,
|
SchemaInitializerProvider,
|
||||||
TableBlockProvider,
|
TableBlockProvider
|
||||||
} from '@nocobase/client';
|
} from '@nocobase/client';
|
||||||
import React, { useContext } from 'react';
|
import React from 'react';
|
||||||
import { useAuditChangesCollection, useAuditLogsCollection, useCollectionsCollection } from './collections';
|
import { useAuditChangesCollection, useAuditLogsCollection, useCollectionsCollection } from './collections';
|
||||||
import { AuditLogsTableActionColumnInitializers } from './initializers/AuditLogsTableActionColumnInitializers';
|
import { AuditLogsTableActionColumnInitializers } from './initializers/AuditLogsTableActionColumnInitializers';
|
||||||
import { AuditLogsTableActionInitializers } from './initializers/AuditLogsTableActionInitializers';
|
import { AuditLogsTableActionInitializers } from './initializers/AuditLogsTableActionInitializers';
|
||||||
import { AuditLogsTableColumnInitializers } from './initializers/AuditLogsTableColumnInitializers';
|
import { AuditLogsTableColumnInitializers } from './initializers/AuditLogsTableColumnInitializers';
|
||||||
|
|
||||||
export const AuditLogsBlockProvider: React.FC = ({ children, ...restProps }) => {
|
export const AuditLogsBlockProvider: React.FC = ({ children, ...restProps }) => {
|
||||||
const initializers = useContext(SchemaInitializerContext);
|
|
||||||
const auditChangesCollection = useAuditChangesCollection();
|
const auditChangesCollection = useAuditChangesCollection();
|
||||||
const auditLogsCollection = useAuditLogsCollection();
|
const auditLogsCollection = useAuditLogsCollection();
|
||||||
const collectionsCollection = useCollectionsCollection();
|
const collectionsCollection = useCollectionsCollection();
|
||||||
@ -19,7 +17,6 @@ export const AuditLogsBlockProvider: React.FC = ({ children, ...restProps }) =>
|
|||||||
return (
|
return (
|
||||||
<SchemaInitializerProvider
|
<SchemaInitializerProvider
|
||||||
initializers={{
|
initializers={{
|
||||||
...initializers,
|
|
||||||
AuditLogsTableActionInitializers,
|
AuditLogsTableActionInitializers,
|
||||||
AuditLogsTableActionColumnInitializers,
|
AuditLogsTableActionColumnInitializers,
|
||||||
AuditLogsTableColumnInitializers,
|
AuditLogsTableColumnInitializers,
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import { SchemaComponentOptions, SchemaInitializerContext, SchemaInitializerProvider } from '@nocobase/client';
|
import { SchemaComponentOptions } from '@nocobase/client';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { AuditLogsBlockInitializer } from './AuditLogsBlockInitializer';
|
import { AuditLogsBlockInitializer } from './AuditLogsBlockInitializer';
|
||||||
import { AuditLogsValue } from './components/AuditLogsValue';
|
|
||||||
import { AuditLogsField } from './components/AuditLogsField';
|
|
||||||
import { AuditLogsBlockProvider } from './AuditLogsBlockProvider';
|
import { AuditLogsBlockProvider } from './AuditLogsBlockProvider';
|
||||||
import { AuditLogsTableActionColumnInitializer } from './initializers/AuditLogsTableActionColumnInitializer';
|
import { AuditLogsField } from './components/AuditLogsField';
|
||||||
import { AuditLogs } from './deplicated/AuditLogs';
|
import { AuditLogsValue } from './components/AuditLogsValue';
|
||||||
import { AuditLogsViewActionInitializer } from './components/AuditLogsViewActionInitializer';
|
import { AuditLogsViewActionInitializer } from './components/AuditLogsViewActionInitializer';
|
||||||
|
import { AuditLogs } from './deplicated/AuditLogs';
|
||||||
|
import { AuditLogsTableActionColumnInitializer } from './initializers/AuditLogsTableActionColumnInitializer';
|
||||||
|
|
||||||
export const AuditLogsProvider = (props: any) => {
|
export const AuditLogsProvider = (props: any) => {
|
||||||
return (
|
return (
|
||||||
|
@ -44,6 +44,7 @@ export default function (props) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const ctx = useContext(PluginManagerContext);
|
const ctx = useContext(PluginManagerContext);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SettingsCenterProvider
|
<SettingsCenterProvider
|
||||||
settings={{
|
settings={{
|
||||||
|
@ -1,9 +1,4 @@
|
|||||||
import {
|
import { SchemaComponentOptions, SchemaInitializerContext, SchemaInitializerProvider } from '@nocobase/client';
|
||||||
SchemaComponent,
|
|
||||||
SchemaComponentOptions,
|
|
||||||
SchemaInitializerContext,
|
|
||||||
SchemaInitializerProvider,
|
|
||||||
} from '@nocobase/client';
|
|
||||||
import React, { useContext, useEffect } from 'react';
|
import React, { useContext, useEffect } from 'react';
|
||||||
import { generateNTemplate } from '../locale';
|
import { generateNTemplate } from '../locale';
|
||||||
import { MapActionInitializers } from './MapActionInitializers';
|
import { MapActionInitializers } from './MapActionInitializers';
|
||||||
@ -15,7 +10,6 @@ import { MapBlockProvider, useMapBlockProps } from './MapBlockProvider';
|
|||||||
export const MapBlockOptions: React.FC = (props) => {
|
export const MapBlockOptions: React.FC = (props) => {
|
||||||
const items = useContext(SchemaInitializerContext);
|
const items = useContext(SchemaInitializerContext);
|
||||||
const children = items.BlockInitializers.items[0].children;
|
const children = items.BlockInitializers.items[0].children;
|
||||||
const schemaInitializer = useContext(SchemaInitializerContext);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!children.find((item) => item.component === 'MapBlockInitializer')) {
|
if (!children.find((item) => item.component === 'MapBlockInitializer')) {
|
||||||
@ -29,7 +23,7 @@ export const MapBlockOptions: React.FC = (props) => {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SchemaInitializerProvider initializers={{ ...schemaInitializer, MapActionInitializers }}>
|
<SchemaInitializerProvider initializers={{ MapActionInitializers }}>
|
||||||
<SchemaComponentOptions
|
<SchemaComponentOptions
|
||||||
scope={{ useMapBlockProps }}
|
scope={{ useMapBlockProps }}
|
||||||
components={{ MapBlockInitializer, MapBlockDesigner, MapBlockProvider, MapBlock }}
|
components={{ MapBlockInitializer, MapBlockDesigner, MapBlockProvider, MapBlock }}
|
||||||
|
@ -3,21 +3,18 @@ import {
|
|||||||
CollectionManagerProvider,
|
CollectionManagerProvider,
|
||||||
registerField,
|
registerField,
|
||||||
SchemaComponentOptions,
|
SchemaComponentOptions,
|
||||||
SchemaInitializerContext,
|
SchemaInitializerProvider
|
||||||
SchemaInitializerProvider,
|
|
||||||
} from '@nocobase/client';
|
} 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 { snapshot } from './interface';
|
||||||
import { SnapshotRecordPicker } from './SnapshotRecordPicker';
|
|
||||||
import { SnapshotBlockInitializers } from './SnapshotBlock/SnapshotBlockInitializers/SnapshotBlockInitializers';
|
import { SnapshotBlockInitializers } from './SnapshotBlock/SnapshotBlockInitializers/SnapshotBlockInitializers';
|
||||||
import { SnapshotBlockInitializersDetailItem } from './SnapshotBlock/SnapshotBlockInitializers/SnapshotBlockInitializersDetailItem';
|
import { SnapshotBlockInitializersDetailItem } from './SnapshotBlock/SnapshotBlockInitializers/SnapshotBlockInitializersDetailItem';
|
||||||
import { SnapshotBlockProvider } from './SnapshotBlock/SnapshotBlockProvider';
|
import { SnapshotBlockProvider } from './SnapshotBlock/SnapshotBlockProvider';
|
||||||
import { AppendsTreeSelect } from './components/AppendsTreeSelect';
|
import { SnapshotRecordPicker } from './SnapshotRecordPicker';
|
||||||
import { SnapshotOwnerCollectionFieldsSelect } from './components/SnapshotOwnerCollectionFieldsSelect';
|
|
||||||
|
|
||||||
export default React.memo((props) => {
|
export default React.memo((props) => {
|
||||||
const initializers = useContext(SchemaInitializerContext);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
registerField(snapshot.group, snapshot.name as string, snapshot);
|
registerField(snapshot.group, snapshot.name as string, snapshot);
|
||||||
}, []);
|
}, []);
|
||||||
@ -31,7 +28,6 @@ export default React.memo((props) => {
|
|||||||
<CollectionHistoryProvider>
|
<CollectionHistoryProvider>
|
||||||
<SchemaInitializerProvider
|
<SchemaInitializerProvider
|
||||||
initializers={{
|
initializers={{
|
||||||
...initializers,
|
|
||||||
SnapshotBlockInitializers,
|
SnapshotBlockInitializers,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
Loading…
Reference in New Issue
Block a user