@@ -186,6 +186,7 @@ export const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
186186
187187export interface ViewInput {
188188 gridData : DataGrid . DataGrid . DataGridNode < CookieReportNodeData > [ ] ;
189+ filterItems : UI . FilterBar . Item [ ] ;
189190 onFilterChanged : ( ) => void ;
190191 onSortingChanged : ( ) => void ;
191192 populateContextMenu :
@@ -214,6 +215,7 @@ export class CookieReportView extends UI.Widget.VBox {
214215 #view: View ;
215216 dataGrid ?: DataGrid . DataGrid . DataGridImpl < CookieReportNodeData > ;
216217 gridData : DataGrid . DataGrid . DataGridNode < CookieReportNodeData > [ ] = [ ] ;
218+ filterItems : UI . FilterBar . Item [ ] = [ ] ;
217219
218220 constructor ( element ?: HTMLElement , view : View = ( input , output , target ) => {
219221 const dataGridOptions : DataGrid . DataGrid . DataGridWidgetOptions < CookieReportNodeData > = {
@@ -231,33 +233,6 @@ export class CookieReportView extends UI.Widget.VBox {
231233 rowContextMenuCallback : input . populateContextMenu . bind ( input ) ,
232234 } ;
233235
234- const filterItems : UI . FilterBar . Item [ ] = [ ] ;
235-
236- if ( input . gridData . some ( n => n . data [ 'status' ] === i18nString ( UIStrings . blocked ) ) ) {
237- filterItems . push ( {
238- name : UIStrings . blocked ,
239- label : ( ) => i18nString ( UIStrings . blocked ) ,
240- title : UIStrings . blocked ,
241- jslogContext : UIStrings . blocked ,
242- } ) ;
243- }
244- if ( input . gridData . some ( n => n . data [ 'status' ] === i18nString ( UIStrings . allowed ) ) ) {
245- filterItems . push ( {
246- name : UIStrings . allowed ,
247- label : ( ) => i18nString ( UIStrings . allowed ) ,
248- title : UIStrings . allowed ,
249- jslogContext : UIStrings . allowed ,
250- } ) ;
251- }
252- if ( input . gridData . some ( n => n . data [ 'status' ] === i18nString ( UIStrings . allowedByException ) ) ) {
253- filterItems . push ( {
254- name : UIStrings . allowedByException ,
255- label : ( ) => i18nString ( UIStrings . allowedByException ) ,
256- title : UIStrings . allowedByException ,
257- jslogContext : UIStrings . allowedByException ,
258- } ) ;
259- }
260-
261236 // clang-format off
262237 render ( html `
263238 < div class ="report overflow-auto ">
@@ -270,7 +245,7 @@ export class CookieReportView extends UI.Widget.VBox {
270245 < devtools-named-bit-set-filter
271246 class ="filter "
272247 @filterChanged =${ input . onFilterChanged }
273- .options =${ { items : filterItems } }
248+ .options =${ { items : input . filterItems } }
274249 ${ ref ( ( el ?: Element ) => {
275250 if ( el instanceof UI . FilterBar . NamedBitSetFilterUIElement ) {
276251 output . namedBitSetFilterUI = el . getOrCreateNamedBitSetFilterUI ( ) ;
@@ -327,6 +302,7 @@ export class CookieReportView extends UI.Widget.VBox {
327302
328303 override performUpdate ( ) : void {
329304 this . gridData = this . #buildNodes( ) ;
305+ this . filterItems = this . #buildFilterItems( ) ;
330306 this . #view( this , this , this . contentElement ) ;
331307 }
332308
@@ -361,6 +337,39 @@ export class CookieReportView extends UI.Widget.VBox {
361337 }
362338 }
363339
340+ #buildFilterItems( ) : UI . FilterBar . Item [ ] {
341+ const filterItems : UI . FilterBar . Item [ ] = [ ] ;
342+
343+ if ( this . #cookieRows. values ( ) . some ( n => n . status === IssuesManager . CookieIssue . CookieStatus . BLOCKED ) ) {
344+ filterItems . push ( {
345+ name : UIStrings . blocked ,
346+ label : ( ) => i18nString ( UIStrings . blocked ) ,
347+ title : UIStrings . blocked ,
348+ jslogContext : UIStrings . blocked ,
349+ } ) ;
350+ }
351+ if ( this . #cookieRows. values ( ) . some ( n => n . status === IssuesManager . CookieIssue . CookieStatus . ALLOWED ) ) {
352+ filterItems . push ( {
353+ name : UIStrings . allowed ,
354+ label : ( ) => i18nString ( UIStrings . allowed ) ,
355+ title : UIStrings . allowed ,
356+ jslogContext : UIStrings . allowed ,
357+ } ) ;
358+ }
359+ if ( this . #cookieRows. values ( ) . some (
360+ n => n . status === IssuesManager . CookieIssue . CookieStatus . ALLOWED_BY_GRACE_PERIOD ||
361+ n . status === IssuesManager . CookieIssue . CookieStatus . ALLOWED_BY_HEURISTICS ) ) {
362+ filterItems . push ( {
363+ name : UIStrings . allowedByException ,
364+ label : ( ) => i18nString ( UIStrings . allowedByException ) ,
365+ title : UIStrings . allowedByException ,
366+ jslogContext : UIStrings . allowedByException ,
367+ } ) ;
368+ }
369+
370+ return filterItems ;
371+ }
372+
364373 #buildNodes( ) : DataGrid . DataGrid . DataGridNode < CookieReportNodeData > [ ] {
365374 return [ ...this . #cookieRows. values ( ) ]
366375 . filter ( row => {
0 commit comments