@@ -7,6 +7,8 @@ import { trans } from "i18n";
77import { useStyle } from "comps/controls/styleControl" ;
88import { ButtonStyle } from "comps/controls/styleControlConstants" ;
99import { Button100 } from "comps/comps/buttonComp/buttonCompConstants" ;
10+ import { IconControl } from "comps/controls/iconControl" ;
11+ import { hasIcon } from "comps/utils" ;
1012
1113export const ColumnValueTooltip = trans ( "table.columnValueTooltip" ) ;
1214
@@ -20,24 +22,44 @@ export const ButtonTypeOptions = [
2022 value : "default" ,
2123 } ,
2224 {
23- label : trans ( "text" ) ,
25+ label : trans ( "table. text" ) ,
2426 value : "text" ,
2527 } ,
2628] as const ;
2729
30+ export const ButtonDisplayOptions = [
31+ {
32+ label : trans ( "table.text" ) ,
33+ value : "text" ,
34+ } ,
35+ {
36+ label : trans ( "table.icon" ) ,
37+ value : "icon" ,
38+ } ,
39+ {
40+ label : trans ( "table.textAndIcon" ) ,
41+ value : "textAndIcon" ,
42+ } ,
43+ ] as const ;
44+
2845export const ButtonComp = ( function ( ) {
2946 const childrenMap = {
3047 text : StringControl ,
3148 buttonType : dropdownControl ( ButtonTypeOptions , "primary" ) ,
3249 onClick : ActionSelectorControlInContext ,
3350 loading : BoolCodeControl ,
3451 disabled : BoolCodeControl ,
52+ displayMode : dropdownControl ( ButtonDisplayOptions , "text" ) ,
53+ icon : IconControl ,
3554 } ;
3655 return new ColumnTypeCompBuilder (
3756 childrenMap ,
3857 ( props ) => {
3958 const ButtonStyled = ( ) => {
4059 const style = useStyle ( ButtonStyle ) ;
60+ const showIcon = props . displayMode === "icon" || props . displayMode === "textAndIcon" ;
61+ const showText = props . displayMode === "text" || props . displayMode === "textAndIcon" ;
62+
4163 return (
4264 < Button100
4365 type = { props . buttonType }
@@ -46,9 +68,10 @@ export const ButtonComp = (function () {
4668 disabled = { props . disabled }
4769 $buttonStyle = { props . buttonType === "primary" ? style : undefined }
4870 style = { { margin : 0 } }
71+ icon = { showIcon && hasIcon ( props . icon ) ? props . icon : undefined }
4972 >
5073 { /* prevent the button from disappearing */ }
51- { ! props . text ? " " : props . text }
74+ { showText ? ( ! props . text ? " " : props . text ) : null }
5275 </ Button100 >
5376 ) ;
5477 } ;
@@ -58,10 +81,21 @@ export const ButtonComp = (function () {
5881 )
5982 . setPropertyViewFn ( ( children ) => (
6083 < >
61- { children . text . propertyView ( {
62- label : trans ( "table.columnValue " ) ,
63- tooltip : ColumnValueTooltip ,
84+ { children . displayMode . propertyView ( {
85+ label : trans ( "table.displayMode " ) ,
86+ radioButton : true ,
6487 } ) }
88+ { ( children . displayMode . getView ( ) === "text" || children . displayMode . getView ( ) === "textAndIcon" ) &&
89+ children . text . propertyView ( {
90+ label : trans ( "table.columnValue" ) ,
91+ tooltip : ColumnValueTooltip ,
92+ } )
93+ }
94+ { ( children . displayMode . getView ( ) === "icon" || children . displayMode . getView ( ) === "textAndIcon" ) &&
95+ children . icon . propertyView ( {
96+ label : trans ( "table.icon" ) ,
97+ } )
98+ }
6599 { children . buttonType . propertyView ( {
66100 label : trans ( "table.type" ) ,
67101 radioButton : true ,
0 commit comments