refactor: replace deprecated method
This commit is contained in:
parent
d06cce2cfa
commit
a0f9d54046
@ -1,7 +1,7 @@
|
|||||||
import { FormOutlined } from '@ant-design/icons';
|
import { FormOutlined } from '@ant-design/icons';
|
||||||
import { FormLayout } from '@formily/antd-v5';
|
import { FormLayout } from '@formily/antd-v5';
|
||||||
import { SchemaOptionsContext } from '@formily/react';
|
import { SchemaOptionsContext } from '@formily/react';
|
||||||
import { createFormBlockSchema, useAPIClient, useCollectionManager_deprecated } from '@nocobase/client';
|
import { createFormBlockSchema, useAPIClient, useCollectionManager } from '@nocobase/client';
|
||||||
import {
|
import {
|
||||||
DataBlockInitializer,
|
DataBlockInitializer,
|
||||||
FormDialog,
|
FormDialog,
|
||||||
@ -12,7 +12,7 @@ import {
|
|||||||
useSchemaInitializerItem,
|
useSchemaInitializerItem,
|
||||||
} from '@nocobase/client';
|
} from '@nocobase/client';
|
||||||
import React, { useContext } from 'react';
|
import React, { useContext } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from '../locale';
|
||||||
|
|
||||||
export const SettingBlockInitializer = () => {
|
export const SettingBlockInitializer = () => {
|
||||||
const { insert } = useSchemaInitializer();
|
const { insert } = useSchemaInitializer();
|
||||||
@ -20,7 +20,7 @@ export const SettingBlockInitializer = () => {
|
|||||||
const options = useContext(SchemaOptionsContext);
|
const options = useContext(SchemaOptionsContext);
|
||||||
const { theme } = useGlobalTheme();
|
const { theme } = useGlobalTheme();
|
||||||
const itemConfig = useSchemaInitializerItem();
|
const itemConfig = useSchemaInitializerItem();
|
||||||
const { getCollection } = useCollectionManager_deprecated();
|
const cm = useCollectionManager();
|
||||||
const api = useAPIClient();
|
const api = useAPIClient();
|
||||||
return (
|
return (
|
||||||
<DataBlockInitializer
|
<DataBlockInitializer
|
||||||
@ -28,8 +28,8 @@ export const SettingBlockInitializer = () => {
|
|||||||
componentType={'FormItem'}
|
componentType={'FormItem'}
|
||||||
icon={<FormOutlined />}
|
icon={<FormOutlined />}
|
||||||
onCreateBlockSchema={async ({ item }) => {
|
onCreateBlockSchema={async ({ item }) => {
|
||||||
const collection = getCollection(item.name);
|
const collection = cm.getCollection(item.name);
|
||||||
const titleField = collection.options.titleField;
|
const titleField = collection.titleField;
|
||||||
const result = await api.resource(collection.name).list();
|
const result = await api.resource(collection.name).list();
|
||||||
const values = await FormDialog(
|
const values = await FormDialog(
|
||||||
t('添加单条数据展示区块'),
|
t('添加单条数据展示区块'),
|
||||||
|
Loading…
Reference in New Issue
Block a user