feat: use ActionContextProvider instated of ActionContext.Provider (#2019)

This commit is contained in:
Dunqing 2023-06-09 13:05:05 +08:00 committed by GitHub
parent 151949362b
commit 69bbfee67a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
40 changed files with 129 additions and 124 deletions

View File

@ -6,7 +6,7 @@ import React, { useState } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { useHistory } from 'react-router-dom'; import { useHistory } from 'react-router-dom';
import { PluginManager } from '../plugin-manager'; import { PluginManager } from '../plugin-manager';
import { ActionContext, SchemaComponent } from '../schema-component'; import { ActionContextProvider, SchemaComponent } from '../schema-component';
import * as components from './Configuration'; import * as components from './Configuration';
const schema: ISchema = { const schema: ISchema = {
@ -61,7 +61,7 @@ export const ACLShortcut2 = () => {
const [visible, setVisible] = useState(false); const [visible, setVisible] = useState(false);
const { t } = useTranslation(); const { t } = useTranslation();
return ( return (
<ActionContext.Provider value={{ visible, setVisible }}> <ActionContextProvider value={{ visible, setVisible }}>
<PluginManager.Toolbar.Item <PluginManager.Toolbar.Item
icon={<LockOutlined />} icon={<LockOutlined />}
title={t('Roles & Permissions')} title={t('Roles & Permissions')}
@ -70,6 +70,6 @@ export const ACLShortcut2 = () => {
}} }}
/> />
<SchemaComponent components={components} schema={schema} /> <SchemaComponent components={components} schema={schema} />
</ActionContext.Provider> </ActionContextProvider>
); );
}; };

View File

@ -6,7 +6,7 @@ import React, { useState } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { useHistory } from 'react-router-dom'; import { useHistory } from 'react-router-dom';
import { PluginManager } from '../plugin-manager'; import { PluginManager } from '../plugin-manager';
import { ActionContext, SchemaComponent } from '../schema-component'; import { ActionContextProvider, SchemaComponent } from '../schema-component';
import { import {
AddCollectionField, AddCollectionField,
AddFieldAction, AddFieldAction,
@ -109,7 +109,7 @@ export const CollectionManagerShortcut2 = () => {
const [visible, setVisible] = useState(false); const [visible, setVisible] = useState(false);
const { t } = useTranslation(); const { t } = useTranslation();
return ( return (
<ActionContext.Provider value={{ visible, setVisible }}> <ActionContextProvider value={{ visible, setVisible }}>
<PluginManager.Toolbar.Item <PluginManager.Toolbar.Item
icon={<DatabaseOutlined />} icon={<DatabaseOutlined />}
title={t('Collections & Fields')} title={t('Collections & Fields')}
@ -132,6 +132,6 @@ export const CollectionManagerShortcut2 = () => {
EditCategoryAction, EditCategoryAction,
}} }}
/> />
</ActionContext.Provider> </ActionContextProvider>
); );
}; };

View File

@ -4,7 +4,7 @@ import { cloneDeep } from 'lodash';
import React, { useContext, useState } from 'react'; import React, { useContext, useState } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { useAPIClient } from '../../api-client'; import { useAPIClient } from '../../api-client';
import { ActionContext, SchemaComponent, useActionContext } from '../../schema-component'; import { ActionContextProvider, SchemaComponent, useActionContext } from '../../schema-component';
import { useCancelAction } from '../action-hooks'; import { useCancelAction } from '../action-hooks';
import { CollectionCategroriesContext } from '../context'; import { CollectionCategroriesContext } from '../context';
import * as components from './components'; import * as components from './components';
@ -40,7 +40,7 @@ export const AddCategoryAction = (props) => {
const [visible, setVisible] = useState(false); const [visible, setVisible] = useState(false);
const { t } = useTranslation(); const { t } = useTranslation();
return ( return (
<ActionContext.Provider value={{ visible, setVisible }}> <ActionContextProvider value={{ visible, setVisible }}>
<div onClick={() => setVisible(true)} title={t('Add category')}> <div onClick={() => setVisible(true)} title={t('Add category')}>
{children || <PlusOutlined />} {children || <PlusOutlined />}
</div> </div>
@ -55,6 +55,6 @@ export const AddCategoryAction = (props) => {
...scope, ...scope,
}} }}
/> />
</ActionContext.Provider> </ActionContextProvider>
); );
}; };

View File

@ -8,7 +8,7 @@ import React, { useState } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { useRequest } from '../../api-client'; import { useRequest } from '../../api-client';
import { RecordProvider, useRecord } from '../../record-provider'; import { RecordProvider, useRecord } from '../../record-provider';
import { ActionContext, SchemaComponent, useActionContext, useCompile } from '../../schema-component'; import { ActionContextProvider, SchemaComponent, useActionContext, useCompile } from '../../schema-component';
import { useResourceActionContext, useResourceContext } from '../ResourceActionProvider'; import { useResourceActionContext, useResourceContext } from '../ResourceActionProvider';
import { useCancelAction } from '../action-hooks'; import { useCancelAction } from '../action-hooks';
import { useCollectionManager } from '../hooks'; import { useCollectionManager } from '../hooks';
@ -261,7 +261,7 @@ export const AddCollectionAction = (props) => {
} = useResourceActionContext(); } = useResourceActionContext();
return ( return (
<RecordProvider record={record}> <RecordProvider record={record}>
<ActionContext.Provider value={{ visible, setVisible }}> <ActionContextProvider value={{ visible, setVisible }}>
<Dropdown <Dropdown
getPopupContainer={getContainer} getPopupContainer={getContainer}
trigger={trigger} trigger={trigger}
@ -300,7 +300,7 @@ export const AddCollectionAction = (props) => {
...scope, ...scope,
}} }}
/> />
</ActionContext.Provider> </ActionContextProvider>
</RecordProvider> </RecordProvider>
); );
}; };

View File

@ -8,7 +8,7 @@ import React, { useState } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { useRequest } from '../../api-client'; import { useRequest } from '../../api-client';
import { RecordProvider, useRecord } from '../../record-provider'; import { RecordProvider, useRecord } from '../../record-provider';
import { ActionContext, SchemaComponent, useActionContext, useCompile } from '../../schema-component'; import { ActionContextProvider, SchemaComponent, useActionContext, useCompile } from '../../schema-component';
import { useResourceActionContext, useResourceContext } from '../ResourceActionProvider'; import { useResourceActionContext, useResourceContext } from '../ResourceActionProvider';
import { useCancelAction } from '../action-hooks'; import { useCancelAction } from '../action-hooks';
import { useCollectionManager } from '../hooks'; import { useCollectionManager } from '../hooks';
@ -222,7 +222,7 @@ export const AddFieldAction = (props) => {
return ( return (
record.template !== 'view' && ( record.template !== 'view' && (
<RecordProvider record={record}> <RecordProvider record={record}>
<ActionContext.Provider value={{ visible, setVisible }}> <ActionContextProvider value={{ visible, setVisible }}>
<Dropdown <Dropdown
getPopupContainer={getContainer} getPopupContainer={getContainer}
trigger={trigger} trigger={trigger}
@ -286,7 +286,7 @@ export const AddFieldAction = (props) => {
...scope, ...scope,
}} }}
/> />
</ActionContext.Provider> </ActionContextProvider>
</RecordProvider> </RecordProvider>
) )
); );

