Skip to content

Commit b97556d

Browse files
committed
Add number of matched elements when filtering
1 parent 8319329 commit b97556d

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

app/gui/integration-test/project-view/componentBrowser.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,8 @@ test('Filtering list', async ({ page }) => {
202202
await expect(segments).toHaveText(['Data.', 're', 'ad', '_te', 'xt'])
203203
const highlighted = locate.componentBrowserEntry(page).locator('.component-label-segment.match')
204204
await expect(highlighted).toHaveText(['re', '_te'])
205+
// Filtered-out group are hidden, and the rest displays number of matched elements.
206+
await expect(page.locator('.groupEntry')).toHaveText(['all (1)', 'Input (1)'])
205207
})
206208

207209
test('Navigating groups', async ({ page }) => {

app/gui/src/project-view/components/ComponentBrowser/ComponentList.vue

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type { Filtering } from '@/components/ComponentBrowser/filtering'
55
import SvgIcon from '@/components/SvgIcon.vue'
66
import VirtualizedList from '@/components/VirtualizedList.vue'
77
import { groupColorStyle } from '@/composables/nodeColors'
8-
import { useSuggestionDbStore } from '@/stores/suggestionDatabase'
8+
import { GroupInfo, useSuggestionDbStore } from '@/stores/suggestionDatabase'
99
import { tryGetIndex } from '@/util/data/array'
1010
import { computed, ref, toRef, watch } from 'vue'
1111
import type { ComponentExposed } from 'vue-component-type-helpers'
@@ -48,11 +48,12 @@ watch(selectedGroupIndex, () => (selectedComponentIndex.value = 0))
4848
const suggestionDbStore = useSuggestionDbStore()
4949
const components = computed(() => makeComponentList(suggestionDbStore.entries, props.filtering))
5050
const currentGroups = computed(() => {
51-
return Array.from(components.value.keys(), (id) => ({
51+
return Array.from(components.value.entries(), ([id, components]) => ({
5252
id,
5353
...(id === 'all' ? { name: 'all' }
5454
: id === 'suggestions' ? { name: 'suggestions' }
5555
: (suggestionDbStore.groups[id] ?? { name: 'unknown' })),
56+
...(props.filtering.pattern != null ? { displayedNumber: components.length } : {}),
5657
}))
5758
})
5859
const displayedGroupId = computed(() =>
@@ -111,7 +112,9 @@ defineExpose({
111112
:debounceMouseSelection="MOUSE_SELECTION_DEBOUNCE"
112113
>
113114
<div class="groupEntry">
114-
<span class="groupEntryLabel">{{ group.name }}</span>
115+
<span class="groupEntryLabel">
116+
{{ group.name }}{{ group.displayedNumber ? ` (${group.displayedNumber})` : '' }}
117+
</span>
115118
<SvgIcon v-if="selected" class="groupEntryIcon" name="folder_closed" />
116119
</div>
117120
</VirtualizedList>

app/gui/src/project-view/components/ComponentBrowser/filtering.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ export class Filtering {
244244
public currentModule: ProjectPath | undefined = undefined,
245245
) {
246246
const { pattern, selfArg } = filter
247-
this.pattern = pattern != null ? new FilteringWithPattern(pattern) : undefined
247+
this.pattern = pattern ? new FilteringWithPattern(pattern) : undefined
248248
this.selfArg = selfArg
249249
}
250250

0 commit comments

Comments
 (0)