File tree Expand file tree Collapse file tree 2 files changed +14
-6
lines changed
utils/notifications/filters Expand file tree Collapse file tree 2 files changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -6,11 +6,9 @@ import { Opacity } from '../../types';
66import { cn } from '../../utils/cn' ;
77import {
88 SEARCH_DELIMITER ,
9- SEARCH_QUALIFIERS ,
9+ getAvailableSearchQualifiers ,
1010} from '../../utils/notifications/filters/search' ;
1111
12- const QUALIFIERS = Object . values ( SEARCH_QUALIFIERS ) ;
13-
1412interface SearchFilterSuggestionsProps {
1513 open : boolean ;
1614 inputValue : string ;
@@ -29,9 +27,7 @@ export const SearchFilterSuggestions: FC<SearchFilterSuggestionsProps> = ({
2927 }
3028
3129 const lower = inputValue . toLowerCase ( ) ;
32- const base = isDetailedNotificationsEnabled
33- ? QUALIFIERS
34- : QUALIFIERS . filter ( ( q ) => ! q . requiresDetailsNotifications ) ;
30+ const base = getAvailableSearchQualifiers ( isDetailedNotificationsEnabled ) ;
3531 const suggestions = base . filter (
3632 ( q ) => q . prefix . startsWith ( lower ) || inputValue === '' ,
3733 ) ;
Original file line number Diff line number Diff line change @@ -47,6 +47,18 @@ export const AUTHOR_PREFIX: SearchPrefix = SEARCH_QUALIFIERS.author.prefix;
4747export const ORG_PREFIX : SearchPrefix = SEARCH_QUALIFIERS . org . prefix ;
4848export const REPO_PREFIX : SearchPrefix = SEARCH_QUALIFIERS . repo . prefix ;
4949
50+ // Qualifier selection helpers (centralized to avoid duplicating logic in UI components)
51+ export function getAvailableSearchQualifiers (
52+ detailedNotificationsEnabled : boolean ,
53+ ) : readonly SearchQualifier [ ] {
54+ const all = Object . values ( SEARCH_QUALIFIERS ) as readonly SearchQualifier [ ] ;
55+ if ( detailedNotificationsEnabled ) return all ;
56+ return all . filter ( ( q ) => ! q . requiresDetailsNotifications ) ;
57+ }
58+
59+ export const BASE_SEARCH_QUALIFIERS : readonly SearchQualifier [ ] = getAvailableSearchQualifiers ( false ) ;
60+ export const ALL_SEARCH_QUALIFIERS : readonly SearchQualifier [ ] = getAvailableSearchQualifiers ( true ) ;
61+
5062export function hasIncludeSearchFilters ( settings : SettingsState ) {
5163 return settings . filterIncludeSearchTokens . length > 0 ;
5264}
You can’t perform that action at this time.
0 commit comments