View File

@ -8,7 +8,7 @@ import React, { useState } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { useRequest } from '../../api-client'; import { useRequest } from '../../api-client';
import { RecordProvider } from '../../record-provider'; import { RecordProvider } from '../../record-provider';
import { ActionContext, SchemaComponent, useActionContext, useCompile } from '../../schema-component'; import { ActionContextProvider, SchemaComponent, useActionContext, useCompile } from '../../schema-component';
import { useCollectionManager } from '../hooks'; import { useCollectionManager } from '../hooks';
import { useOptions } from '../hooks/useOptions'; import { useOptions } from '../hooks/useOptions';
import { IField } from '../interfaces/types'; import { IField } from '../interfaces/types';
@ -112,7 +112,7 @@ export const AddSubFieldAction = () => {
}; };
}); });
return ( return (
<ActionContext.Provider value={{ visible, setVisible }}> <ActionContextProvider value={{ visible, setVisible }}>
<Dropdown <Dropdown
overlay={ overlay={
<Menu <Menu
@ -140,6 +140,6 @@ export const AddSubFieldAction = () => {
scope={{ createOnly: true, useCreateSubField }} scope={{ createOnly: true, useCreateSubField }}
/> />
</RecordProvider> </RecordProvider>
</ActionContext.Provider> </ActionContextProvider>
); );
}; };

View File

@ -3,7 +3,7 @@ import { cloneDeep } from 'lodash';
import React, { useContext, useEffect, useState } from 'react'; import React, { useContext, useEffect, useState } from 'react';
import { useAPIClient, useRequest } from '../../api-client'; import { useAPIClient, useRequest } from '../../api-client';
import { RecordProvider, useRecord } from '../../record-provider'; import { RecordProvider, useRecord } from '../../record-provider';
import { ActionContext, SchemaComponent, useActionContext, useCompile } from '../../schema-component'; import { ActionContextProvider, SchemaComponent, useActionContext, useCompile } from '../../schema-component';
import { useCancelAction } from '../action-hooks'; import { useCancelAction } from '../action-hooks';
import { CollectionCategroriesContext } from '../context'; import { CollectionCategroriesContext } from '../context';
import { useResourceActionContext } from '../ResourceActionProvider'; import { useResourceActionContext } from '../ResourceActionProvider';
@ -61,7 +61,7 @@ export const EditCategoryAction = (props) => {
const compile = useCompile(); const compile = useCompile();
return ( return (
<RecordProvider record={item}> <RecordProvider record={item}>
<ActionContext.Provider value={{ visible, setVisible }}> <ActionContextProvider value={{ visible, setVisible }}>
<>{children || <span onClick={() => setVisible(true)}>{compile('{{ t("Edit category") }}')}</span>}</> <>{children || <span onClick={() => setVisible(true)}>{compile('{{ t("Edit category") }}')}</span>}</>
<SchemaComponent <SchemaComponent
schema={collectionCategoryEditSchema} schema={collectionCategoryEditSchema}
@ -75,7 +75,7 @@ export const EditCategoryAction = (props) => {
...scope, ...scope,
}} }}
/> />
</ActionContext.Provider> </ActionContextProvider>
</RecordProvider> </RecordProvider>
); );
}; };

View File

