mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-05 13:39:24 +08:00
fix: action modal icon and Initializer menu close when click (#4664)
* fix: action modal icon and Initializer menu close when click * fix: bug * fix: bug * feat: bug * fix: e2e bug
This commit is contained in:
parent
6c431caec4
commit
c66744d4a8
@ -16,6 +16,7 @@ import {
|
|||||||
} from '@nocobase/client';
|
} from '@nocobase/client';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { appOptions } from './schema-initializer-common';
|
import { appOptions } from './schema-initializer-common';
|
||||||
|
import { MenuOutlined } from '@ant-design/icons';
|
||||||
|
|
||||||
const myInitializer = new SchemaInitializer({
|
const myInitializer = new SchemaInitializer({
|
||||||
name: 'myInitializer',
|
name: 'myInitializer',
|
||||||
@ -31,6 +32,7 @@ const myInitializer = new SchemaInitializer({
|
|||||||
title="Add Card"
|
title="Add Card"
|
||||||
buttonText="Add Card"
|
buttonText="Add Card"
|
||||||
isItem
|
isItem
|
||||||
|
icon={<MenuOutlined />}
|
||||||
onSubmit={({ title }) => {
|
onSubmit={({ title }) => {
|
||||||
insert({
|
insert({
|
||||||
type: 'void',
|
type: 'void',
|
||||||
@ -52,6 +54,36 @@ const myInitializer = new SchemaInitializer({
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'b',
|
||||||
|
type: 'actionModal',
|
||||||
|
useComponentProps() {
|
||||||
|
const { insert } = useSchemaInitializer();
|
||||||
|
return {
|
||||||
|
isItem: true,
|
||||||
|
icon: <MenuOutlined />,
|
||||||
|
buttonText: 'Add Card 2',
|
||||||
|
title: 'Add Card Form 2',
|
||||||
|
schema: {
|
||||||
|
title: {
|
||||||
|
type: 'string',
|
||||||
|
title: 'Title',
|
||||||
|
required: true,
|
||||||
|
'x-component': 'Input',
|
||||||
|
'x-decorator': 'FormItem',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
onSubmit({ title }) {
|
||||||
|
insert({
|
||||||
|
type: 'void',
|
||||||
|
title,
|
||||||
|
'x-decorator': 'CardItem',
|
||||||
|
'x-component': 'Hello',
|
||||||
|
});
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ import {
|
|||||||
} from '@nocobase/client';
|
} from '@nocobase/client';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { appOptions } from './schema-initializer-common';
|
import { appOptions } from './schema-initializer-common';
|
||||||
|
import { MenuOutlined } from '@ant-design/icons';
|
||||||
|
|
||||||
const myInitializer = new SchemaInitializer({
|
const myInitializer = new SchemaInitializer({
|
||||||
name: 'myInitializer',
|
name: 'myInitializer',
|
||||||
@ -31,6 +32,7 @@ const myInitializer = new SchemaInitializer({
|
|||||||
title="Add Card"
|
title="Add Card"
|
||||||
buttonText="Add Card"
|
buttonText="Add Card"
|
||||||
isItem
|
isItem
|
||||||
|
icon={<MenuOutlined />}
|
||||||
onSubmit={({ title }) => {
|
onSubmit={({ title }) => {
|
||||||
insert({
|
insert({
|
||||||
type: 'void',
|
type: 'void',
|
||||||
@ -52,6 +54,36 @@ const myInitializer = new SchemaInitializer({
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'b',
|
||||||
|
type: 'actionModal',
|
||||||
|
useComponentProps() {
|
||||||
|
const { insert } = useSchemaInitializer();
|
||||||
|
return {
|
||||||
|
isItem: true,
|
||||||
|
icon: <MenuOutlined />,
|
||||||
|
buttonText: 'Add Card 2',
|
||||||
|
title: 'Add Card Form 2',
|
||||||
|
schema: {
|
||||||
|
title: {
|
||||||
|
type: 'string',
|
||||||
|
title: 'Title',
|
||||||
|
required: true,
|
||||||
|
'x-component': 'Input',
|
||||||
|
'x-decorator': 'FormItem',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
onSubmit({ title }) {
|
||||||
|
insert({
|
||||||
|
type: 'void',
|
||||||
|
title,
|
||||||
|
'x-decorator': 'CardItem',
|
||||||
|
'x-component': 'Hello',
|
||||||
|
});
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -12,9 +12,11 @@ import React, { FC, useCallback, useMemo } from 'react';
|
|||||||
import { useActionContext, SchemaComponent } from '../../../schema-component';
|
import { useActionContext, SchemaComponent } from '../../../schema-component';
|
||||||
import { useSchemaInitializerItem } from '../context';
|
import { useSchemaInitializerItem } from '../context';
|
||||||
import { SchemaInitializerItem } from './SchemaInitializerItem';
|
import { SchemaInitializerItem } from './SchemaInitializerItem';
|
||||||
|
import { uid } from '@formily/shared';
|
||||||
|
|
||||||
export interface SchemaInitializerActionModalProps {
|
export interface SchemaInitializerActionModalProps {
|
||||||
title: string;
|
title: string;
|
||||||
|
icon?: string | React.ReactNode;
|
||||||
schema: any;
|
schema: any;
|
||||||
onCancel?: () => void;
|
onCancel?: () => void;
|
||||||
onSubmit?: (values: any) => void;
|
onSubmit?: (values: any) => void;
|
||||||
@ -23,21 +25,13 @@ export interface SchemaInitializerActionModalProps {
|
|||||||
isItem?: boolean;
|
isItem?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const SchemaInitializerActionModalItemComponent = React.forwardRef((props: any, ref) => {
|
const SchemaInitializerActionModalItemComponent = React.forwardRef((props: any, ref: any) => {
|
||||||
const { onClick, title, ...others } = props;
|
const { onClick, ...others } = props;
|
||||||
return (
|
return <SchemaInitializerItem ref={ref} {...others} onClick={(e) => onClick?.(e.event, false)} />;
|
||||||
<SchemaInitializerItem
|
|
||||||
ref={ref}
|
|
||||||
{...others}
|
|
||||||
onClick={(e) => {
|
|
||||||
onClick?.(e.event);
|
|
||||||
}}
|
|
||||||
></SchemaInitializerItem>
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export const SchemaInitializerActionModal: FC<SchemaInitializerActionModalProps> = (props) => {
|
export const SchemaInitializerActionModal: FC<SchemaInitializerActionModalProps> = (props) => {
|
||||||
const { title, schema, buttonText, isItem, component, onCancel, onSubmit } = props;
|
const { title, icon, schema, buttonText, isItem, component, onCancel, onSubmit } = props;
|
||||||
const useCancelAction = useCallback(() => {
|
const useCancelAction = useCallback(() => {
|
||||||
// eslint-disable-next-line react-hooks/rules-of-hooks
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
||||||
const form = useForm();
|
const form = useForm();
|
||||||
@ -66,24 +60,35 @@ export const SchemaInitializerActionModal: FC<SchemaInitializerActionModalProps>
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
}, [onSubmit]);
|
}, [onSubmit]);
|
||||||
|
|
||||||
|
const ItemComponent = useMemo(
|
||||||
|
() =>
|
||||||
|
React.forwardRef(({ onClick }: any, ref) => {
|
||||||
|
return <SchemaInitializerActionModalItemComponent onClick={onClick} ref={ref} title={buttonText} icon={icon} />;
|
||||||
|
}),
|
||||||
|
[buttonText, icon],
|
||||||
|
);
|
||||||
|
|
||||||
|
const schemaId = useMemo(() => uid(), []);
|
||||||
|
|
||||||
const defaultSchema = useMemo(() => {
|
const defaultSchema = useMemo(() => {
|
||||||
return {
|
return {
|
||||||
type: 'void',
|
type: 'void',
|
||||||
properties: {
|
properties: {
|
||||||
action1: {
|
[schemaId]: {
|
||||||
type: 'void',
|
type: 'void',
|
||||||
'x-component': 'Action',
|
'x-component': 'Action',
|
||||||
'x-component-props': component
|
'x-component-props': component
|
||||||
? {
|
? {
|
||||||
component,
|
component,
|
||||||
|
icon,
|
||||||
}
|
}
|
||||||
: isItem
|
: isItem
|
||||||
? {
|
? {
|
||||||
title: buttonText,
|
component: ItemComponent,
|
||||||
component: SchemaInitializerActionModalItemComponent,
|
|
||||||
}
|
}
|
||||||
: {
|
: {
|
||||||
icon: 'PlusOutlined',
|
icon: icon || 'PlusOutlined',
|
||||||
style: {
|
style: {
|
||||||
borderColor: 'var(--colorSettings)',
|
borderColor: 'var(--colorSettings)',
|
||||||
color: 'var(--colorSettings)',
|
color: 'var(--colorSettings)',
|
||||||
@ -132,7 +137,7 @@ export const SchemaInitializerActionModal: FC<SchemaInitializerActionModalProps>
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}, [buttonText, component, schema, title, useCancelAction, useSubmitAction]);
|
}, [buttonText, component, schemaId, schema, title, useCancelAction, useSubmitAction]);
|
||||||
|
|
||||||
return <SchemaComponent schema={defaultSchema as any} />;
|
return <SchemaComponent schema={defaultSchema as any} />;
|
||||||
};
|
};
|
||||||
|
@ -12,7 +12,7 @@ import classNames from 'classnames';
|
|||||||
import React, { ReactNode, memo, useMemo } from 'react';
|
import React, { ReactNode, memo, useMemo } from 'react';
|
||||||
import { Icon } from '../../../icon';
|
import { Icon } from '../../../icon';
|
||||||
import { useCompile } from '../../../schema-component';
|
import { useCompile } from '../../../schema-component';
|
||||||
import { useSchemaInitializerItem } from '../context';
|
import { useSchemaInitializer, useSchemaInitializerItem } from '../context';
|
||||||
import { useAriaAttributeOfMenuItem, useSchemaInitializerMenuItems } from '../hooks';
|
import { useAriaAttributeOfMenuItem, useSchemaInitializerMenuItems } from '../hooks';
|
||||||
import { SchemaInitializerMenu } from './SchemaInitializerSubMenu';
|
import { SchemaInitializerMenu } from './SchemaInitializerSubMenu';
|
||||||
import { useSchemaInitializerStyles } from './style';
|
import { useSchemaInitializerStyles } from './style';
|
||||||
@ -27,16 +27,31 @@ export interface SchemaInitializerItemProps {
|
|||||||
onClick?: (args?: any) => any;
|
onClick?: (args?: any) => any;
|
||||||
applyMenuStyle?: boolean;
|
applyMenuStyle?: boolean;
|
||||||
children?: ReactNode;
|
children?: ReactNode;
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
closeInitializerMenuWhenClick?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const SchemaInitializerItem = memo(
|
export const SchemaInitializerItem = memo(
|
||||||
React.forwardRef<any, SchemaInitializerItemProps>((props, ref) => {
|
React.forwardRef<any, SchemaInitializerItemProps>((props, ref) => {
|
||||||
const { style, name = uid(), applyMenuStyle = true, className, items, icon, title, onClick, children } = props;
|
const {
|
||||||
|
style,
|
||||||
|
closeInitializerMenuWhenClick = true,
|
||||||
|
name = uid(),
|
||||||
|
applyMenuStyle = true,
|
||||||
|
className,
|
||||||
|
items,
|
||||||
|
icon,
|
||||||
|
title,
|
||||||
|
onClick,
|
||||||
|
children,
|
||||||
|
} = props;
|
||||||
const compile = useCompile();
|
const compile = useCompile();
|
||||||
const childrenItems = useSchemaInitializerMenuItems(items, name, onClick);
|
const childrenItems = useSchemaInitializerMenuItems(items, name, onClick);
|
||||||
const { componentCls, hashId } = useSchemaInitializerStyles();
|
const { componentCls, hashId } = useSchemaInitializerStyles();
|
||||||
const { attribute } = useAriaAttributeOfMenuItem();
|
const { attribute } = useAriaAttributeOfMenuItem();
|
||||||
|
const { setVisible } = useSchemaInitializer();
|
||||||
const menuItems = useMemo(() => {
|
const menuItems = useMemo(() => {
|
||||||
if (!(items && items.length > 0)) return undefined;
|
if (!(items && items.length > 0)) return undefined;
|
||||||
return [
|
return [
|
||||||
@ -47,6 +62,9 @@ export const SchemaInitializerItem = memo(
|
|||||||
label: children || compile(title),
|
label: children || compile(title),
|
||||||
onClick: (info) => {
|
onClick: (info) => {
|
||||||
if (info.key !== name) return;
|
if (info.key !== name) return;
|
||||||
|
if (closeInitializerMenuWhenClick) {
|
||||||
|
setVisible?.(false);
|
||||||
|
}
|
||||||
onClick?.({ ...info, item: props });
|
onClick?.({ ...info, item: props });
|
||||||
},
|
},
|
||||||
icon: typeof icon === 'string' ? <Icon type={icon as string} /> : icon,
|
icon: typeof icon === 'string' ? <Icon type={icon as string} /> : icon,
|
||||||
@ -58,12 +76,14 @@ export const SchemaInitializerItem = memo(
|
|||||||
if (items && items.length > 0) {
|
if (items && items.length > 0) {
|
||||||
return <SchemaInitializerMenu items={menuItems}></SchemaInitializerMenu>;
|
return <SchemaInitializerMenu items={menuItems}></SchemaInitializerMenu>;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
ref={ref}
|
ref={ref}
|
||||||
onClick={(event) => {
|
onClick={(event) => {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
if (closeInitializerMenuWhenClick) {
|
||||||
|
setVisible?.(false);
|
||||||
|
}
|
||||||
onClick?.({ event, item: props });
|
onClick?.({ event, item: props });
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
@ -74,8 +94,10 @@ export const SchemaInitializerItem = memo(
|
|||||||
>
|
>
|
||||||
{children || (
|
{children || (
|
||||||
<>
|
<>
|
||||||
{icon && typeof icon === 'string' ? <Icon type={icon as string} /> : icon}
|
{typeof icon === 'string' ? <Icon type={icon} /> : icon}
|
||||||
<span className={classNames({ [`${hashId} ${componentCls}-item-content`]: icon })}>{compile(title)}</span>
|
<span className={classNames({ [`${hashId} ${componentCls}-item-content`]: !!icon })}>
|
||||||
|
{compile(title)}
|
||||||
|
</span>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
@ -22,7 +22,7 @@ export const SchemaInitializerSwitch: FC<SchemaInitializerSwitchItemProps> = (pr
|
|||||||
const { title, checked, ...resets } = props;
|
const { title, checked, ...resets } = props;
|
||||||
const compile = useCompile();
|
const compile = useCompile();
|
||||||
return (
|
return (
|
||||||
<SchemaInitializerItem {...resets}>
|
<SchemaInitializerItem {...resets} closeInitializerMenuWhenClick={false}>
|
||||||
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
|
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
|
||||||
{compile(title)} <Switch style={{ marginLeft: 20 }} size={'small'} checked={checked} />
|
{compile(title)} <Switch style={{ marginLeft: 20 }} size={'small'} checked={checked} />
|
||||||
</div>
|
</div>
|
||||||
|
@ -32,7 +32,7 @@ type SchemaInitializerItemBuiltInType<T = {}> = T & {
|
|||||||
|
|
||||||
export interface SchemaInitializerItemComponentType<T = {}> {
|
export interface SchemaInitializerItemComponentType<T = {}> {
|
||||||
name: string;
|
name: string;
|
||||||
Component: ComponentType<T> | string;
|
Component?: ComponentType<T> | string;
|
||||||
sort?: number;
|
sort?: number;
|
||||||
componentProps?: Omit<T, 'children'>;
|
componentProps?: Omit<T, 'children'>;
|
||||||
useComponentProps?: () => Omit<T, 'children'>;
|
useComponentProps?: () => Omit<T, 'children'>;
|
||||||
|
@ -114,6 +114,7 @@ test.describe('configure actions', () => {
|
|||||||
|
|
||||||
await page.getByLabel('schema-initializer-ActionBar-detailsWithPaging:configureActions-general').hover();
|
await page.getByLabel('schema-initializer-ActionBar-detailsWithPaging:configureActions-general').hover();
|
||||||
await page.getByRole('menuitem', { name: 'Edit' }).click();
|
await page.getByRole('menuitem', { name: 'Edit' }).click();
|
||||||
|
await page.getByLabel('schema-initializer-ActionBar-detailsWithPaging:configureActions-general').hover();
|
||||||
await page.getByRole('menuitem', { name: 'Delete' }).click();
|
await page.getByRole('menuitem', { name: 'Delete' }).click();
|
||||||
|
|
||||||
await page.mouse.move(300, 0);
|
await page.mouse.move(300, 0);
|
||||||
|
@ -68,6 +68,7 @@ test.describe('actions schema settings', () => {
|
|||||||
// 创建 Edit & Delete 两个按钮
|
// 创建 Edit & Delete 两个按钮
|
||||||
await page.getByLabel('schema-initializer-ActionBar-detailsWithPaging:configureActions-general').hover();
|
await page.getByLabel('schema-initializer-ActionBar-detailsWithPaging:configureActions-general').hover();
|
||||||
await page.getByRole('menuitem', { name: 'Edit' }).click();
|
await page.getByRole('menuitem', { name: 'Edit' }).click();
|
||||||
|
await page.getByLabel('schema-initializer-ActionBar-detailsWithPaging:configureActions-general').hover();
|
||||||
await page.getByRole('menuitem', { name: 'Delete' }).click();
|
await page.getByRole('menuitem', { name: 'Delete' }).click();
|
||||||
await page.mouse.move(0, 300);
|
await page.mouse.move(0, 300);
|
||||||
|
|
||||||
|
@ -67,7 +67,9 @@ test.describe('configure global actions', () => {
|
|||||||
|
|
||||||
await page.getByLabel('schema-initializer-ActionBar-gridCard:configureActions-general').hover();
|
await page.getByLabel('schema-initializer-ActionBar-gridCard:configureActions-general').hover();
|
||||||
await page.getByRole('menuitem', { name: 'Filter' }).click();
|
await page.getByRole('menuitem', { name: 'Filter' }).click();
|
||||||
|
await page.getByLabel('schema-initializer-ActionBar-gridCard:configureActions-general').hover();
|
||||||
await page.getByRole('menuitem', { name: 'Add new' }).click();
|
await page.getByRole('menuitem', { name: 'Add new' }).click();
|
||||||
|
await page.getByLabel('schema-initializer-ActionBar-gridCard:configureActions-general').hover();
|
||||||
await page.getByRole('menuitem', { name: 'Refresh' }).click();
|
await page.getByRole('menuitem', { name: 'Refresh' }).click();
|
||||||
|
|
||||||
await page.mouse.move(300, 0);
|
await page.mouse.move(300, 0);
|
||||||
@ -95,7 +97,9 @@ test.describe('configure item actions', () => {
|
|||||||
|
|
||||||
await page.getByLabel('schema-initializer-ActionBar-gridCard:configureItemActions-general').first().hover();
|
await page.getByLabel('schema-initializer-ActionBar-gridCard:configureItemActions-general').first().hover();
|
||||||
await page.getByRole('menuitem', { name: 'View' }).click();
|
await page.getByRole('menuitem', { name: 'View' }).click();
|
||||||
|
await page.getByLabel('schema-initializer-ActionBar-gridCard:configureItemActions-general').first().hover();
|
||||||
await page.getByRole('menuitem', { name: 'Edit' }).click();
|
await page.getByRole('menuitem', { name: 'Edit' }).click();
|
||||||
|
await page.getByLabel('schema-initializer-ActionBar-gridCard:configureItemActions-general').first().hover();
|
||||||
await page.getByRole('menuitem', { name: 'Delete' }).click();
|
await page.getByRole('menuitem', { name: 'Delete' }).click();
|
||||||
|
|
||||||
await page.mouse.move(300, 0);
|
await page.mouse.move(300, 0);
|
||||||
@ -121,6 +125,7 @@ test.describe('configure item actions', () => {
|
|||||||
|
|
||||||
await page.getByLabel('schema-initializer-ActionBar-gridCard:configureItemActions-general').first().hover();
|
await page.getByLabel('schema-initializer-ActionBar-gridCard:configureItemActions-general').first().hover();
|
||||||
await page.getByRole('menuitem', { name: 'Popup' }).click();
|
await page.getByRole('menuitem', { name: 'Popup' }).click();
|
||||||
|
await page.getByLabel('schema-initializer-ActionBar-gridCard:configureItemActions-general').first().hover();
|
||||||
await page.getByRole('menuitem', { name: 'Update record' }).click();
|
await page.getByRole('menuitem', { name: 'Update record' }).click();
|
||||||
|
|
||||||
await page.mouse.move(300, 0);
|
await page.mouse.move(300, 0);
|
||||||
|
@ -64,7 +64,9 @@ test.describe('configure global actions', () => {
|
|||||||
|
|
||||||
await page.getByLabel('schema-initializer-ActionBar-list:configureActions-general').hover();
|
await page.getByLabel('schema-initializer-ActionBar-list:configureActions-general').hover();
|
||||||
await page.getByRole('menuitem', { name: 'Filter' }).click();
|
await page.getByRole('menuitem', { name: 'Filter' }).click();
|
||||||
|
await page.getByLabel('schema-initializer-ActionBar-list:configureActions-general').hover();
|
||||||
await page.getByRole('menuitem', { name: 'Add new' }).click();
|
await page.getByRole('menuitem', { name: 'Add new' }).click();
|
||||||
|
await page.getByLabel('schema-initializer-ActionBar-list:configureActions-general').hover();
|
||||||
await page.getByRole('menuitem', { name: 'Refresh' }).click();
|
await page.getByRole('menuitem', { name: 'Refresh' }).click();
|
||||||
|
|
||||||
await page.mouse.move(300, 0);
|
await page.mouse.move(300, 0);
|
||||||
@ -92,7 +94,9 @@ test.describe('configure item actions', () => {
|
|||||||
|
|
||||||
await page.getByLabel('schema-initializer-ActionBar-list:configureItemActions-general').first().hover();
|
await page.getByLabel('schema-initializer-ActionBar-list:configureItemActions-general').first().hover();
|
||||||
await page.getByRole('menuitem', { name: 'View' }).click();
|
await page.getByRole('menuitem', { name: 'View' }).click();
|
||||||
|
await page.getByLabel('schema-initializer-ActionBar-list:configureItemActions-general').first().hover();
|
||||||
await page.getByRole('menuitem', { name: 'Edit' }).click();
|
await page.getByRole('menuitem', { name: 'Edit' }).click();
|
||||||
|
await page.getByLabel('schema-initializer-ActionBar-list:configureItemActions-general').first().hover();
|
||||||
await page.getByRole('menuitem', { name: 'Delete' }).click();
|
await page.getByRole('menuitem', { name: 'Delete' }).click();
|
||||||
|
|
||||||
await page.mouse.move(300, 0);
|
await page.mouse.move(300, 0);
|
||||||
@ -118,6 +122,7 @@ test.describe('configure item actions', () => {
|
|||||||
|
|
||||||
await page.getByLabel('schema-initializer-ActionBar-list:configureItemActions-general').first().hover();
|
await page.getByLabel('schema-initializer-ActionBar-list:configureItemActions-general').first().hover();
|
||||||
await page.getByRole('menuitem', { name: 'Popup' }).click();
|
await page.getByRole('menuitem', { name: 'Popup' }).click();
|
||||||
|
await page.getByLabel('schema-initializer-ActionBar-list:configureItemActions-general').first().hover();
|
||||||
await page.getByRole('menuitem', { name: 'Update record' }).click();
|
await page.getByRole('menuitem', { name: 'Update record' }).click();
|
||||||
|
|
||||||
await page.mouse.move(300, 0);
|
await page.mouse.move(300, 0);
|
||||||
|
@ -38,8 +38,11 @@ test.describe('configure actions', () => {
|
|||||||
// add buttons
|
// add buttons
|
||||||
await page.getByLabel('schema-initializer-ActionBar-table:configureActions-users').hover();
|
await page.getByLabel('schema-initializer-ActionBar-table:configureActions-users').hover();
|
||||||
await page.getByRole('menuitem', { name: 'Filter' }).click();
|
await page.getByRole('menuitem', { name: 'Filter' }).click();
|
||||||
|
await page.getByLabel('schema-initializer-ActionBar-table:configureActions-users').hover();
|
||||||
await page.getByRole('menuitem', { name: 'Add new' }).click();
|
await page.getByRole('menuitem', { name: 'Add new' }).click();
|
||||||
|
await page.getByLabel('schema-initializer-ActionBar-table:configureActions-users').hover();
|
||||||
await page.getByRole('menuitem', { name: 'Delete' }).click();
|
await page.getByRole('menuitem', { name: 'Delete' }).click();
|
||||||
|
await page.getByLabel('schema-initializer-ActionBar-table:configureActions-users').hover();
|
||||||
await page.getByRole('menuitem', { name: 'Refresh' }).click();
|
await page.getByRole('menuitem', { name: 'Refresh' }).click();
|
||||||
|
|
||||||
await page.mouse.move(300, 0);
|
await page.mouse.move(300, 0);
|
||||||
|
@ -32,12 +32,10 @@ export const Resizable = () => {
|
|||||||
title={t('Column width')}
|
title={t('Column width')}
|
||||||
component={React.forwardRef<any, any>((props, ref) => {
|
component={React.forwardRef<any, any>((props, ref) => {
|
||||||
const { children, onClick, ...others } = props;
|
const { children, onClick, ...others } = props;
|
||||||
const { setVisible } = useSchemaInitializer();
|
|
||||||
return (
|
return (
|
||||||
<SchemaInitializerItem
|
<SchemaInitializerItem
|
||||||
ref={ref}
|
ref={ref}
|
||||||
onClick={({ event }) => {
|
onClick={({ event }) => {
|
||||||
setVisible(false);
|
|
||||||
onClick(event);
|
onClick(event);
|
||||||
}}
|
}}
|
||||||
{...others}
|
{...others}
|
||||||
|
@ -138,7 +138,13 @@ test.describe('configure actions column', () => {
|
|||||||
await page.getByText('Actions', { exact: true }).hover();
|
await page.getByText('Actions', { exact: true }).hover();
|
||||||
await page.getByLabel('designer-schema-initializer-TableV2.Column-TableV2.ActionColumnDesigner-').hover();
|
await page.getByLabel('designer-schema-initializer-TableV2.Column-TableV2.ActionColumnDesigner-').hover();
|
||||||
await page.getByRole('menuitem', { name: 'View' }).click();
|
await page.getByRole('menuitem', { name: 'View' }).click();
|
||||||
|
|
||||||
|
await page.getByText('Actions', { exact: true }).hover();
|
||||||
|
await page.getByLabel('designer-schema-initializer-TableV2.Column-TableV2.ActionColumnDesigner-').hover();
|
||||||
await page.getByRole('menuitem', { name: 'Edit' }).click();
|
await page.getByRole('menuitem', { name: 'Edit' }).click();
|
||||||
|
|
||||||
|
await page.getByText('Actions', { exact: true }).hover();
|
||||||
|
await page.getByLabel('designer-schema-initializer-TableV2.Column-TableV2.ActionColumnDesigner-').hover();
|
||||||
await page.getByRole('menuitem', { name: 'Delete' }).click();
|
await page.getByRole('menuitem', { name: 'Delete' }).click();
|
||||||
await page.getByRole('menuitem', { name: 'Duplicate' }).click();
|
await page.getByRole('menuitem', { name: 'Duplicate' }).click();
|
||||||
|
|
||||||
@ -163,9 +169,10 @@ test.describe('configure actions column', () => {
|
|||||||
// add custom action ------------------------------------------------------------
|
// add custom action ------------------------------------------------------------
|
||||||
await page.getByText('Actions', { exact: true }).hover();
|
await page.getByText('Actions', { exact: true }).hover();
|
||||||
await page.getByLabel('designer-schema-initializer-TableV2.Column-TableV2.ActionColumnDesigner-').hover();
|
await page.getByLabel('designer-schema-initializer-TableV2.Column-TableV2.ActionColumnDesigner-').hover();
|
||||||
|
|
||||||
await page.getByRole('menuitem', { name: 'Popup' }).click();
|
await page.getByRole('menuitem', { name: 'Popup' }).click();
|
||||||
// 此时二级菜单,不应该关闭,可以继续点击?
|
|
||||||
|
await page.getByText('Actions', { exact: true }).hover();
|
||||||
|
await page.getByLabel('designer-schema-initializer-TableV2.Column-TableV2.ActionColumnDesigner-').hover();
|
||||||
await page.getByRole('menuitem', { name: 'Update record' }).click();
|
await page.getByRole('menuitem', { name: 'Update record' }).click();
|
||||||
|
|
||||||
await page.mouse.move(300, 0);
|
await page.mouse.move(300, 0);
|
||||||
|
@ -119,8 +119,11 @@ test.describe('configure actions', () => {
|
|||||||
// add buttons
|
// add buttons
|
||||||
await page.getByLabel('schema-initializer-ActionBar-table:configureActions-t_unp4scqamw9').hover();
|
await page.getByLabel('schema-initializer-ActionBar-table:configureActions-t_unp4scqamw9').hover();
|
||||||
await page.getByRole('menuitem', { name: 'Filter' }).click();
|
await page.getByRole('menuitem', { name: 'Filter' }).click();
|
||||||
|
await page.getByLabel('schema-initializer-ActionBar-table:configureActions-t_unp4scqamw9').hover();
|
||||||
await page.getByRole('menuitem', { name: 'Add new' }).click();
|
await page.getByRole('menuitem', { name: 'Add new' }).click();
|
||||||
|
await page.getByLabel('schema-initializer-ActionBar-table:configureActions-t_unp4scqamw9').hover();
|
||||||
await page.getByRole('menuitem', { name: 'Delete' }).click();
|
await page.getByRole('menuitem', { name: 'Delete' }).click();
|
||||||
|
await page.getByLabel('schema-initializer-ActionBar-table:configureActions-t_unp4scqamw9').hover();
|
||||||
await page.getByRole('menuitem', { name: 'Refresh' }).click();
|
await page.getByRole('menuitem', { name: 'Refresh' }).click();
|
||||||
|
|
||||||
await page.mouse.move(300, 0);
|
await page.mouse.move(300, 0);
|
||||||
|
@ -37,6 +37,9 @@ const addSomeCustomActions = async (page: Page) => {
|
|||||||
await page.getByRole('button', { name: 'Actions', exact: true }).hover();
|
await page.getByRole('button', { name: 'Actions', exact: true }).hover();
|
||||||
await page.getByLabel('designer-schema-initializer-TableV2.Column-TableV2.ActionColumnDesigner-general').hover();
|
await page.getByLabel('designer-schema-initializer-TableV2.Column-TableV2.ActionColumnDesigner-general').hover();
|
||||||
await page.getByRole('menuitem', { name: 'Popup' }).click();
|
await page.getByRole('menuitem', { name: 'Popup' }).click();
|
||||||
|
|
||||||
|
await page.getByRole('button', { name: 'Actions', exact: true }).hover();
|
||||||
|
await page.getByLabel('designer-schema-initializer-TableV2.Column-TableV2.ActionColumnDesigner-general').hover();
|
||||||
await page.getByRole('menuitem', { name: 'Update record' }).click();
|
await page.getByRole('menuitem', { name: 'Update record' }).click();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@ test.describe('where to open a popup and what can be added to it', () => {
|
|||||||
// add blocks
|
// add blocks
|
||||||
await page.getByLabel('schema-initializer-Grid-popup:addNew:addBlock-general').hover();
|
await page.getByLabel('schema-initializer-Grid-popup:addNew:addBlock-general').hover();
|
||||||
await page.getByText('Markdown').click();
|
await page.getByText('Markdown').click();
|
||||||
|
await page.getByLabel('schema-initializer-Grid-popup:addNew:addBlock-general').hover();
|
||||||
await page.getByText('Form').hover();
|
await page.getByText('Form').hover();
|
||||||
await page.getByRole('menuitem', { name: 'Current collection' }).click();
|
await page.getByRole('menuitem', { name: 'Current collection' }).click();
|
||||||
|
|
||||||
@ -146,6 +147,7 @@ test.describe('where to open a popup and what can be added to it', () => {
|
|||||||
// add blocks
|
// add blocks
|
||||||
await page.getByLabel('schema-initializer-Grid-popup:bulkEdit:addBlock-general').hover();
|
await page.getByLabel('schema-initializer-Grid-popup:bulkEdit:addBlock-general').hover();
|
||||||
await page.getByText('Form').click();
|
await page.getByText('Form').click();
|
||||||
|
await page.getByLabel('schema-initializer-Grid-popup:bulkEdit:addBlock-general').hover();
|
||||||
await page.getByRole('menuitem', { name: 'Markdown' }).click();
|
await page.getByRole('menuitem', { name: 'Markdown' }).click();
|
||||||
await page.mouse.move(300, 0);
|
await page.mouse.move(300, 0);
|
||||||
|
|
||||||
|
@ -127,8 +127,8 @@ export const Action: ComposedAction = withDynamicSchemaProps(
|
|||||||
}, [field, linkageRules, localVariables, variables]);
|
}, [field, linkageRules, localVariables, variables]);
|
||||||
|
|
||||||
const handleButtonClick = useCallback(
|
const handleButtonClick = useCallback(
|
||||||
(e: React.MouseEvent) => {
|
(e: React.MouseEvent, checkPortal = true) => {
|
||||||
if (isPortalInBody(e.target as Element)) {
|
if (checkPortal && isPortalInBody(e.target as Element)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
@ -186,7 +186,7 @@ export const Action: ComposedAction = withDynamicSchemaProps(
|
|||||||
{...others}
|
{...others}
|
||||||
onMouseEnter={handleMouseEnter}
|
onMouseEnter={handleMouseEnter}
|
||||||
loading={field?.data?.loading || loading}
|
loading={field?.data?.loading || loading}
|
||||||
icon={icon ? <Icon type={icon} /> : null}
|
icon={typeof icon === 'string' ? <Icon type={icon} /> : icon}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
style={buttonStyle}
|
style={buttonStyle}
|
||||||
onClick={handleButtonClick}
|
onClick={handleButtonClick}
|
||||||
|
@ -348,9 +348,10 @@ export const DataBlockInitializer: FC<DataBlockInitializerProps> = (props) => {
|
|||||||
onCreateBlockSchema({ item, fromOthersInPopup });
|
onCreateBlockSchema({ item, fromOthersInPopup });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setVisible(false);
|
setVisible(false);
|
||||||
},
|
},
|
||||||
[getTemplateSchemaByMode, insert, onCreateBlockSchema, propsOnClick, setVisible, templateWrap],
|
[getTemplateSchemaByMode, insert, setVisible, onCreateBlockSchema, propsOnClick, templateWrap],
|
||||||
);
|
);
|
||||||
const items =
|
const items =
|
||||||
itemsFromProps ||
|
itemsFromProps ||
|
||||||
|
@ -65,7 +65,7 @@ export const CalendarFormActionInitializers = new SchemaInitializer({
|
|||||||
'x-component': 'Action',
|
'x-component': 'Action',
|
||||||
'x-decorator': 'ACLActionProvider',
|
'x-decorator': 'ACLActionProvider',
|
||||||
},
|
},
|
||||||
visible: function useVisible() {
|
useVisible: function useVisible() {
|
||||||
const collection = useCollection_deprecated();
|
const collection = useCollection_deprecated();
|
||||||
return (collection.template !== 'view' || collection?.writableView) && collection.template !== 'sql';
|
return (collection.template !== 'view' || collection?.writableView) && collection.template !== 'sql';
|
||||||
},
|
},
|
||||||
|
@ -86,10 +86,15 @@ test.describe('configure actions', () => {
|
|||||||
await mockPage(oneEmptyGantt).goto();
|
await mockPage(oneEmptyGantt).goto();
|
||||||
await page.getByLabel('schema-initializer-ActionBar-gantt:configureActions-general').hover();
|
await page.getByLabel('schema-initializer-ActionBar-gantt:configureActions-general').hover();
|
||||||
await page.getByRole('menuitem', { name: 'Filter' }).click();
|
await page.getByRole('menuitem', { name: 'Filter' }).click();
|
||||||
|
await page.getByLabel('schema-initializer-ActionBar-gantt:configureActions-general').hover();
|
||||||
await page.getByRole('menuitem', { name: 'Add new' }).click();
|
await page.getByRole('menuitem', { name: 'Add new' }).click();
|
||||||
|
await page.getByLabel('schema-initializer-ActionBar-gantt:configureActions-general').hover();
|
||||||
await page.getByRole('menuitem', { name: 'Delete' }).click();
|
await page.getByRole('menuitem', { name: 'Delete' }).click();
|
||||||
|
await page.getByLabel('schema-initializer-ActionBar-gantt:configureActions-general').hover();
|
||||||
await page.getByRole('menuitem', { name: 'Refresh' }).click();
|
await page.getByRole('menuitem', { name: 'Refresh' }).click();
|
||||||
|
await page.getByLabel('schema-initializer-ActionBar-gantt:configureActions-general').hover();
|
||||||
await page.getByRole('menuitem', { name: 'Bulk update' }).click();
|
await page.getByRole('menuitem', { name: 'Bulk update' }).click();
|
||||||
|
await page.getByLabel('schema-initializer-ActionBar-gantt:configureActions-general').hover();
|
||||||
await page.getByRole('menuitem', { name: 'Bulk edit' }).click();
|
await page.getByRole('menuitem', { name: 'Bulk edit' }).click();
|
||||||
await expect(page.getByLabel('action-Filter.Action-Filter-filter-general-table')).toBeVisible();
|
await expect(page.getByLabel('action-Filter.Action-Filter-filter-general-table')).toBeVisible();
|
||||||
await expect(page.getByLabel('action-Action-Add new-create-general-table')).toBeVisible();
|
await expect(page.getByLabel('action-Action-Add new-create-general-table')).toBeVisible();
|
||||||
|
@ -382,7 +382,7 @@ export const addCustomFormField = new CompatibleSchemaInitializer(
|
|||||||
|
|
||||||
function CustomFormFieldInitializer() {
|
function CustomFormFieldInitializer() {
|
||||||
const itemConfig = useSchemaInitializerItem();
|
const itemConfig = useSchemaInitializerItem();
|
||||||
const { insert, setVisible } = useSchemaInitializer();
|
const { insert } = useSchemaInitializer();
|
||||||
const { onAddField, setCallback } = useContext(AddCustomFormFieldButtonContext);
|
const { onAddField, setCallback } = useContext(AddCustomFormFieldButtonContext);
|
||||||
const { getInterface } = useCollectionManager_deprecated();
|
const { getInterface } = useCollectionManager_deprecated();
|
||||||
|
|
||||||
@ -394,7 +394,6 @@ function CustomFormFieldInitializer() {
|
|||||||
onClick={() => {
|
onClick={() => {
|
||||||
setCallback(() => insert);
|
setCallback(() => insert);
|
||||||
onAddField(interfaceOptions);
|
onAddField(interfaceOptions);
|
||||||
setVisible(false);
|
|
||||||
}}
|
}}
|
||||||
{...itemConfig}
|
{...itemConfig}
|
||||||
/>
|
/>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user