@@ -27,8 +27,10 @@ export class ViewEventContextMenuBuilder {
27
27
private onPin : ( event : CollectedEvent ) => void ,
28
28
private onDelete : ( event : CollectedEvent ) => void ,
29
29
private onBuildRuleFromExchange : ( exchange : HttpExchangeView ) => void ,
30
- private onPrepareToResendRequest ?: ( exchange : HttpExchangeView ) => void
31
- ) { }
30
+ private onPrepareToResendRequest ?: ( exchange : HttpExchangeView ) => void ,
31
+ private onHeaderColumnOptionChange ?: ( columnName : string , show : boolean ) => void ,
32
+ ) {
33
+ }
32
34
33
35
private readonly BaseOptions = {
34
36
Pin : {
@@ -142,4 +144,28 @@ export class ViewEventContextMenuBuilder {
142
144
} ;
143
145
}
144
146
147
+ getHeaderContextMenuCallback ( enabledColumns : Map < string , boolean > ) {
148
+ let menuOptions : ContextMenuItem < void > [ ] = [ ] ;
149
+
150
+ enabledColumns . forEach ( ( enabled , columnName ) => {
151
+ menuOptions . push ( {
152
+ type : 'option' ,
153
+ label : ( ! enabled ? "Show " : "Hide " ) + columnName ,
154
+ callback : ( ) => {
155
+ this . onHeaderColumnOptionChange ? this . onHeaderColumnOptionChange ( columnName , ! enabled ) : console . log ( 'onHeaderColumnOptionChange callback not set' ) ;
156
+ }
157
+ } ) ;
158
+ } ) ;
159
+
160
+ return ( mouseEvent : React . MouseEvent ) => {
161
+ const sortedOptions = _ . sortBy ( menuOptions , ( o : ContextMenuItem < void > ) =>
162
+ o . type === 'separator' || ! ( o . enabled ?? true )
163
+ ) as Array < ContextMenuItem < void > > ;
164
+
165
+ this . uiStore . handleContextMenuEvent (
166
+ mouseEvent ,
167
+ sortedOptions
168
+ )
169
+ } ;
170
+ }
145
171
}
0 commit comments