@ -7,7 +7,7 @@ import React, { useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { useRequest } from '../../api-client'; import { useRequest } from '../../api-client';
import { RecordProvider, useRecord } from '../../record-provider'; import { RecordProvider, useRecord } from '../../record-provider';
import { ActionContext, SchemaComponent, useActionContext, useCompile } from '../../schema-component'; import { ActionContextProvider, SchemaComponent, useActionContext, useCompile } from '../../schema-component';
import { useResourceActionContext, useResourceContext } from '../ResourceActionProvider'; import { useResourceActionContext, useResourceContext } from '../ResourceActionProvider';
import { useCancelAction } from '../action-hooks'; import { useCancelAction } from '../action-hooks';
import { useCollectionManager } from '../hooks'; import { useCollectionManager } from '../hooks';
@ -128,7 +128,7 @@ export const EditCollectionAction = (props) => {
return ( return (
<RecordProvider record={record}> <RecordProvider record={record}>
<ActionContext.Provider value={{ visible, setVisible }}> <ActionContextProvider value={{ visible, setVisible }}>
<a <a
onClick={async () => { onClick={async () => {
const templateConf = getTemplate(record.template); const templateConf = getTemplate(record.template);
@ -158,7 +158,7 @@ export const EditCollectionAction = (props) => {
...scope, ...scope,
}} }}
/> />
</ActionContext.Provider> </ActionContextProvider>
</RecordProvider> </RecordProvider>
); );
}; };

View File

@ -7,7 +7,7 @@ import React, { useState } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { useAPIClient, useRequest } from '../../api-client'; import { useAPIClient, useRequest } from '../../api-client';
import { RecordProvider, useRecord } from '../../record-provider'; import { RecordProvider, useRecord } from '../../record-provider';
import { ActionContext, SchemaComponent, useActionContext, useCompile } from '../../schema-component'; import { ActionContextProvider, SchemaComponent, useActionContext, useCompile } from '../../schema-component';
import { useResourceActionContext, useResourceContext } from '../ResourceActionProvider'; import { useResourceActionContext, useResourceContext } from '../ResourceActionProvider';
import { useCancelAction, useUpdateAction } from '../action-hooks'; import { useCancelAction, useUpdateAction } from '../action-hooks';
import { useCollectionManager } from '../hooks'; import { useCollectionManager } from '../hooks';
@ -145,7 +145,7 @@ export const EditFieldAction = (props) => {
const [data, setData] = useState<any>({}); const [data, setData] = useState<any>({});
return ( return (
<RecordProvider record={record}> <RecordProvider record={record}>
<ActionContext.Provider value={{ visible, setVisible }}> <ActionContextProvider value={{ visible, setVisible }}>
<a <a
onClick={async () => { onClick={async () => {
const { data } = await api.resource('collections.fields', record.collectionName).get({ const { data } = await api.resource('collections.fields', record.collectionName).get({
@ -187,7 +187,7 @@ export const EditFieldAction = (props) => {
...scope, ...scope,
}} }}
/> />
</ActionContext.Provider> </ActionContextProvider>
</RecordProvider> </RecordProvider>
); );
}; };

View File

@ -6,7 +6,7 @@ import React, { useState } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { useAPIClient, useRequest } from '../../api-client'; import { useAPIClient, useRequest } from '../../api-client';
import { useRecord } from '../../record-provider'; import { useRecord } from '../../record-provider';
import { ActionContext, SchemaComponent } from '../../schema-component'; import { ActionContextProvider, SchemaComponent } from '../../schema-component';
import { useUpdateAction } from '../action-hooks'; import { useUpdateAction } from '../action-hooks';
import { useCollectionManager } from '../hooks'; import { useCollectionManager } from '../hooks';
import { IField } from '../interfaces/types'; import { IField } from '../interfaces/types';
@ -98,7 +98,7 @@ export const EditSubFieldAction = (props) => {
const api = useAPIClient(); const api = useAPIClient();
const { t } = useTranslation(); const { t } = useTranslation();
return ( return (
<ActionContext.Provider value={{ visible, setVisible }}> <ActionContextProvider value={{ visible, setVisible }}>
<a <a
onClick={async () => { onClick={async () => {
// const { data } = await api.resource('collections.fields', record.collectionName).get({ // const { data } = await api.resource('collections.fields', record.collectionName).get({
@ -120,6 +120,6 @@ export const EditSubFieldAction = (props) => {
components={{ ...components, ArrayTable }} components={{ ...components, ArrayTable }}
scope={{ useUpdateCollectionField }} scope={{ useUpdateCollectionField }}
/> />
</ActionContext.Provider> </ActionContextProvider>
); );
}; };

View File

@ -7,7 +7,7 @@ import React, { useState } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { useAPIClient, useRequest } from '../../api-client'; import { useAPIClient, useRequest } from '../../api-client';
import { RecordProvider, useRecord } from '../../record-provider'; import { RecordProvider, useRecord } from '../../record-provider';
import { ActionContext, SchemaComponent, useActionContext, useCompile } from '../../schema-component'; import { ActionContextProvider, SchemaComponent, useActionContext, useCompile } from '../../schema-component';
import { useResourceActionContext, useResourceContext } from '../ResourceActionProvider'; import { useResourceActionContext, useResourceContext } from '../ResourceActionProvider';
import { useCancelAction } from '../action-hooks'; import { useCancelAction } from '../action-hooks';
import { useCollectionManager } from '../hooks'; import { useCollectionManager } from '../hooks';
@ -148,7 +148,7 @@ export const OverridingFieldAction = (props) => {
const disabled = getIsOverriding(currentFields, record); const disabled = getIsOverriding(currentFields, record);
return ( return (
<RecordProvider record={{ ...record, collectionName: record.__parent.name }}> <RecordProvider record={{ ...record, collectionName: record.__parent.name }}>
<ActionContext.Provider value={{ visible, setVisible }}> <ActionContextProvider value={{ visible, setVisible }}>
<a <a
//@ts-ignore //@ts-ignore
disabled={disabled} disabled={disabled}
@ -198,7 +198,7 @@ export const OverridingFieldAction = (props) => {
...scope, ...scope,
}} }}
/> />
</ActionContext.Provider> </ActionContextProvider>
</RecordProvider> </RecordProvider>
); );
}; };

View File

@ -8,7 +8,7 @@ import React, { useState } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { useRequest } from '../../api-client'; import { useRequest } from '../../api-client';
import { RecordProvider, useRecord } from '../../record-provider'; import { RecordProvider, useRecord } from '../../record-provider';
import { ActionContext, SchemaComponent, useActionContext, useCompile } from '../../schema-component'; import { ActionContextProvider, SchemaComponent, useActionContext, useCompile } from '../../schema-component';
import { useCancelAction } from '../action-hooks'; import { useCancelAction } from '../action-hooks';
import { useCollectionManager } from '../hooks'; import { useCollectionManager } from '../hooks';
import { IField } from '../interfaces/types'; import { IField } from '../interfaces/types';
@ -167,7 +167,7 @@ export const SyncFieldsActionCom = (props) => {
return ( return (
record.template === 'view' && ( record.template === 'view' && (
<RecordProvider record={record}> <RecordProvider record={record}>
<ActionContext.Provider value={{ visible, setVisible }}> <ActionContextProvider value={{ visible, setVisible }}>
{children || ( {children || (
<Button <Button
icon={<PlusOutlined />} icon={<PlusOutlined />}
@ -195,7 +195,7 @@ export const SyncFieldsActionCom = (props) => {
...scope, ...scope,
}} }}
/> />
</ActionContext.Provider> </ActionContextProvider>
</RecordProvider> </RecordProvider>
) )
); );

View File

@ -7,7 +7,7 @@ import React, { useState } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { useAPIClient, useRequest } from '../../api-client'; import { useAPIClient, useRequest } from '../../api-client';
import { RecordProvider, useRecord } from '../../record-provider'; import { RecordProvider, useRecord } from '../../record-provider';
import { ActionContext, SchemaComponent, useCompile } from '../../schema-component'; import { ActionContextProvider, SchemaComponent, useCompile } from '../../schema-component';
import { useCollectionManager } from '../hooks'; import { useCollectionManager } from '../hooks';
import { IField } from '../interfaces/types'; import { IField } from '../interfaces/types';
import * as components from './components'; import * as components from './components';
@ -75,7 +75,7 @@ export const ViewFieldAction = (props) => {
return ( return (
<RecordProvider record={record}> <RecordProvider record={record}>
<ActionContext.Provider value={{ visible, setVisible }}> <ActionContextProvider value={{ visible, setVisible }}>
<a <a
onClick={async () => { onClick={async () => {
const { data } = await api.resource('collections.fields', record.collectionName).get({ const { data } = await api.resource('collections.fields', record.collectionName).get({
@ -116,7 +116,7 @@ export const ViewFieldAction = (props) => {
...scope, ...scope,
}} }}
/> />
</ActionContext.Provider> </ActionContextProvider>
</RecordProvider> </RecordProvider>
); );
}; };

View File

@ -1,6 +1,6 @@
import { VerifiedOutlined } from '@ant-design/icons'; import { VerifiedOutlined } from '@ant-design/icons';
import { ISchema, useForm } from '@formily/react'; import { ISchema, useForm } from '@formily/react';
import { ActionContext, PluginManager, SchemaComponent, useActionContext } from '@nocobase/client'; import { ActionContextProvider, PluginManager, SchemaComponent, useActionContext } from '@nocobase/client';
import React, { useState } from 'react'; import React, { useState } from 'react';
const useCloseAction = () => { const useCloseAction = () => {
@ -51,7 +51,7 @@ export const Plugin2 = () => null;
Plugin2.ToolbarItem = () => { Plugin2.ToolbarItem = () => {
const [visible, setVisible] = useState(false); const [visible, setVisible] = useState(false);
return ( return (
<ActionContext.Provider value={{ visible, setVisible }}> <ActionContextProvider value={{ visible, setVisible }}>
<PluginManager.Toolbar.Item <PluginManager.Toolbar.Item
icon={<VerifiedOutlined />} icon={<VerifiedOutlined />}
title={'Plugin2'} title={'Plugin2'}
@ -60,6 +60,6 @@ Plugin2.ToolbarItem = () => {
}} }}
/> />
<SchemaComponent scope={{ useCloseAction }} schema={schema} /> <SchemaComponent scope={{ useCloseAction }} schema={schema} />
</ActionContext.Provider> </ActionContextProvider>
); );
}; };

View File

@ -1,6 +1,6 @@
import { VerifiedOutlined } from '@ant-design/icons'; import { VerifiedOutlined } from '@ant-design/icons';
import { ISchema, useForm } from '@formily/react'; import { ISchema, useForm } from '@formily/react';
import { ActionContext, PluginManager, SchemaComponent, useActionContext } from '@nocobase/client'; import { ActionContextProvider, PluginManager, SchemaComponent, useActionContext } from '@nocobase/client';
import React, { useState } from 'react'; import React, { useState } from 'react';
const useCloseAction = () => { const useCloseAction = () => {
@ -51,7 +51,7 @@ export const Plugin4 = () => null;
Plugin4.ToolbarItem = () => { Plugin4.ToolbarItem = () => {
const [visible, setVisible] = useState(false); const [visible, setVisible] = useState(false);
return ( return (
<ActionContext.Provider value={{ visible, setVisible }}> <ActionContextProvider value={{ visible, setVisible }}>
<PluginManager.Toolbar.Item <PluginManager.Toolbar.Item
icon={<VerifiedOutlined />} icon={<VerifiedOutlined />}
title={'Plugin4'} title={'Plugin4'}
@ -60,6 +60,6 @@ Plugin4.ToolbarItem = () => {
}} }}
/> />
<SchemaComponent scope={{ useCloseAction }} schema={schema} /> <SchemaComponent scope={{ useCloseAction }} schema={schema} />
</ActionContext.Provider> </ActionContextProvider>
); );
}; };

View File

@ -4,7 +4,7 @@ import React, { useContext, useState } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { useHistory } from 'react-router-dom'; import { useHistory } from 'react-router-dom';
import { useACLRoleContext } from '../acl/ACLProvider'; import { useACLRoleContext } from '../acl/ACLProvider';
import { ActionContext, useCompile } from '../schema-component'; import { ActionContextProvider, useCompile } from '../schema-component';
import { getPluginsTabs, SettingsCenterContext } from './index'; import { getPluginsTabs, SettingsCenterContext } from './index';
export const PluginManagerLink = () => { export const PluginManagerLink = () => {
@ -43,7 +43,7 @@ export const SettingsCenterDropdown = () => {
const pluginsTabs = getPluginsTabs(itemData, snippets); const pluginsTabs = getPluginsTabs(itemData, snippets);
const bookmarkTabs = getBookmarkTabs(pluginsTabs); const bookmarkTabs = getBookmarkTabs(pluginsTabs);
return ( return (
<ActionContext.Provider value={{ visible, setVisible }}> <ActionContextProvider value={{ visible, setVisible }}>
<Dropdown <Dropdown
placement="bottom" placement="bottom"
menu={{ menu={{
@ -68,6 +68,6 @@ export const SettingsCenterDropdown = () => {
// title={t('All plugin settings')} // title={t('All plugin settings')}
/> />
</Dropdown> </Dropdown>
</ActionContext.Provider> </ActionContextProvider>
); );
}; };

View File

@ -1,7 +1,7 @@
import { ISchema, observer, useForm } from '@formily/react'; import { ISchema, observer, useForm } from '@formily/react';
import { import {
Action, Action,
ActionContext, ActionContextProvider,
Form, Form,
FormItem, FormItem,
Input, Input,
@ -58,10 +58,10 @@ export default observer(() => {
const [visible, setVisible] = useState(false); const [visible, setVisible] = useState(false);
return ( return (
<SchemaComponentProvider components={{ Form, Action, Input, FormItem }}> <SchemaComponentProvider components={{ Form, Action, Input, FormItem }}>
<ActionContext.Provider value={{ visible, setVisible }}> <ActionContextProvider value={{ visible, setVisible }}>
<a onClick={() => setVisible(true)}>Open</a> <a onClick={() => setVisible(true)}>Open</a>
<SchemaComponent scope={{ useCloseAction }} schema={schema} /> <SchemaComponent scope={{ useCloseAction }} schema={schema} />
</ActionContext.Provider> </ActionContextProvider>
</SchemaComponentProvider> </SchemaComponentProvider>
); );
}); });

View File

@ -14,7 +14,7 @@ import {
} from '../../../block-provider/TableSelectorProvider'; } from '../../../block-provider/TableSelectorProvider';
import { CollectionProvider, useCollection } from '../../../collection-manager'; import { CollectionProvider, useCollection } from '../../../collection-manager';
import { useCompile } from '../../hooks'; import { useCompile } from '../../hooks';
import { ActionContext } from '../action'; import { ActionContextProvider } from '../action';
import { FileSelector, Preview } from '../preview'; import { FileSelector, Preview } from '../preview';
import { ReadPrettyInternalViewer } from './InternalViewer'; import { ReadPrettyInternalViewer } from './InternalViewer';
import { useFieldNames, useInsertSchema } from './hooks'; import { useFieldNames, useInsertSchema } from './hooks';
@ -152,7 +152,7 @@ const InternalFileManager = (props) => {
} }
}} }}
/> />
<ActionContext.Provider value={{ openMode: 'drawer', visible: visibleSelector, setVisible: setVisibleSelector }}> <ActionContextProvider value={{ openMode: 'drawer', visible: visibleSelector, setVisible: setVisibleSelector }}>
<RecordPickerProvider {...pickerProps}> <RecordPickerProvider {...pickerProps}>
<CollectionProvider name={collectionField.target}> <CollectionProvider name={collectionField.target}>
<FormProvider> <FormProvider>
@ -171,7 +171,7 @@ const InternalFileManager = (props) => {
</FormProvider> </FormProvider>
</CollectionProvider> </CollectionProvider>
</RecordPickerProvider> </RecordPickerProvider>
</ActionContext.Provider> </ActionContextProvider>
</div> </div>
); );
}; };

View File

@ -16,7 +16,7 @@ import {
} from '../../../block-provider/TableSelectorProvider'; } from '../../../block-provider/TableSelectorProvider';
import { CollectionProvider } from '../../../collection-manager'; import { CollectionProvider } from '../../../collection-manager';
import { useCompile } from '../../hooks'; import { useCompile } from '../../hooks';
import { ActionContext } from '../action'; import { ActionContextProvider } from '../action';
import { useAssociationFieldContext, useFieldNames, useInsertSchema } from './hooks'; import { useAssociationFieldContext, useFieldNames, useInsertSchema } from './hooks';
import schema from './schema'; import schema from './schema';
import { flatData, getLabelFormatValue, useLabelUiSchema } from './util'; import { flatData, getLabelFormatValue, useLabelUiSchema } from './util';
@ -175,9 +175,7 @@ export const InternalPicker = observer(
</RecordProvider> </RecordProvider>
)} )}
</Input.Group> </Input.Group>
<ActionContext.Provider <ActionContextProvider value={{ openMode: 'drawer', visible: visibleSelector, setVisible: setVisibleSelector }}>
value={{ openMode: 'drawer', visible: visibleSelector, setVisible: setVisibleSelector }}
>
<RecordPickerProvider {...pickerProps}> <RecordPickerProvider {...pickerProps}>
<CollectionProvider name={collectionField?.target}> <CollectionProvider name={collectionField?.target}>
<FormProvider> <FormProvider>
@ -196,7 +194,7 @@ export const InternalPicker = observer(
</FormProvider> </FormProvider>
</CollectionProvider> </CollectionProvider>
</RecordPickerProvider> </RecordPickerProvider>
</ActionContext.Provider> </ActionContextProvider>
</> </>
); );
}, },

