diff --git a/packages/plugins/@nocobase/plugin-block-workbench/src/client/WorkbenchAction.tsx b/packages/plugins/@nocobase/plugin-block-workbench/src/client/WorkbenchAction.tsx index 56814c760d..65179849a1 100644 --- a/packages/plugins/@nocobase/plugin-block-workbench/src/client/WorkbenchAction.tsx +++ b/packages/plugins/@nocobase/plugin-block-workbench/src/client/WorkbenchAction.tsx @@ -42,31 +42,35 @@ const useStyles = createStyles(({ token, css }) => ({ `, })); -function Button() { +function Button({ onlyIcon }) { const fieldSchema = useFieldSchema(); - const icon = fieldSchema['x-component-props']?.['icon']; - const backgroundColor = fieldSchema['x-component-props']?.['iconColor']; + const { icon, iconColor: backgroundColor } = fieldSchema['x-component-props'] || {}; const { layout, ellipsis = true } = useContext(WorkbenchBlockContext); const { styles, cx } = useStyles(); const { t } = useTranslation(); const title = t(fieldSchema.title, { ns: NAMESPACE_UI_SCHEMA }); - return layout === WorkbenchLayout.Grid ? ( -
- } /> -
- {title} + + const shouldShowTitle = !onlyIcon; + + if (layout === WorkbenchLayout.Grid) { + return ( +
+ } /> +
+ {shouldShowTitle && title} +
-
- ) : ( - {title} - ); + ); + } + + return {shouldShowTitle && title}; } export const WorkbenchAction = withDynamicSchemaProps((props) => { @@ -79,9 +83,10 @@ export const WorkbenchAction = withDynamicSchemaProps((props) => { } + title={