Undo reverse logic when filtering by component type

This commit is contained in:
Andrew Kingston 2022-09-12 16:19:28 +01:00
parent dc1b0e2bd7
commit 10c7964afe
1 changed files with 14 additions and 12 deletions

View File

@ -16,21 +16,23 @@
let modal
let searchTerm = ""
let filter = "all"
let filterOptions = [
{ label: "All Plugins", value: "all" },
{ label: "Components", value: "datasource" },
{ label: "Datasources", value: "component" },
{ label: "Components", value: "component" },
{ label: "Datasources", value: "datasource" },
]
let filter = "all"
$: filteredPlugins =
filter === "all" && searchTerm.length === 0
? $plugins
: $plugins
.filter(plugin => plugin.schema.type !== filter)
.filter(plugin =>
plugin?.name?.toLowerCase().includes(searchTerm.toLowerCase())
)
$: filteredPlugins = $plugins
.filter(plugin => {
return filter === "all" || plugin.schema.type === filter
})
.filter(plugin => {
return (
!searchTerm ||
plugin?.name?.toLowerCase().includes(searchTerm.toLowerCase())
)
})
onMount(async () => {
await plugins.load()