View File

@ -6,7 +6,7 @@ import { CollectionProvider } from '../../../collection-manager';
import { RecordProvider, useRecord } from '../../../record-provider'; import { RecordProvider, useRecord } from '../../../record-provider';
import { FormProvider } from '../../core'; import { FormProvider } from '../../core';
import { useCompile } from '../../hooks'; import { useCompile } from '../../hooks';
import { ActionContext, useActionContext } from '../action'; import { ActionContextProvider, useActionContext } from '../action';
import { EllipsisWithTooltip } from '../input/EllipsisWithTooltip'; import { EllipsisWithTooltip } from '../input/EllipsisWithTooltip';
import { useAssociationFieldContext, useFieldNames, useInsertSchema } from './hooks'; import { useAssociationFieldContext, useFieldNames, useInsertSchema } from './hooks';
import schema from './schema'; import schema from './schema';
@ -104,11 +104,11 @@ export const ReadPrettyInternalViewer: React.FC = observer(
<EllipsisWithTooltip ellipsis={true} ref={ellipsisWithTooltipRef}> <EllipsisWithTooltip ellipsis={true} ref={ellipsisWithTooltipRef}>
{renderRecords()} {renderRecords()}
</EllipsisWithTooltip> </EllipsisWithTooltip>
<ActionContext.Provider <ActionContextProvider
value={{ visible, setVisible, openMode: 'drawer', snapshot: collectionField?.interface === 'snapshot' }} value={{ visible, setVisible, openMode: 'drawer', snapshot: collectionField?.interface === 'snapshot' }}
> >
{renderRecordProvider()} {renderRecordProvider()}
</ActionContext.Provider> </ActionContextProvider>
</CollectionProvider> </CollectionProvider>
</BlockAssociationContext.Provider> </BlockAssociationContext.Provider>
</div> </div>

View File

@ -2,7 +2,7 @@ import { RecursionField, observer, useField, useFieldSchema } from '@formily/rea
import React, { useState } from 'react'; import React, { useState } from 'react';
import { CollectionProvider } from '../../../../collection-manager'; import { CollectionProvider } from '../../../../collection-manager';
import { CreateAction } from '../../../../schema-initializer/components'; import { CreateAction } from '../../../../schema-initializer/components';
import { ActionContext, useActionContext } from '../../action'; import { ActionContextProvider, useActionContext } from '../../action';
import { useAssociationFieldContext, useInsertSchema } from '../hooks'; import { useAssociationFieldContext, useInsertSchema } from '../hooks';
import schema from '../schema'; import schema from '../schema';
@ -23,7 +23,7 @@ export const CreateRecordAction = observer(
return ( return (
<CollectionProvider name={collectionField?.target}> <CollectionProvider name={collectionField?.target}>
<CreateAction {...props} onClick={(arg) => addbuttonClick(arg)} /> <CreateAction {...props} onClick={(arg) => addbuttonClick(arg)} />
<ActionContext.Provider value={{ ...ctx, visible: visibleAddNewer, setVisible: setVisibleAddNewer }}> <ActionContextProvider value={{ ...ctx, visible: visibleAddNewer, setVisible: setVisibleAddNewer }}>
<CollectionProvider name={currentCollection}> <CollectionProvider name={currentCollection}>
<RecursionField <RecursionField
onlyRenderProperties onlyRenderProperties
@ -34,7 +34,7 @@ export const CreateRecordAction = observer(
}} }}
/> />
</CollectionProvider> </CollectionProvider>
</ActionContext.Provider> </ActionContextProvider>
</CollectionProvider> </CollectionProvider>
); );
}, },

