@@ -12,19 +12,16 @@ const actions = ({value}) => [
12
12
} ,
13
13
{
14
14
label : `View tutorials on this chart type.` ,
15
- href : `#` , // update
15
+ href : `#` ,
16
16
icon : < ThumnailViewIcon /> ,
17
17
} ,
18
18
{
19
19
label : `See a basic example.` ,
20
- href : `#` , // update
20
+ href : `#` ,
21
21
icon : < GraphIcon /> ,
22
22
} ,
23
23
] ;
24
24
25
- /**
26
- * This renders our item actions
27
- */
28
25
const renderActionItems = ( actionItems , item ) =>
29
26
actionItems ( item ) . map ( ( action , i ) => (
30
27
< a
@@ -40,18 +37,15 @@ const renderActionItems = (actionItems, item) =>
40
37
</ a >
41
38
) ) ;
42
39
43
- /**
44
- * Trace Type Item
45
- */
46
- const Item = ( { item, active, handleClick} ) => {
40
+ const Item = ( { item, active, handleClick, actions, showActions} ) => {
47
41
const { label, value, icon} = item ;
48
42
return (
49
43
< div
50
44
className = { `trace-item${ active ? ' trace-item--active' : '' } ` }
51
45
onClick = { ( ) => handleClick ( ) }
52
46
>
53
47
< div className = "trace-item__actions" >
54
- { actions ? renderActionItems ( actions , item ) : null }
48
+ { actions && showActions ? renderActionItems ( actions , item ) : null }
55
49
</ div >
56
50
< div className = "trace-item__image" >
57
51
< img src = { `/_temp/ic-${ icon ? icon : value } .svg` } />
@@ -61,9 +55,6 @@ const Item = ({item, active, handleClick}) => {
61
55
) ;
62
56
} ;
63
57
64
- /**
65
- * Trace Type Selector
66
- */
67
58
class TraceTypeSelector extends Component {
68
59
selectAndClose ( value ) {
69
60
const computedValue = traceTypeToPlotlyInitFigure ( value ) ;
@@ -81,9 +72,9 @@ class TraceTypeSelector extends Component {
81
72
) ;
82
73
83
74
const MAX_ITEMS = 6 ;
75
+
84
76
let columnClasses = 'trace-grid__column' ;
85
77
86
- // If the category has more than 6 items, it will span 2 columns
87
78
if ( items . length > MAX_ITEMS ) {
88
79
columnClasses += ' trace-grid__column--double' ;
89
80
}
@@ -97,6 +88,8 @@ class TraceTypeSelector extends Component {
97
88
key = { item . value }
98
89
active = { fullValue === item . value }
99
90
item = { item }
91
+ actions = { actions }
92
+ showActions = { false }
100
93
handleClick = { ( ) => this . selectAndClose ( item . value ) }
101
94
/>
102
95
) ) }
@@ -144,8 +137,6 @@ class TraceTypeButton extends React.Component {
144
137
}
145
138
}
146
139
147
- export const TraceTypeSelectorButton = localize ( TraceTypeButton ) ;
148
-
149
140
TraceTypeSelector . propTypes = {
150
141
updateContainer : PropTypes . func ,
151
142
fullValue : PropTypes . string ,
@@ -165,6 +156,10 @@ Item.propTypes = {
165
156
item : PropTypes . object ,
166
157
active : PropTypes . bool ,
167
158
handleClick : PropTypes . func ,
159
+ actions : PropTypes . array ,
160
+ showActions : PropTypes . bool ,
168
161
} ;
169
162
170
163
export default localize ( TraceTypeSelector ) ;
164
+
165
+ export const TraceTypeSelectorButton = localize ( TraceTypeButton ) ;
0 commit comments