@@ -22,6 +22,7 @@ import {
2222 css ,
2323 html ,
2424 PropertyValueMap ,
25+ nothing ,
2526} from 'lit' ;
2627import { customElement , property , state } from 'lit/decorators.js' ;
2728import { type components } from 'webstatus.dev-backend' ;
@@ -62,9 +63,11 @@ import {Toast} from '../utils/toast.js';
6263import { navigateToUrl } from '../utils/app-router.js' ;
6364import {
6465 AppBookmarkInfo ,
66+ SavedSearchScope ,
6567 savedSearchHelpers ,
6668} from '../contexts/app-bookmark-info-context.js' ;
67- import { VOCABULARY } from '../utils/constants.js' ;
69+ import { UserSavedSearch , VOCABULARY } from '../utils/constants.js' ;
70+ import { User , firebaseUserContext } from '../contexts/firebase-user-context.js' ;
6871
6972const WEBSTATUS_FEATURE_OVERVIEW_CSV_FILENAME =
7073 'webstatus-feature-overview.csv' ;
@@ -82,8 +85,14 @@ export class WebstatusOverviewFilters extends LitElement {
8285 @property ( { type : Object } )
8386 appBookmarkInfo ?: AppBookmarkInfo ;
8487
88+ @consume ( { context : firebaseUserContext , subscribe : true } )
89+ @state ( )
90+ user : User | null | undefined ;
91+
8592 _activeQuery : string = '' ;
8693
94+ _activeUserSavedSearch ?: UserSavedSearch | undefined ;
95+
8796 // Whether the export button should be enabled based on export status.
8897 @state ( )
8998 exportDataStatus : TaskStatus = TaskStatus . INITIAL ;
@@ -159,6 +168,13 @@ export class WebstatusOverviewFilters extends LitElement {
159168 this . appBookmarkInfo ,
160169 this . location ,
161170 ) ;
171+ const search = savedSearchHelpers . getCurrentSavedSearch (
172+ this . appBookmarkInfo ,
173+ this . location ,
174+ ) ;
175+ if ( search ?. scope === SavedSearchScope . UserSavedSearch ) {
176+ this . _activeUserSavedSearch = search . value ;
177+ }
162178 }
163179 }
164180
@@ -367,6 +383,35 @@ export class WebstatusOverviewFilters extends LitElement {
367383 < sl-icon slot ="prefix " name ="search "> </ sl-icon >
368384 </ sl-button >
369385 </ webstatus-typeahead >
386+ ${ this . user && this . apiClient
387+ ? this . renderSavedSearchControls ( this . user , this . apiClient )
388+ : nothing }
389+ ` ;
390+ }
391+
392+ renderSavedSearchControls ( user : User , apiClient : APIClient ) : TemplateResult {
393+ if ( this . typeaheadRef . value === undefined ) {
394+ return html `` ;
395+ }
396+ return html `
397+ < sl-popup
398+ placement ="top-end "
399+ autoSize ="horizontal "
400+ distance ="5 "
401+ active
402+ .anchor =${ this . typeaheadRef . value }
403+ >
404+ < div slot ="anchor " class ="popup-anchor saved-search-controls "> </ div >
405+ < div class ="popup-content ">
406+ < webstatus-saved-search-controls
407+ .user =${ user }
408+ .apiClient =${ apiClient }
409+ .savedSearch=${ this . _activeUserSavedSearch }
410+ .location=${ this . location }
411+ .overviewPageQueryInput=${ this . typeaheadRef . value }
412+ > </ webstatus-saved-search-controls >
413+ </ div >
414+ </ sl-popup >
370415 ` ;
371416 }
372417
0 commit comments