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,15 +42,18 @@ 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 ? (
const shouldShowTitle = !onlyIcon;
if (layout === WorkbenchLayout.Grid) {
return (
<div title={title} className={cx(styles.avatar)}> <div title={title} className={cx(styles.avatar)}>
<Avatar style={{ backgroundColor }} size={48} icon={<Icon type={icon} />} /> <Avatar style={{ backgroundColor }} size={48} icon={<Icon type={icon} />} />
<div <div
@ -61,14 +64,15 @@ function Button() {
overflow: ellipsis ? 'hidden' : 'visible', overflow: ellipsis ? 'hidden' : 'visible',
}} }}
> >
{title} {shouldShowTitle && title}
</div> </div>
</div> </div>
) : (
<span>{title}</span>
); );
} }
return <span>{shouldShowTitle && title}</span>;
}
export const WorkbenchAction = withDynamicSchemaProps((props) => { export const WorkbenchAction = withDynamicSchemaProps((props) => {
const { className, ...others } = props; const { className, ...others } = props;
const { styles, cx } = useStyles() as any; const { styles, cx } = useStyles() as any;
@ -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>