Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit fc8ced3

Browse filesBrowse files
ramazansancarantfu
andauthored
feat: filter out installed modules in search result, closes #780 (#786)
Co-authored-by: Anthony Fu <github@antfu.me>
1 parent 7c8999e commit fc8ced3
Copy full SHA for fc8ced3

File tree

Expand file treeCollapse file tree

1 file changed

+19
-4
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+19
-4
lines changed

‎packages/devtools/client/components/ModuleInstallList.vue

Copy file name to clipboardExpand all lines: packages/devtools/client/components/ModuleInstallList.vue
+19-4Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,19 @@ import Fuse from 'fuse.js'
44
import { computed, ref } from 'vue'
55
// @ts-expect-error missing types
66
import { RecycleScroller } from 'vue-virtual-scroller'
7-
import { useModulesList } from '~/composables/state-modules'
7+
import { useInstalledModules, useModulesList } from '~/composables/state-modules'
88
99
type SortingFunction<T> = (a: T, b: T) => number
1010
1111
const emit = defineEmits(['close'])
1212
1313
const collection = useModulesList()
14+
const installedModules = useInstalledModules()
1415
1516
const sortingOptions = ['downloads', 'stars', 'updated', 'created'] as const
1617
const ascendingOrder = ref(false)
1718
const selectedSortingOption = ref<typeof sortingOptions[number]>(sortingOptions[0])
19+
const excludeInstalled = ref(true)
1820
1921
const sortingFactors: Record<typeof sortingOptions[number], SortingFunction<ModuleStaticInfo>> = {
2022
downloads: (a, b) => a.stats.downloads - b.stats.downloads,
@@ -45,9 +47,13 @@ const fuse = computed(() => new Fuse(collection.value || [], {
4547
}))
4648
4749
const items = computed(() => {
50+
let filteredItems = sortedItems.value
51+
if (excludeInstalled.value) {
52+
filteredItems = (filteredItems || []).filter(item => !installedModules.value.some(installed => installed.name === item.name))
53+
}
4854
if (!search.value)
49-
return sortedItems.value
50-
return fuse.value.search(search.value).map(r => r.item)
55+
return filteredItems
56+
return fuse.value.search(search.value).map(r => r.item).filter(item => filteredItems?.includes(item))
5157
})
5258
</script>
5359

@@ -59,7 +65,7 @@ const items = computed(() => {
5965
icon="i-carbon-intent-request-create"
6066
text="Install Module"
6167
/>
62-
<NNavbar v-model:search="search" no-padding px-6 pb-5 pt-2>
68+
<NNavbar v-model:search="search" no-padding px-6 pb-3 pt-2>
6369
<template #actions>
6470
<NDropdown direction="end" n="sm primary">
6571
<template #trigger="{ click }">
@@ -96,6 +102,15 @@ const items = computed(() => {
96102
</div>
97103
</NDropdown>
98104
</template>
105+
<div flex="~ items-center gap-2">
106+
<NCheckbox v-model="excludeInstalled" n="primary md">
107+
<span op75>Exclude installed modules</span>
108+
</NCheckbox>
109+
<div flex="~ gap1" text-sm op50>
110+
<span v-if="search || excludeInstalled">{{ items?.length }} matched · </span>
111+
<span>{{ collection?.length }} modules in total</span>
112+
</div>
113+
</div>
99114
</NNavbar>
100115

101116
<div flex-auto of-auto flex="~ col gap-2" pl6 pr4>

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.