Migrate all search to v2 and remove v1 (#11125)

This commit is contained in:
DS Boyce
2026-07-09 15:08:20 -07:00
committed by GitHub
parent 65e10f13f7
commit 3499d3646e
14 changed files with 114 additions and 475 deletions
@@ -1,12 +1,10 @@
import {useMemo} from 'react'
import {msg} from '@lingui/core/macro'
import {useLingui} from '@lingui/react'
import {Trans} from '@lingui/react/macro'
import {Trans, useLingui} from '@lingui/react/macro'
import {languageName} from '#/locale/helpers'
import {APP_LANGUAGES, LANGUAGES} from '#/locale/languages'
import {useLanguagePrefs} from '#/state/preferences'
import {atoms as a, native, platform, tokens} from '#/alf'
import {atoms as a, native, platform} from '#/alf'
import {Button, ButtonIcon, ButtonText} from '#/components/Button'
import {
ChevronBottom_Stroke2_Corner0_Rounded as ChevronDownIcon,
@@ -14,7 +12,6 @@ import {
} from '#/components/icons/Chevron'
import {Earth_Stroke2_Corner0_Rounded as EarthIcon} from '#/components/icons/Globe'
import * as Menu from '#/components/Menu'
import {useAnalytics} from '#/analytics'
export function SearchLanguageDropdown({
showIcon = true,
@@ -25,14 +22,9 @@ export function SearchLanguageDropdown({
value: string
onChange(value: string): void
}) {
const ax = useAnalytics()
const {_} = useLingui()
const {t: l} = useLingui()
const {appLanguage, contentLanguages, primaryLanguage} = useLanguagePrefs()
const searchV2Enabled = ax.features.enabled(ax.features.SearchV2Enable)
const advancedSearchV2Enabled =
searchV2Enabled && ax.features.enabled(ax.features.AdvancedSearchV2Enable)
const languages = useMemo(() => {
return LANGUAGES.filter(
(lang, index, self) =>
@@ -70,40 +62,20 @@ export function SearchLanguageDropdown({
}, [appLanguage, contentLanguages, primaryLanguage])
const currentLanguageLabel =
languages.find(lang => lang.value === value)?.label ?? _(msg`All languages`)
languages.find(lang => lang.value === value)?.label ?? l`All languages`
return (
<Menu.Root>
<Menu.Trigger
label={_(
msg`Filter search by language (currently: ${currentLanguageLabel})`,
)}>
label={l`Filter search by language (currently: ${currentLanguageLabel})`}>
{({props}) => (
<Button
{...props}
label={props.accessibilityLabel}
size="small"
color={
advancedSearchV2Enabled
? 'secondary'
: platform({native: 'primary', default: 'secondary'})
}
variant={
advancedSearchV2Enabled
? 'solid'
: platform({native: 'ghost', default: 'solid'})
}
style={
showIcon
? native([
a.py_sm,
a.px_sm,
advancedSearchV2Enabled
? null
: {marginRight: tokens.space.sm * -1},
])
: null
}>
color="secondary"
variant="solid"
style={showIcon ? native([a.py_sm, a.px_sm]) : null}>
{showIcon ? <ButtonIcon icon={EarthIcon} /> : null}
<ButtonText>{currentLanguageLabel}</ButtonText>
<ButtonIcon
@@ -119,7 +91,7 @@ export function SearchLanguageDropdown({
<Menu.LabelText>
<Trans>Filter search by language</Trans>
</Menu.LabelText>
<Menu.Item label={_(msg`All languages`)} onPress={() => onChange('')}>
<Menu.Item label={l`All languages`} onPress={() => onChange('')}>
<Menu.ItemText>
<Trans>All languages</Trans>
</Menu.ItemText>