Merge branch 'next' into develop

This commit is contained in:
nocobase[bot] 2025-04-28 06:16:49 +00:00
commit 1978d0edd5
7 changed files with 7 additions and 27 deletions

View File

@ -61,14 +61,11 @@ export const TableBlockInitializer = ({
export const useCreateTableBlock = () => {
const { insert } = useSchemaInitializer();
const { getCollection } = useCollectionManager_deprecated();
const createTableBlock = ({ item }) => {
const collection = getCollection(item.name, item.dataSource);
const schema = createTableBlockUISchema({
collectionName: item.name,
dataSource: item.dataSource,
rowKey: collection.filterTargetKey || 'id',
});
insert(schema);
};

View File

@ -17,7 +17,7 @@ vi.mock('@formily/shared', () => {
describe('createTableBLockSchemaV2', () => {
it('should create a default table block schema with minimum options', () => {
const options = { dataSource: 'abc', collectionName: 'users', association: 'users.roles', rowKey: 'rowKey' };
const options = { dataSource: 'abc', collectionName: 'users', association: 'users.roles' };
const schema = createTableBlockUISchema(options);
expect(schema).toMatchInlineSnapshot(`
@ -85,7 +85,6 @@ describe('createTableBLockSchemaV2', () => {
"params": {
"pageSize": 20,
},
"rowKey": "rowKey",
"showIndex": true,
},
"x-filter-targets": [],

View File

@ -13,10 +13,9 @@ import { uid } from '@formily/shared';
export const createTableBlockUISchema = (options: {
dataSource: string;
collectionName?: string;
rowKey?: string;
association?: string;
}): ISchema => {
const { collectionName, dataSource, rowKey, association } = options;
const { collectionName, dataSource, association } = options;
if (!dataSource) {
throw new Error('dataSource is required');
@ -35,7 +34,6 @@ export const createTableBlockUISchema = (options: {
params: {
pageSize: 20,
},
rowKey,
showIndex: true,
dragSort: false,
},

View File

@ -11,15 +11,19 @@ import { useFieldSchema } from '@formily/react';
import { useMemo } from 'react';
import { useParsedFilter } from '../../../../../block-provider/hooks/useParsedFilter';
import { useParentRecordCommon } from '../../../useParentRecordCommon';
import { useDataSourceManager } from '../../../../../data-source';
export const useTableBlockDecoratorProps = (props) => {
const { params, parseVariableLoading } = useTableBlockParams(props);
const parentRecord = useParentRecordCommon(props.association);
const dm = useDataSourceManager();
const collection = dm.getDataSource(props.dataSource)?.collectionManager.getCollection(props.collection);
return {
params,
parentRecord,
parseVariableLoading,
rowKey: collection?.filterTargetKey || 'id',
};
};

View File

@ -10,25 +10,9 @@
import { observer } from '@formily/react';
import classnames from 'classnames';
import React from 'react';
import { Space, Tooltip } from 'antd';
import { withDynamicSchemaProps } from '../../../hoc/withDynamicSchemaProps';
import Action from './Action';
import { ComposedAction } from './types';
import { Icon } from '../../../icon';
const WrapperComponent = React.forwardRef(
({ component: Component = 'a', icon, onlyIcon, children, ...restProps }: any, ref) => {
return (
<Component ref={ref} {...restProps}>
<Tooltip title={restProps.title}>
<span style={{ marginRight: 3 }}>{icon && typeof icon === 'string' ? <Icon type={icon} /> : icon}</span>
</Tooltip>
{onlyIcon ? children[1] : children}
</Component>
);
},
);
WrapperComponent.displayName = 'WrapperComponentLink';
export const ActionLink: ComposedAction = withDynamicSchemaProps(
observer((props: any) => {

View File

@ -357,7 +357,7 @@ function FinallyButton({
}}
style={{
...props?.style,
display: !designable && field?.data?.hidden && 'none',
display: !designable && field?.data?.hidden ? 'none' : 'inline-block',
opacity: designable && field?.data?.hidden && 0.1,
...buttonStyle,
}}

View File

@ -39,7 +39,6 @@ export const RecordAssociationBlockInitializer = () => {
} else {
insert(
createTableBlockUISchema({
rowKey: collection.filterTargetKey,
dataSource: collection.dataSource,
association: association,
}),
@ -62,7 +61,6 @@ export function useCreateAssociationTableBlock() {
insert(
createTableBlockUISchema({
rowKey: collection.filterTargetKey,
dataSource: collection.dataSource,
association: `${field.collectionName}.${field.name}`,
}),