@@ -7,6 +7,8 @@ import { trans } from "i18n";
7
7
import { useStyle } from "comps/controls/styleControl" ;
8
8
import { ButtonStyle } from "comps/controls/styleControlConstants" ;
9
9
import { Button100 } from "comps/comps/buttonComp/buttonCompConstants" ;
10
+ import { IconControl } from "comps/controls/iconControl" ;
11
+ import { hasIcon } from "comps/utils" ;
10
12
11
13
export const ColumnValueTooltip = trans ( "table.columnValueTooltip" ) ;
12
14
@@ -20,24 +22,44 @@ export const ButtonTypeOptions = [
20
22
value : "default" ,
21
23
} ,
22
24
{
23
- label : trans ( "text" ) ,
25
+ label : trans ( "table. text" ) ,
24
26
value : "text" ,
25
27
} ,
26
28
] as const ;
27
29
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
+
28
45
export const ButtonComp = ( function ( ) {
29
46
const childrenMap = {
30
47
text : StringControl ,
31
48
buttonType : dropdownControl ( ButtonTypeOptions , "primary" ) ,
32
49
onClick : ActionSelectorControlInContext ,
33
50
loading : BoolCodeControl ,
34
51
disabled : BoolCodeControl ,
52
+ displayMode : dropdownControl ( ButtonDisplayOptions , "text" ) ,
53
+ icon : IconControl ,
35
54
} ;
36
55
return new ColumnTypeCompBuilder (
37
56
childrenMap ,
38
57
( props ) => {
39
58
const ButtonStyled = ( ) => {
40
59
const style = useStyle ( ButtonStyle ) ;
60
+ const showIcon = props . displayMode === "icon" || props . displayMode === "textAndIcon" ;
61
+ const showText = props . displayMode === "text" || props . displayMode === "textAndIcon" ;
62
+
41
63
return (
42
64
< Button100
43
65
type = { props . buttonType }
@@ -46,9 +68,10 @@ export const ButtonComp = (function () {
46
68
disabled = { props . disabled }
47
69
$buttonStyle = { props . buttonType === "primary" ? style : undefined }
48
70
style = { { margin : 0 } }
71
+ icon = { showIcon && hasIcon ( props . icon ) ? props . icon : undefined }
49
72
>
50
73
{ /* prevent the button from disappearing */ }
51
- { ! props . text ? " " : props . text }
74
+ { showText ? ( ! props . text ? " " : props . text ) : null }
52
75
</ Button100 >
53
76
) ;
54
77
} ;
@@ -58,10 +81,21 @@ export const ButtonComp = (function () {
58
81
)
59
82
. setPropertyViewFn ( ( children ) => (
60
83
< >
61
- { children . text . propertyView ( {
62
- label : trans ( "table.columnValue " ) ,
63
- tooltip : ColumnValueTooltip ,
84
+ { children . displayMode . propertyView ( {
85
+ label : trans ( "table.displayMode " ) ,
86
+ radioButton : true ,
64
87
} ) }
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
+ }
65
99
{ children . buttonType . propertyView ( {
66
100
label : trans ( "table.type" ) ,
67
101
radioButton : true ,
0 commit comments