Merge pull request #6246 from menloresearch/fix/sort-filter-hub

fix: hidden sort filter when searching model
This commit is contained in:
Faisal Amir 2025-08-20 14:36:15 +07:00 committed by GitHub
commit 43ab6dfc65
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -146,14 +146,16 @@ function Hub() {
} }
// Apply downloaded filter // Apply downloaded filter
if (showOnlyDownloaded) { if (showOnlyDownloaded) {
filtered = filtered?.map((model) => ({ filtered = filtered
...model, ?.map((model) => ({
quants: model.quants.filter((variant) => ...model,
llamaProvider?.models.some( quants: model.quants.filter((variant) =>
(m: { id: string }) => m.id === variant.model_id llamaProvider?.models.some(
) (m: { id: string }) => m.id === variant.model_id
) )
})).filter((model) => model.quants.length > 0) ),
}))
.filter((model) => model.quants.length > 0)
} }
// Add HuggingFace repo at the beginning if available // Add HuggingFace repo at the beginning if available
if (huggingFaceRepo) { if (huggingFaceRepo) {
@ -428,43 +430,44 @@ function Hub() {
const isLastStep = currentStepIndex === steps.length - 1 const isLastStep = currentStepIndex === steps.length - 1
const renderFilter = () => { const renderFilter = () => {
return ( if (searchValue.length === 0)
<> return (
<DropdownMenu> <>
<DropdownMenuTrigger> <DropdownMenu>
<span className="flex cursor-pointer items-center gap-1 px-2 py-1 rounded-sm bg-main-view-fg/15 text-sm outline-none text-main-view-fg font-medium"> <DropdownMenuTrigger>
{ <span className="flex cursor-pointer items-center gap-1 px-2 py-1 rounded-sm bg-main-view-fg/15 text-sm outline-none text-main-view-fg font-medium">
sortOptions.find((option) => option.value === sortSelected) {
?.name sortOptions.find((option) => option.value === sortSelected)
} ?.name
}
</span>
</DropdownMenuTrigger>
<DropdownMenuContent side="bottom" align="end">
{sortOptions.map((option) => (
<DropdownMenuItem
className={cn(
'cursor-pointer my-0.5',
sortSelected === option.value && 'bg-main-view-fg/5'
)}
key={option.value}
onClick={() => setSortSelected(option.value)}
>
{option.name}
</DropdownMenuItem>
))}
</DropdownMenuContent>
</DropdownMenu>
<div className="flex items-center gap-2">
<Switch
checked={showOnlyDownloaded}
onCheckedChange={setShowOnlyDownloaded}
/>
<span className="text-xs text-main-view-fg/70 font-medium whitespace-nowrap">
{t('hub:downloaded')}
</span> </span>
</DropdownMenuTrigger> </div>
<DropdownMenuContent side="bottom" align="end"> </>
{sortOptions.map((option) => ( )
<DropdownMenuItem
className={cn(
'cursor-pointer my-0.5',
sortSelected === option.value && 'bg-main-view-fg/5'
)}
key={option.value}
onClick={() => setSortSelected(option.value)}
>
{option.name}
</DropdownMenuItem>
))}
</DropdownMenuContent>
</DropdownMenu>
<div className="flex items-center gap-2">
<Switch
checked={showOnlyDownloaded}
onCheckedChange={setShowOnlyDownloaded}
/>
<span className="text-xs text-main-view-fg/70 font-medium whitespace-nowrap">
{t('hub:downloaded')}
</span>
</div>
</>
)
} }
return ( return (