View File

@ -11,7 +11,7 @@ import { useTranslation } from 'react-i18next';
import { RecordProvider } from '../../../'; import { RecordProvider } from '../../../';
import { i18n } from '../../../i18n'; import { i18n } from '../../../i18n';
import { useProps } from '../../hooks/useProps'; import { useProps } from '../../hooks/useProps';
import { ActionContext } from '../action'; import { ActionContextProvider } from '../action';
import Header from './components/Header'; import Header from './components/Header';
import { CalendarToolbarContext } from './context'; import { CalendarToolbarContext } from './context';
import './style.less'; import './style.less';
@ -180,11 +180,11 @@ const CalendarRecordViewer = (props) => {
return ( return (
eventSchema && ( eventSchema && (
<DeleteEventContext.Provider value={{ close }}> <DeleteEventContext.Provider value={{ close }}>
<ActionContext.Provider value={{ visible, setVisible }}> <ActionContextProvider value={{ visible, setVisible }}>
<RecordProvider record={record}> <RecordProvider record={record}>
<RecursionField schema={eventSchema} name={eventSchema.name} /> <RecursionField schema={eventSchema} name={eventSchema.name} />
</RecordProvider> </RecordProvider>
</ActionContext.Provider> </ActionContextProvider>
</DeleteEventContext.Provider> </DeleteEventContext.Provider>
) )
); );

View File

@ -2,7 +2,7 @@ import { FormItem } from '@formily/antd';
import { ISchema, observer } from '@formily/react'; import { ISchema, observer } from '@formily/react';
import { import {
Action, Action,
ActionContext, ActionContextProvider,
Form, Form,
Input, Input,
SchemaComponent, SchemaComponent,
@ -71,7 +71,7 @@ export default observer(() => {
return ( return (
<SchemaComponentProvider components={{ Action, Input, FormItem, Form }} scope={{ useCloseAction }}> <SchemaComponentProvider components={{ Action, Input, FormItem, Form }} scope={{ useCloseAction }}>
<ActionContext.Provider value={{ visible, setVisible }}> <ActionContextProvider value={{ visible, setVisible }}>
<Button <Button
onClick={() => { onClick={() => {
setVisible(true); setVisible(true);
@ -80,7 +80,7 @@ export default observer(() => {
Edit Edit
</Button> </Button>
<SchemaComponent schema={schema} /> <SchemaComponent schema={schema} />
</ActionContext.Provider> </ActionContextProvider>
</SchemaComponentProvider> </SchemaComponentProvider>
); );
}); });

View File

@ -8,7 +8,7 @@ import { useCurrentAppInfo } from '../../../../../appInfo';
import { useBlockRequestContext, useGanttBlockContext, useTableBlockContext } from '../../../../../block-provider'; import { useBlockRequestContext, useGanttBlockContext, useTableBlockContext } from '../../../../../block-provider';
import { RecordProvider } from '../../../../../record-provider'; import { RecordProvider } from '../../../../../record-provider';
import { useDesignable } from '../../../../../schema-component'; import { useDesignable } from '../../../../../schema-component';
import { ActionContext } from '../../../action'; import { ActionContextProvider } from '../../../action';
import { convertToBarTasks } from '../../helpers/bar-helper'; import { convertToBarTasks } from '../../helpers/bar-helper';
import { ganttDateRange, seedDates } from '../../helpers/date-helper'; import { ganttDateRange, seedDates } from '../../helpers/date-helper';
import { removeHiddenTasks, sortTasks } from '../../helpers/other-helper'; import { removeHiddenTasks, sortTasks } from '../../helpers/other-helper';
@ -44,11 +44,11 @@ const GanttRecordViewer = (props) => {
return ( return (
eventSchema && ( eventSchema && (
<DeleteEventContext.Provider value={{ close }}> <DeleteEventContext.Provider value={{ close }}>
<ActionContext.Provider value={{ visible, setVisible }}> <ActionContextProvider value={{ visible, setVisible }}>
<RecordProvider record={record}> <RecordProvider record={record}>
<RecursionField schema={eventSchema} name={eventSchema.name} /> <RecursionField schema={eventSchema} name={eventSchema.name} />
</RecordProvider> </RecordProvider>
</ActionContext.Provider> </ActionContextProvider>
</DeleteEventContext.Provider> </DeleteEventContext.Provider>
) )
); );

View File

@ -4,7 +4,7 @@ import { observer, RecursionField, useFieldSchema } from '@formily/react';
import { Card } from 'antd'; import { Card } from 'antd';
import React, { useContext, useState } from 'react'; import React, { useContext, useState } from 'react';
import cls from 'classnames'; import cls from 'classnames';
import { ActionContext } from '..'; import { ActionContextProvider } from '..';
import { DndContext } from '../..'; import { DndContext } from '../..';
import { RecordProvider } from '../../../record-provider'; import { RecordProvider } from '../../../record-provider';
import { SchemaComponentOptions } from '../../core/SchemaComponentOptions'; import { SchemaComponentOptions } from '../../core/SchemaComponentOptions';
@ -86,7 +86,7 @@ export const KanbanCard: any = observer(
</DndContext> </DndContext>
</Card> </Card>
{cardViewerSchema && ( {cardViewerSchema && (
<ActionContext.Provider <ActionContextProvider
value={{ value={{
openMode: fieldSchema['x-component-props']?.['openMode'] || 'drawer', openMode: fieldSchema['x-component-props']?.['openMode'] || 'drawer',
openSize: fieldSchema['x-component-props']?.['openSize'], openSize: fieldSchema['x-component-props']?.['openSize'],
@ -101,7 +101,7 @@ export const KanbanCard: any = observer(
onlyRenderProperties onlyRenderProperties
/> />
</RecordProvider> </RecordProvider>
</ActionContext.Provider> </ActionContextProvider>
)} )}
</SchemaComponentOptions> </SchemaComponentOptions>
); );

View File

@ -7,7 +7,7 @@ import { useDesignable } from '../../';
import { useACLRolesCheck, useRecordPkValue } from '../../acl/ACLProvider'; import { useACLRolesCheck, useRecordPkValue } from '../../acl/ACLProvider';
import { CollectionProvider, useCollection, useCollectionManager } from '../../collection-manager'; import { CollectionProvider, useCollection, useCollectionManager } from '../../collection-manager';
import { useRecord } from '../../record-provider'; import { useRecord } from '../../record-provider';
import { ActionContext, useActionContext, useCompile } from '../../schema-component'; import { ActionContextProvider, useActionContext, useCompile } from '../../schema-component';
import { linkageAction } from '../../schema-component/antd/action/utils'; import { linkageAction } from '../../schema-component/antd/action/utils';
export const actionDesignerCss = css` export const actionDesignerCss = css`
@ -102,7 +102,7 @@ export const CreateRecordAction = observer(
}, [linkageRules, values]); }, [linkageRules, values]);
return ( return (
<div className={actionDesignerCss}> <div className={actionDesignerCss}>
<ActionContext.Provider value={{ ...ctx, visible, setVisible }}> <ActionContextProvider value={{ ...ctx, visible, setVisible }}>
<CreateAction <CreateAction
{...props} {...props}
onClick={(name) => { onClick={(name) => {
@ -113,7 +113,7 @@ export const CreateRecordAction = observer(
<CollectionProvider name={currentCollection}> <CollectionProvider name={currentCollection}>
<RecursionField schema={fieldSchema} basePath={field.address} onlyRenderProperties /> <RecursionField schema={fieldSchema} basePath={field.address} onlyRenderProperties />
</CollectionProvider> </CollectionProvider>
</ActionContext.Provider> </ActionContextProvider>
</div> </div>
); );
}, },

View File

@ -1,6 +1,6 @@
import React, { createContext, useContext, useState } from 'react'; import React, { createContext, useContext, useState } from 'react';
import { observer, RecursionField, useField, useFieldSchema } from '@formily/react'; import { observer, RecursionField, useField, useFieldSchema } from '@formily/react';
import { RecordProvider, ActionContext, useActionContext, useRecord, useCollection } from '../../'; import { RecordProvider, ActionContextProvider, useActionContext, useRecord, useCollection } from '../../';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { css, cx } from '@emotion/css'; import { css, cx } from '@emotion/css';
import { useAPIClient, useBlockRequestContext, useDesignable } from '../../'; import { useAPIClient, useBlockRequestContext, useDesignable } from '../../';
@ -111,9 +111,9 @@ export const DuplicateAction = observer((props: any) => {
{loading ? t('Duplicating') : children || t('Duplicate')} {loading ? t('Duplicating') : children || t('Duplicate')}
</Button> </Button>
)} )}
<ActionContext.Provider value={{ ...ctx, visible, setVisible }}> <ActionContextProvider value={{ ...ctx, visible, setVisible }}>
<RecursionField schema={fieldSchema} basePath={field.address} onlyRenderProperties /> <RecursionField schema={fieldSchema} basePath={field.address} onlyRenderProperties />
</ActionContext.Provider> </ActionContextProvider>
</div> </div>
</DuplicatefieldsContext.Provider> </DuplicatefieldsContext.Provider>
</div> </div>

View File

@ -25,7 +25,7 @@ import { createPortal } from 'react-dom';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { import {
APIClientProvider, APIClientProvider,
ActionContext, ActionContextProvider,
CollectionFieldOptions, CollectionFieldOptions,
CollectionManagerContext, CollectionManagerContext,
Designable, Designable,
@ -664,7 +664,7 @@ SchemaSettings.PopupItem = function PopupItem(props) {
const [visible, setVisible] = useState(false); const [visible, setVisible] = useState(false);
const ctx = useContext(SchemaSettingsContext); const ctx = useContext(SchemaSettingsContext);
return ( return (
<ActionContext.Provider value={{ visible, setVisible }}> <ActionContextProvider value={{ visible, setVisible }}>
<SchemaSettings.Item <SchemaSettings.Item
{...others} {...others}
onClick={() => { onClick={() => {
@ -681,7 +681,7 @@ SchemaSettings.PopupItem = function PopupItem(props) {
...schema, ...schema,
}} }}
/> />
</ActionContext.Provider> </ActionContextProvider>
); );
}; };

View File

@ -9,7 +9,7 @@ import { useHistory } from 'react-router-dom';
import { useSystemSettings } from '.'; import { useSystemSettings } from '.';
import { i18n, PluginManager, useAPIClient, useRequest } from '..'; import { i18n, PluginManager, useAPIClient, useRequest } from '..';
import locale from '../locale'; import locale from '../locale';
import { ActionContext, SchemaComponent, useActionContext } from '../schema-component'; import { ActionContextProvider, SchemaComponent, useActionContext } from '../schema-component';
const langs = Object.keys(locale).map((lang) => { const langs = Object.keys(locale).map((lang) => {
return { return {
@ -300,7 +300,7 @@ export const SystemSettingsShortcut2 = () => {
const [visible, setVisible] = useState(false); const [visible, setVisible] = useState(false);
const { t } = useTranslation(); const { t } = useTranslation();
return ( return (
<ActionContext.Provider value={{ visible, setVisible }}> <ActionContextProvider value={{ visible, setVisible }}>
<PluginManager.Toolbar.Item <PluginManager.Toolbar.Item
eventKey={'ACLAction'} eventKey={'ACLAction'}
onClick={() => { onClick={() => {
@ -313,6 +313,6 @@ export const SystemSettingsShortcut2 = () => {
scope={{ useSaveSystemSettingsValues, useSystemSettingsValues, useCloseAction }} scope={{ useSaveSystemSettingsValues, useSystemSettingsValues, useCloseAction }}
schema={schema} schema={schema}
/> />
</ActionContext.Provider> </ActionContextProvider>
); );
}; };

View File

@ -1,5 +1,5 @@
import { import {
ActionContext, ActionContextProvider,
SchemaComponent, SchemaComponent,
useAPIClient, useAPIClient,
useActionContext, useActionContext,
@ -38,7 +38,7 @@ const AddNew = () => {
})); }));
return ( return (
<ActionContext.Provider value={{ visible, setVisible }}> <ActionContextProvider value={{ visible, setVisible }}>
<AuthTypeContext.Provider value={{ type }}> <AuthTypeContext.Provider value={{ type }}>
<Dropdown menu={{ items }}> <Dropdown menu={{ items }}>
<Button icon={<PlusOutlined />} type={'primary'}> <Button icon={<PlusOutlined />} type={'primary'}>
@ -47,7 +47,7 @@ const AddNew = () => {
</Dropdown> </Dropdown>
<SchemaComponent scope={{ useCloseAction, types, setType }} schema={createFormSchema} /> <SchemaComponent scope={{ useCloseAction, types, setType }} schema={createFormSchema} />
</AuthTypeContext.Provider> </AuthTypeContext.Provider>
</ActionContext.Provider> </ActionContextProvider>
); );
}; };

View File

@ -3,7 +3,7 @@ import { createForm } from '@formily/core';
import { ISchema, useForm } from '@formily/react'; import { ISchema, useForm } from '@formily/react';
import { uid } from '@formily/shared'; import { uid } from '@formily/shared';
import { import {
ActionContext, ActionContextProvider,
SchemaComponent, SchemaComponent,
useActionContext, useActionContext,
useRecord, useRecord,
@ -129,14 +129,14 @@ export const AddNewQuery = () => {
</Menu> </Menu>
); );
return ( return (
<ActionContext.Provider value={{ visible, setVisible }}> <ActionContextProvider value={{ visible, setVisible }}>
<Dropdown overlay={menu}> <Dropdown overlay={menu}>
<Button icon={<PlusOutlined />} type={'primary'}> <Button icon={<PlusOutlined />} type={'primary'}>
{lang('Add query')} <DownOutlined /> {lang('Add query')} <DownOutlined />
</Button> </Button>
</Dropdown> </Dropdown>
<SchemaComponent schema={schema} scope={{ useCloseAction, useSubmitAction: useCreateAction }} /> <SchemaComponent schema={schema} scope={{ useCloseAction, useSubmitAction: useCreateAction }} />
</ActionContext.Provider> </ActionContextProvider>
); );
}; };
@ -146,7 +146,7 @@ export const EditQuery = () => {
const form = useMemo(() => createForm(), []); const form = useMemo(() => createForm(), []);
const schema = getSchema(record, { form, isNewRecord: false }); const schema = getSchema(record, { form, isNewRecord: false });
return ( return (
<ActionContext.Provider value={{ visible, setVisible }}> <ActionContextProvider value={{ visible, setVisible }}>
<a <a
onClick={() => { onClick={() => {
form.setValues(record); form.setValues(record);
@ -156,6 +156,6 @@ export const EditQuery = () => {
{lang('Edit')} {lang('Edit')}
</a> </a>
<SchemaComponent schema={schema} scope={{ useCloseAction, useSubmitAction: useUpdateAction }} /> <SchemaComponent schema={schema} scope={{ useCloseAction, useSubmitAction: useUpdateAction }} />
</ActionContext.Provider> </ActionContextProvider>
); );
}; };

View File

@ -1,6 +1,6 @@
import { FileOutlined } from '@ant-design/icons'; import { FileOutlined } from '@ant-design/icons';
import { uid } from '@formily/shared'; import { uid } from '@formily/shared';
import { ActionContext, PluginManager, SchemaComponent } from '@nocobase/client'; import { ActionContextProvider, PluginManager, SchemaComponent } from '@nocobase/client';
import React, { useState } from 'react'; import React, { useState } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { storageSchema } from './schemas/storage'; import { storageSchema } from './schemas/storage';
@ -24,7 +24,7 @@ export const FileStorageShortcut = () => {
const [visible, setVisible] = useState(false); const [visible, setVisible] = useState(false);
const { t } = useTranslation(); const { t } = useTranslation();
return ( return (
<ActionContext.Provider value={{ visible, setVisible }}> <ActionContextProvider value={{ visible, setVisible }}>
<PluginManager.Toolbar.Item <PluginManager.Toolbar.Item
eventKey={'FileStorage'} eventKey={'FileStorage'}
onClick={() => { onClick={() => {
@ -34,6 +34,6 @@ export const FileStorageShortcut = () => {
title={t('File manager')} title={t('File manager')}
/> />
<SchemaComponent components={{ StorageOptions }} schema={schema} /> <SchemaComponent components={{ StorageOptions }} schema={schema} />
</ActionContext.Provider> </ActionContextProvider>
); );
}; };

View File

@ -1,7 +1,14 @@
import { CheckOutlined, EnvironmentOutlined, ExpandOutlined } from '@ant-design/icons'; import { CheckOutlined, EnvironmentOutlined, ExpandOutlined } from '@ant-design/icons';
import { css } from '@emotion/css'; import { css } from '@emotion/css';
import { RecursionField, Schema, useFieldSchema } from '@formily/react'; import { RecursionField, Schema, useFieldSchema } from '@formily/react';
import { ActionContext, RecordProvider, useCollection, useCompile, useFilterAPI, useProps } from '@nocobase/client'; import {
ActionContextProvider,
RecordProvider,
useCollection,
useCompile,
useFilterAPI,
useProps,
} from '@nocobase/client';
import { useMemoizedFn } from 'ahooks'; import { useMemoizedFn } from 'ahooks';
import { Button, Space } from 'antd'; import { Button, Space } from 'antd';
import React, { useEffect, useMemo, useRef, useState } from 'react'; import React, { useEffect, useMemo, useRef, useState } from 'react';
@ -272,11 +279,11 @@ const MapBlockDrawer = (props) => {
return ( return (
schema && ( schema && (
<ActionContext.Provider value={{ visible: !!record, setVisible }}> <ActionContextProvider value={{ visible: !!record, setVisible }}>
<RecordProvider record={record}> <RecordProvider record={record}>
<RecursionField schema={schema} name={schema.name} /> <RecursionField schema={schema} name={schema.name} />
</RecordProvider> </RecordProvider>
</ActionContext.Provider> </ActionContextProvider>
) )
); );
}; };

View File

@ -4,7 +4,7 @@ import { css } from '@emotion/css';
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
import { import {
ActionContext, ActionContextProvider,
SchemaComponent, SchemaComponent,
useCompile, useCompile,
useDocumentTitle, useDocumentTitle,
@ -47,7 +47,7 @@ function JobModal() {
const instruction = instructions.get(node.type); const instruction = instructions.get(node.type);
return ( return (
<ActionContext.Provider value={{ visible: Boolean(job), setVisible: setViewJob }}> <ActionContextProvider value={{ visible: Boolean(job), setVisible: setViewJob }}>
<SchemaComponent <SchemaComponent
schema={{ schema={{
type: 'void', type: 'void',
@ -103,7 +103,7 @@ function JobModal() {
}, },
}} }}
/> />
</ActionContext.Provider> </ActionContextProvider>
); );
} }
@ -141,7 +141,7 @@ export function ExecutionCanvas() {
nodes, nodes,
execution, execution,
viewJob, viewJob,
setViewJob setViewJob,
}} }}
> >
<div className="workflow-toolbar"> <div className="workflow-toolbar">

View File

@ -7,7 +7,7 @@ import classnames from 'classnames';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { import {
ActionContext, ActionContextProvider,
ResourceActionProvider, ResourceActionProvider,
SchemaComponent, SchemaComponent,
useDocumentTitle, useDocumentTitle,
@ -202,7 +202,7 @@ export function WorkflowCanvas() {
> >
<Button type="text" icon={<EllipsisOutlined />} /> <Button type="text" icon={<EllipsisOutlined />} />
</Dropdown> </Dropdown>
<ActionContext.Provider value={{ visible, setVisible }}> <ActionContextProvider value={{ visible, setVisible }}>
<SchemaComponent <SchemaComponent
schema={executionSchema} schema={executionSchema}
components={{ components={{
@ -210,7 +210,7 @@ export function WorkflowCanvas() {
ExecutionLink, ExecutionLink,
}} }}
/> />
</ActionContext.Provider> </ActionContextProvider>
</aside> </aside>
</div> </div>
<CanvasContent entry={entry} /> <CanvasContent entry={entry} />

View File

@ -1,13 +1,13 @@
import React, { useState } from 'react'; import React, { useState } from 'react';
import { useFieldSchema } from '@formily/react'; import { useFieldSchema } from '@formily/react';
import { ActionContext, SchemaComponent } from '@nocobase/client'; import { ActionContextProvider, SchemaComponent } from '@nocobase/client';
export default function ({ component = 'div', children, ...props }) { export default function ({ component = 'div', children, ...props }) {
const [visible, setVisible] = useState(false); const [visible, setVisible] = useState(false);
const fieldSchema = useFieldSchema(); const fieldSchema = useFieldSchema();
return ( return (
<ActionContext.Provider value={{ visible, setVisible, fieldSchema }}> <ActionContextProvider value={{ visible, setVisible, fieldSchema }}>
{React.createElement( {React.createElement(
component, component,
{ {
@ -19,6 +19,6 @@ export default function ({ component = 'div', children, ...props }) {
children, children,
)} )}
<SchemaComponent schema={fieldSchema} onlyRenderProperties /> <SchemaComponent schema={fieldSchema} onlyRenderProperties />
</ActionContext.Provider> </ActionContextProvider>
); );
} }

View File

@ -7,7 +7,7 @@ import { useTranslation } from 'react-i18next';
import { Registry, parse, str2moment } from '@nocobase/utils/client'; import { Registry, parse, str2moment } from '@nocobase/utils/client';
import { import {
ActionContext, ActionContextProvider,
SchemaComponent, SchemaComponent,
SchemaInitializerItemOptions, SchemaInitializerItemOptions,
useActionContext, useActionContext,
@ -371,7 +371,7 @@ export function NodeDefaultView(props) {
</div> </div>
<RemoveButton /> <RemoveButton />
<JobButton /> <JobButton />
<ActionContext.Provider value={{ visible: editingConfig, setVisible: setEditingConfig }}> <ActionContextProvider value={{ visible: editingConfig, setVisible: setEditingConfig }}>
<SchemaComponent <SchemaComponent
scope={instruction.scope} scope={instruction.scope}
components={instruction.components} components={instruction.components}
@ -486,7 +486,7 @@ export function NodeDefaultView(props) {
}, },
}} }}
/> />
</ActionContext.Provider> </ActionContextProvider>
</div> </div>
{children} {children}
</div> </div>

View File

@ -11,7 +11,7 @@ import {
InitializerWithSwitch, InitializerWithSwitch,
SchemaInitializerProvider, SchemaInitializerProvider,
gridRowColWrap, gridRowColWrap,
ActionContext, ActionContextProvider,
GeneralSchemaDesigner, GeneralSchemaDesigner,
SchemaSettings, SchemaSettings,
useCompile, useCompile,
@ -360,7 +360,7 @@ export function SchemaConfigButton(props) {
<div className="ant-btn ant-btn-primary" onClick={() => setVisible(true)}> <div className="ant-btn ant-btn-primary" onClick={() => setVisible(true)}>
{workflow.executed ? lang('View user interface') : lang('Configure user interface')} {workflow.executed ? lang('View user interface') : lang('Configure user interface')}
</div> </div>
<ActionContext.Provider value={{ visible, setVisible }}>{props.children}</ActionContext.Provider> <ActionContextProvider value={{ visible, setVisible }}>{props.children}</ActionContextProvider>
</> </>
); );
} }

View File

@ -6,7 +6,7 @@ import { useForm } from '@formily/react';
import { ArrayTable } from '@formily/antd'; import { ArrayTable } from '@formily/antd';
import { import {
ActionContext, ActionContextProvider,
CollectionContext, CollectionContext,
CollectionProvider, CollectionProvider,
gridRowColWrap, gridRowColWrap,
@ -206,7 +206,7 @@ function AddCustomFormField(props) {
component={component} component={component}
title="{{t('Configure fields')}}" title="{{t('Configure fields')}}"
/> />
<ActionContext.Provider value={{ visible: Boolean(interfaceOptions) }}> <ActionContextProvider value={{ visible: Boolean(interfaceOptions) }}>
{interfaceOptions ? ( {interfaceOptions ? (
<SchemaComponent <SchemaComponent
schema={{ schema={{
@ -291,7 +291,7 @@ function AddCustomFormField(props) {
}} }}
/> />
) : null} ) : null}
</ActionContext.Provider> </ActionContextProvider>
</AddCustomFormFieldButtonContext.Provider> </AddCustomFormFieldButtonContext.Provider>
); );
} }

View File

@ -7,7 +7,7 @@ import { useTranslation } from 'react-i18next';
import { InfoOutlined } from '@ant-design/icons'; import { InfoOutlined } from '@ant-design/icons';
import { import {
ActionContext, ActionContextProvider,
SchemaComponent, SchemaComponent,
SchemaInitializerItemOptions, SchemaInitializerItemOptions,
useActionContext, useActionContext,
@ -199,7 +199,7 @@ export const TriggerConfig = () => {
/> />
</div> </div>
<TriggerExecution /> <TriggerExecution />
<ActionContext.Provider value={{ visible: editingConfig, setVisible: setEditingConfig }}> <ActionContextProvider value={{ visible: editingConfig, setVisible: setEditingConfig }}>
<SchemaComponent <SchemaComponent
schema={{ schema={{
type: 'void', type: 'void',
@ -293,7 +293,7 @@ export const TriggerConfig = () => {
scope={scope} scope={scope}
components={components} components={components}
/> />
</ActionContext.Provider> </ActionContextProvider>
</div> </div>
); );
}; };