Undo reverse logic when filtering by component type

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

View File

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