@@ -8,14 +8,7 @@ import {
88 RepoIcon ,
99 SearchIcon ,
1010} from '@primer/octicons-react' ;
11- import {
12- ActionList ,
13- Box ,
14- Popover ,
15- Stack ,
16- Text ,
17- TextInputWithTokens ,
18- } from '@primer/react' ;
11+ import { Box , Stack , Text , TextInputWithTokens } from '@primer/react' ;
1912
2013import { AppContext } from '../../context/App' ;
2114import { IconColor , type SearchToken , Size } from '../../types' ;
@@ -30,32 +23,7 @@ import { RequiresDetailedNotificationWarning } from './RequiresDetailedNotificat
3023
3124type InputToken = { id : number ; text : string } ;
3225
33- type Qualifier = {
34- key : string ; // the qualifier prefix shown to user (author, org, repo)
35- description : string ;
36- } ;
37-
38- const QUALIFIERS : Qualifier [ ] = [
39- { key : 'author:' , description : 'Filter by notification author' } ,
40- { key : 'org:' , description : 'Filter by organization owner' } ,
41- { key : 'repo:' , description : 'Filter by repository full name' } ,
42- ] ;
43-
44- const INCLUDE_EXAMPLES : Record < string , string > = {
45- 'author:' : 'author:octocat' ,
46- 'org:' : 'org:gitify-app' ,
47- 'repo:' : 'repo:gitify-app/gitify' ,
48- } ;
49-
50- const EXCLUDE_EXAMPLES : Record < string , string > = {
51- 'author:' : 'author:spambot' ,
52- 'org:' : 'org:hooli' ,
53- 'repo:' : 'repo:hooli/nucleas' ,
54- } ;
55-
56- function getExample ( key : string , mode : 'include' | 'exclude' ) {
57- return ( mode === 'include' ? INCLUDE_EXAMPLES : EXCLUDE_EXAMPLES ) [ key ] || '' ;
58- }
26+ import { SearchFilterSuggestions } from './SearchFilterSuggestions' ;
5927
6028const tokenEvents = [ 'Enter' , 'Tab' , ' ' , ',' ] ;
6129
@@ -193,10 +161,10 @@ export const SearchFilter: FC = () => {
193161 </ Stack >
194162 < Stack direction = "horizontal" gap = "condensed" >
195163 < OrganizationIcon size = { Size . SMALL } />
196- Organization (org:orgname )
164+ Organization (org:name )
197165 </ Stack >
198166 < Stack direction = "horizontal" gap = "condensed" >
199- < RepoIcon size = { Size . SMALL } /> Repository (repo:reponame )
167+ < RepoIcon size = { Size . SMALL } /> Repository (repo:fullname )
200168 </ Stack >
201169 </ Stack >
202170 </ Box >
@@ -221,10 +189,7 @@ export const SearchFilter: FC = () => {
221189 < Box flexGrow = { 1 } position = "relative" >
222190 < TextInputWithTokens
223191 block
224- disabled = {
225- ! settings . detailedNotifications ||
226- hasExcludeSearchFilters ( settings )
227- }
192+ disabled = { ! settings . detailedNotifications }
228193 onBlur = { ( e ) => {
229194 addIncludeSearchToken ( e ) ;
230195 setShowIncludeSuggestions ( false ) ;
@@ -254,53 +219,11 @@ export const SearchFilter: FC = () => {
254219 title = "Include searches"
255220 tokens = { includeSearchTokens }
256221 />
257- { showIncludeSuggestions && (
258- < Popover
259- caret = { false }
260- onOpenChange = { ( ) => setShowIncludeSuggestions ( false ) }
261- open
262- >
263- < Popover . Content sx = { { p : 0 , mt : 1 , width : '100%' } } >
264- < ActionList >
265- { QUALIFIERS . filter (
266- ( q ) =>
267- q . key . startsWith ( includeInputValue . toLowerCase ( ) ) ||
268- includeInputValue === '' ,
269- ) . map ( ( q ) => (
270- < ActionList . Item
271- key = { q . key }
272- onSelect = { ( ) => {
273- setIncludeInputValue ( `${ q . key } :` ) ;
274- const inputEl =
275- document . querySelector < HTMLInputElement > (
276- `fieldset#${ fieldsetId } input[title='Include searches']` ,
277- ) ;
278- if ( inputEl ) {
279- inputEl . value = `${ q . key } :` ;
280- inputEl . focus ( ) ;
281- }
282- setShowIncludeSuggestions ( false ) ;
283- } }
284- >
285- < Stack
286- className = "text-xs"
287- direction = "vertical"
288- gap = "none"
289- >
290- < Text className = "text-xs font-semibold" > { q . key } </ Text >
291- < Text className = "text-[10px] opacity-70" >
292- { q . description }
293- </ Text >
294- < Text className = "text-[10px] font-mono opacity-80" >
295- { getExample ( q . key , 'include' ) }
296- </ Text >
297- </ Stack >
298- </ ActionList . Item >
299- ) ) }
300- </ ActionList >
301- </ Popover . Content >
302- </ Popover >
303- ) }
222+ < SearchFilterSuggestions
223+ inputValue = { includeInputValue }
224+ onClose = { ( ) => setShowIncludeSuggestions ( false ) }
225+ open = { showIncludeSuggestions }
226+ />
304227 </ Box >
305228 </ Stack >
306229
@@ -319,10 +242,7 @@ export const SearchFilter: FC = () => {
319242 < Box flexGrow = { 1 } position = "relative" >
320243 < TextInputWithTokens
321244 block
322- disabled = {
323- ! settings . detailedNotifications ||
324- hasIncludeSearchFilters ( settings )
325- }
245+ disabled = { ! settings . detailedNotifications }
326246 onBlur = { ( e ) => {
327247 addExcludeSearchToken ( e ) ;
328248 setShowExcludeSuggestions ( false ) ;
@@ -351,53 +271,11 @@ export const SearchFilter: FC = () => {
351271 title = "Exclude searches"
352272 tokens = { excludeSearchTokens }
353273 />
354- { showExcludeSuggestions && (
355- < Popover
356- caret = { false }
357- onOpenChange = { ( ) => setShowExcludeSuggestions ( false ) }
358- open
359- >
360- < Popover . Content sx = { { p : 0 , mt : 1 , width : '100%' } } >
361- < ActionList >
362- { QUALIFIERS . filter (
363- ( q ) =>
364- q . key . startsWith ( excludeInputValue . toLowerCase ( ) ) ||
365- excludeInputValue === '' ,
366- ) . map ( ( q ) => (
367- < ActionList . Item
368- key = { q . key }
369- onSelect = { ( ) => {
370- setExcludeInputValue ( `${ q . key } :` ) ;
371- const inputEl =
372- document . querySelector < HTMLInputElement > (
373- `fieldset#${ fieldsetId } input[title='Exclude searches']` ,
374- ) ;
375- if ( inputEl ) {
376- inputEl . value = `${ q . key } :` ;
377- inputEl . focus ( ) ;
378- }
379- setShowExcludeSuggestions ( false ) ;
380- } }
381- >
382- < Stack
383- className = "text-xs"
384- direction = "vertical"
385- gap = "none"
386- >
387- < Text className = "text-xs font-semibold" > { q . key } </ Text >
388- < Text className = "text-[10px] opacity-70" >
389- { q . description }
390- </ Text >
391- < Text className = "text-[10px] font-mono opacity-80" >
392- { getExample ( q . key , 'exclude' ) }
393- </ Text >
394- </ Stack >
395- </ ActionList . Item >
396- ) ) }
397- </ ActionList >
398- </ Popover . Content >
399- </ Popover >
400- ) }
274+ < SearchFilterSuggestions
275+ inputValue = { excludeInputValue }
276+ onClose = { ( ) => setShowExcludeSuggestions ( false ) }
277+ open = { showExcludeSuggestions }
278+ />
401279 </ Box >
402280 </ Stack >
403281 </ Stack >
0 commit comments