Skip to content

Commit

Permalink
Add number of matched elements when filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
farmaazon committed Mar 4, 2025
1 parent 8319329 commit b97556d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ test('Filtering list', async ({ page }) => {
await expect(segments).toHaveText(['Data.', 're', 'ad', '_te', 'xt'])
const highlighted = locate.componentBrowserEntry(page).locator('.component-label-segment.match')
await expect(highlighted).toHaveText(['re', '_te'])
// Filtered-out group are hidden, and the rest displays number of matched elements.
await expect(page.locator('.groupEntry')).toHaveText(['all (1)', 'Input (1)'])
})

test('Navigating groups', async ({ page }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { Filtering } from '@/components/ComponentBrowser/filtering'
import SvgIcon from '@/components/SvgIcon.vue'
import VirtualizedList from '@/components/VirtualizedList.vue'
import { groupColorStyle } from '@/composables/nodeColors'
import { useSuggestionDbStore } from '@/stores/suggestionDatabase'
import { GroupInfo, useSuggestionDbStore } from '@/stores/suggestionDatabase'

Check warning on line 8 in app/gui/src/project-view/components/ComponentBrowser/ComponentList.vue

View workflow job for this annotation

GitHub Actions / 🧹 GUI Lint Results

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

[@typescript-eslint/no-unused-vars] 'GroupInfo' is defined but never used. Allowed unused vars must match /^_/u.

Check warning on line 8 in app/gui/src/project-view/components/ComponentBrowser/ComponentList.vue

View workflow job for this annotation

GitHub Actions / 🧹 GUI Lint Results

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

[@typescript-eslint/no-unused-vars] 'GroupInfo' is defined but never used. Allowed unused vars must match /^_/u.

Check warning on line 8 in app/gui/src/project-view/components/ComponentBrowser/ComponentList.vue

View workflow job for this annotation

GitHub Actions / 🧹 GUI Lint Results

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

[@typescript-eslint/no-unused-vars] 'GroupInfo' is defined but never used. Allowed unused vars must match /^_/u.

Check warning on line 8 in app/gui/src/project-view/components/ComponentBrowser/ComponentList.vue

View workflow job for this annotation

GitHub Actions / 🧹 GUI Lint Results

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

[@typescript-eslint/no-unused-vars] 'GroupInfo' is defined but never used. Allowed unused vars must match /^_/u.
import { tryGetIndex } from '@/util/data/array'
import { computed, ref, toRef, watch } from 'vue'
import type { ComponentExposed } from 'vue-component-type-helpers'
Expand Down Expand Up @@ -48,11 +48,12 @@ watch(selectedGroupIndex, () => (selectedComponentIndex.value = 0))
const suggestionDbStore = useSuggestionDbStore()
const components = computed(() => makeComponentList(suggestionDbStore.entries, props.filtering))
const currentGroups = computed(() => {
return Array.from(components.value.keys(), (id) => ({
return Array.from(components.value.entries(), ([id, components]) => ({
id,
...(id === 'all' ? { name: 'all' }
: id === 'suggestions' ? { name: 'suggestions' }
: (suggestionDbStore.groups[id] ?? { name: 'unknown' })),
...(props.filtering.pattern != null ? { displayedNumber: components.length } : {}),
}))
})
const displayedGroupId = computed(() =>
Expand Down Expand Up @@ -111,7 +112,9 @@ defineExpose({
:debounceMouseSelection="MOUSE_SELECTION_DEBOUNCE"
>
<div class="groupEntry">
<span class="groupEntryLabel">{{ group.name }}</span>
<span class="groupEntryLabel">
{{ group.name }}{{ group.displayedNumber ? ` (${group.displayedNumber})` : '' }}
</span>
<SvgIcon v-if="selected" class="groupEntryIcon" name="folder_closed" />
</div>
</VirtualizedList>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ export class Filtering {
public currentModule: ProjectPath | undefined = undefined,
) {
const { pattern, selfArg } = filter
this.pattern = pattern != null ? new FilteringWithPattern(pattern) : undefined
this.pattern = pattern ? new FilteringWithPattern(pattern) : undefined
this.selfArg = selfArg
}

Expand Down

0 comments on commit b97556d

Please sign in to comment.