Merge branch 'next' into develop

This commit is contained in:
nocobase[bot] 2025-04-25 07:05:49 +00:00
commit 3e78a9f063
2 changed files with 26 additions and 20 deletions

View File

@ -42,31 +42,35 @@ const useStyles = createStyles(({ token, css }) => ({
`, `,
})); }));
function Button() { function Button({ onlyIcon }) {
const fieldSchema = useFieldSchema(); const fieldSchema = useFieldSchema();
const icon = fieldSchema['x-component-props']?.['icon']; const { icon, iconColor: backgroundColor } = fieldSchema['x-component-props'] || {};
const backgroundColor = fieldSchema['x-component-props']?.['iconColor'];
const { layout, ellipsis = true } = useContext(WorkbenchBlockContext); const { layout, ellipsis = true } = useContext(WorkbenchBlockContext);
const { styles, cx } = useStyles(); const { styles, cx } = useStyles();
const { t } = useTranslation(); const { t } = useTranslation();
const title = t(fieldSchema.title, { ns: NAMESPACE_UI_SCHEMA }); const title = t(fieldSchema.title, { ns: NAMESPACE_UI_SCHEMA });
return layout === WorkbenchLayout.Grid ? (
<div title={title} className={cx(styles.avatar)}> const shouldShowTitle = !onlyIcon;
<Avatar style={{ backgroundColor }} size={48} icon={<Icon type={icon} />} />
<div if (layout === WorkbenchLayout.Grid) {
className={cx(styles.title)} return (
style={{ <div title={title} className={cx(styles.avatar)}>
whiteSpace: ellipsis ? 'nowrap' : 'normal', <Avatar style={{ backgroundColor }} size={48} icon={<Icon type={icon} />} />
textOverflow: ellipsis ? 'ellipsis' : 'clip', <div
overflow: ellipsis ? 'hidden' : 'visible', className={cx(styles.title)}
}} style={{
> whiteSpace: ellipsis ? 'nowrap' : 'normal',
{title} textOverflow: ellipsis ? 'ellipsis' : 'clip',
overflow: ellipsis ? 'hidden' : 'visible',
}}
>
{shouldShowTitle && title}
</div>
</div> </div>
</div> );
) : ( }
<span>{title}</span>
); return <span>{shouldShowTitle && title}</span>;
} }
export const WorkbenchAction = withDynamicSchemaProps((props) => { export const WorkbenchAction = withDynamicSchemaProps((props) => {
@ -79,9 +83,10 @@ export const WorkbenchAction = withDynamicSchemaProps((props) => {
<Component <Component
className={cx(className, styles.action, 'nb-action-panel')} className={cx(className, styles.action, 'nb-action-panel')}
{...others} {...others}
onlyIcon={false}
type="text" type="text"
icon={null} icon={null}
title={<Button />} title={<Button onlyIcon={others?.onlyIcon} />}
confirmTitle={fieldSchema.title} confirmTitle={fieldSchema.title}
style={{ display: 'flex', alignItems: 'center', justifyContent: 'center' }} style={{ display: 'flex', alignItems: 'center', justifyContent: 'center' }}
/> />

View File

@ -85,6 +85,7 @@ const InternalIcons = () => {
key={key} key={key}
prefix={<Avatar style={{ backgroundColor }} icon={<Icon type={icon} />} />} prefix={<Avatar style={{ backgroundColor }} icon={<Icon type={icon} />} />}
onClick={() => {}} onClick={() => {}}
style={{ marginTop: '5px' }}
> >
<NocoBaseRecursionField name={key} schema={s} /> <NocoBaseRecursionField name={key} schema={s} />
</List.Item> </List.Item>