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

View File

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

View File

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

View File

@ -8,7 +8,7 @@ import React, { useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useRequest } from '../../api-client';
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 { useCancelAction } from '../action-hooks';
import { useCollectionManager } from '../hooks';
@ -222,7 +222,7 @@ export const AddFieldAction = (props) => {
return (
record.template !== 'view' && (
<RecordProvider record={record}>
<ActionContext.Provider value={{ visible, setVisible }}>
<ActionContextProvider value={{ visible, setVisible }}>
<Dropdown
getPopupContainer={getContainer}
trigger={trigger}
@ -286,7 +286,7 @@ export const AddFieldAction = (props) => {
...scope,
}}
/>
</ActionContext.Provider>
</ActionContextProvider>
</RecordProvider>
)
);

View File

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

View File

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

View File

@ -7,7 +7,7 @@ import React, { useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useRequest } from '../../api-client';
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 { useCancelAction } from '../action-hooks';
import { useCollectionManager } from '../hooks';
@ -128,7 +128,7 @@ export const EditCollectionAction = (props) => {
return (
<RecordProvider record={record}>
<ActionContext.Provider value={{ visible, setVisible }}>
<ActionContextProvider value={{ visible, setVisible }}>
<a
onClick={async () => {
const templateConf = getTemplate(record.template);
@ -158,7 +158,7 @@ export const EditCollectionAction = (props) => {
...scope,
}}
/>
</ActionContext.Provider>
</ActionContextProvider>
</RecordProvider>
);
};

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,6 @@
import { VerifiedOutlined } from '@ant-design/icons';
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';
const useCloseAction = () => {
@ -51,7 +51,7 @@ export const Plugin4 = () => null;
Plugin4.ToolbarItem = () => {
const [visible, setVisible] = useState(false);
return (
<ActionContext.Provider value={{ visible, setVisible }}>
<ActionContextProvider value={{ visible, setVisible }}>
<PluginManager.Toolbar.Item
icon={<VerifiedOutlined />}
title={'Plugin4'}
@ -60,6 +60,6 @@ Plugin4.ToolbarItem = () => {
}}
/>
<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 { useHistory } from 'react-router-dom';
import { useACLRoleContext } from '../acl/ACLProvider';
import { ActionContext, useCompile } from '../schema-component';
import { ActionContextProvider, useCompile } from '../schema-component';
import { getPluginsTabs, SettingsCenterContext } from './index';
export const PluginManagerLink = () => {
@ -43,7 +43,7 @@ export const SettingsCenterDropdown = () => {
const pluginsTabs = getPluginsTabs(itemData, snippets);
const bookmarkTabs = getBookmarkTabs(pluginsTabs);
return (
<ActionContext.Provider value={{ visible, setVisible }}>
<ActionContextProvider value={{ visible, setVisible }}>
<Dropdown
placement="bottom"
menu={{
@ -68,6 +68,6 @@ export const SettingsCenterDropdown = () => {
// title={t('All plugin settings')}
/>
</Dropdown>
</ActionContext.Provider>
</ActionContextProvider>
);
};

View File

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

View File

@ -14,7 +14,7 @@ import {
} from '../../../block-provider/TableSelectorProvider';
import { CollectionProvider, useCollection } from '../../../collection-manager';
import { useCompile } from '../../hooks';
import { ActionContext } from '../action';
import { ActionContextProvider } from '../action';
import { FileSelector, Preview } from '../preview';
import { ReadPrettyInternalViewer } from './InternalViewer';
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}>
<CollectionProvider name={collectionField.target}>
<FormProvider>
@ -171,7 +171,7 @@ const InternalFileManager = (props) => {
</FormProvider>
</CollectionProvider>
</RecordPickerProvider>
</ActionContext.Provider>
</ActionContextProvider>
</div>
);
};

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,7 +1,14 @@
import { CheckOutlined, EnvironmentOutlined, ExpandOutlined } from '@ant-design/icons';
import { css } from '@emotion/css';
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 { Button, Space } from 'antd';
import React, { useEffect, useMemo, useRef, useState } from 'react';
@ -272,11 +279,11 @@ const MapBlockDrawer = (props) => {
return (
schema && (
<ActionContext.Provider value={{ visible: !!record, setVisible }}>
<ActionContextProvider value={{ visible: !!record, setVisible }}>
<RecordProvider record={record}>
<RecursionField schema={schema} name={schema.name} />
</RecordProvider>
</ActionContext.Provider>
</ActionContextProvider>
)
);
};

View File

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

View File

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

View File

@ -1,13 +1,13 @@
import React, { useState } from '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 }) {
const [visible, setVisible] = useState(false);
const fieldSchema = useFieldSchema();
return (
<ActionContext.Provider value={{ visible, setVisible, fieldSchema }}>
<ActionContextProvider value={{ visible, setVisible, fieldSchema }}>
{React.createElement(
component,
{
@ -19,6 +19,6 @@ export default function ({ component = 'div', children, ...props }) {
children,
)}
<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 {
ActionContext,
ActionContextProvider,
SchemaComponent,
SchemaInitializerItemOptions,
useActionContext,
@ -371,7 +371,7 @@ export function NodeDefaultView(props) {
</div>
<RemoveButton />
<JobButton />
<ActionContext.Provider value={{ visible: editingConfig, setVisible: setEditingConfig }}>
<ActionContextProvider value={{ visible: editingConfig, setVisible: setEditingConfig }}>
<SchemaComponent
scope={instruction.scope}
components={instruction.components}
@ -486,7 +486,7 @@ export function NodeDefaultView(props) {
},
}}
/>
</ActionContext.Provider>
</ActionContextProvider>
</div>
{children}
</div>

View File

@ -11,7 +11,7 @@ import {
InitializerWithSwitch,
SchemaInitializerProvider,
gridRowColWrap,
ActionContext,
ActionContextProvider,
GeneralSchemaDesigner,
SchemaSettings,
useCompile,
@ -360,7 +360,7 @@ export function SchemaConfigButton(props) {
<div className="ant-btn ant-btn-primary" onClick={() => setVisible(true)}>
{workflow.executed ? lang('View user interface') : lang('Configure user interface')}
</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 {
ActionContext,
ActionContextProvider,
CollectionContext,
CollectionProvider,
gridRowColWrap,
@ -206,7 +206,7 @@ function AddCustomFormField(props) {
component={component}
title="{{t('Configure fields')}}"
/>
<ActionContext.Provider value={{ visible: Boolean(interfaceOptions) }}>
<ActionContextProvider value={{ visible: Boolean(interfaceOptions) }}>
{interfaceOptions ? (
<SchemaComponent
schema={{
@ -291,7 +291,7 @@ function AddCustomFormField(props) {
}}
/>
) : null}
</ActionContext.Provider>
</ActionContextProvider>
</AddCustomFormFieldButtonContext.Provider>
);
}

View File

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