Skip to content

Commit 71116e8

Browse files
fix(ui): replace "yolo" mode with npm API max of 250 results (#1922)
1 parent bf12be0 commit 71116e8

34 files changed

+30
-63
lines changed

app/components/Package/List.vue

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,18 +75,15 @@ const paginationMode = computed(() =>
7575
)
7676
const currentPage = computed(() => props.currentPage ?? 1)
7777
const pageSize = computed(() => props.pageSize ?? 25)
78-
// Numeric page size for virtual scroll and arithmetic (when 'all' is selected, use 25 as default)
79-
const numericPageSize = computed(() => (pageSize.value === 'all' ? 25 : pageSize.value))
78+
// Numeric page size for virtual scroll and arithmetic (use 25 as default)
79+
const numericPageSize = computed(() => pageSize.value)
8080
8181
// Compute paginated results for paginated mode
8282
const displayedResults = computed(() => {
8383
if (paginationMode.value === 'infinite') {
8484
return props.results
8585
}
86-
// 'all' page size means show everything (YOLO)
87-
if (pageSize.value === 'all') {
88-
return props.results
89-
}
86+
9087
const start = (currentPage.value - 1) * numericPageSize.value
9188
const end = start + numericPageSize.value
9289
return props.results.slice(start, end)

app/components/Package/ListToolbar.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ function getSortKeyLabelKey(key: SortKey): string {
147147
$t(
148148
'filters.count.showing_paginated',
149149
{
150-
pageSize: pageSize === 'all' ? $n(filteredCount) : Math.min(pageSize, filteredCount),
150+
pageSize: Math.min(pageSize, filteredCount),
151151
count: $n(filteredCount),
152152
},
153153
filteredCount,

app/components/PaginationControls.vue

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,17 @@ const effectiveMode = computed<PaginationMode>(() =>
2222
shouldShowControls.value ? 'paginated' : 'infinite',
2323
)
2424
25-
// When 'all' is selected, there's only 1 page with everything
26-
const isShowingAll = computed(() => pageSize.value === 'all')
27-
const totalPages = computed(() =>
28-
isShowingAll.value ? 1 : Math.ceil(props.totalItems / (pageSize.value as number)),
29-
)
25+
const totalPages = computed(() => Math.ceil(props.totalItems / (pageSize.value as number)))
3026
3127
// Whether to show the mode toggle (hidden in table view since table always uses pagination)
3228
const showModeToggle = computed(() => props.viewMode !== 'table')
3329
3430
const startItem = computed(() => {
3531
if (props.totalItems === 0) return 0
36-
if (isShowingAll.value) return 1
3732
return (currentPage.value - 1) * (pageSize.value as number) + 1
3833
})
3934
4035
const endItem = computed(() => {
41-
if (isShowingAll.value) return props.totalItems
4236
return Math.min(currentPage.value * (pageSize.value as number), props.totalItems)
4337
})
4438
@@ -106,8 +100,8 @@ const visiblePages = computed(() => {
106100
function handlePageSizeChange(event: Event) {
107101
const target = event.target as HTMLSelectElement
108102
const value = target.value
109-
// Handle 'all' as a special string value, otherwise parse as number
110-
const newSize = (value === 'all' ? 'all' : Number(value)) as PageSize
103+
104+
const newSize = Number(value) as PageSize
111105
pageSize.value = newSize
112106
// Reset to page 1 when changing page size
113107
currentPage.value = 1
@@ -159,10 +153,7 @@ function handlePageSizeChange(event: Event) {
159153
@change="handlePageSizeChange"
160154
:items="
161155
PAGE_SIZE_OPTIONS.map(size => ({
162-
label:
163-
size === 'all'
164-
? $t('filters.pagination.all_yolo')
165-
: $t('filters.pagination.per_page', { count: size }),
156+
label: $t('filters.pagination.per_page', { count: size }),
166157
value: String(size),
167158
}))
168159
"

app/composables/usePackageListPreferences.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,22 @@ export function usePackageListPreferences() {
4141
},
4242
})
4343

44+
// One-time migration: replace legacy 'all' with the current maximum page size
45+
watch(
46+
isHydrated,
47+
hydrated => {
48+
if (!hydrated) {
49+
return
50+
}
51+
52+
if ((preferences.value.pageSize as unknown) === 'all') {
53+
preferences.value.pageSize = Math.max(...PAGE_SIZE_OPTIONS) as PageSize
54+
save()
55+
}
56+
},
57+
{ immediate: true },
58+
)
59+
4460
const pageSize = computed({
4561
get: () => preferences.value.pageSize,
4662
set: (value: PageSize) => {

app/pages/org/[org].vue

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,7 @@ const currentPage = shallowRef(1)
6565
6666
// Calculate total pages
6767
const totalPages = computed(() => {
68-
if (pageSize.value === 'all') return 1
69-
const numericSize = typeof pageSize.value === 'number' ? pageSize.value : 25
70-
return Math.ceil(sortedPackages.value.length / numericSize)
68+
return Math.ceil(sortedPackages.value.length / pageSize.value)
7169
})
7270
7371
// Reset to page 1 when filters change

app/pages/search.vue

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,7 @@ const EAGER_LOAD_SIZE = { algolia: 500, npm: 500 } as const
164164
165165
// Calculate how many results we need based on current page and preferred page size
166166
const requestedSize = computed(() => {
167-
const numericPrefSize = preferredPageSize.value === 'all' ? 250 : preferredPageSize.value
168-
const base = Math.max(pageSize, currentPage.value * numericPrefSize)
167+
const base = Math.max(pageSize, currentPage.value * preferredPageSize.value)
169168
// When sorting by something other than relevance, fetch a large batch
170169
// so client-side sorting operates on a meaningful pool of matching results
171170
if (!isRelevanceSort.value) {
@@ -587,10 +586,8 @@ const rawLiveRegionMessage = computed(() => {
587586
588587
if (visibleResults.value && displayResults.value.length > 0) {
589588
if (viewMode.value === 'table' || paginationMode.value === 'paginated') {
590-
const pSize =
591-
preferredPageSize.value === 'all'
592-
? $n(effectiveTotal.value)
593-
: Math.min(preferredPageSize.value, effectiveTotal.value)
589+
const pSize = Math.min(preferredPageSize.value, effectiveTotal.value)
590+
594591
return $t(
595592
'filters.count.showing_paginated',
596593
{
@@ -781,10 +778,7 @@ onBeforeUnmount(() => {
781778
$t(
782779
'filters.count.showing_paginated',
783780
{
784-
pageSize:
785-
preferredPageSize === 'all'
786-
? $n(effectiveTotal)
787-
: Math.min(preferredPageSize, effectiveTotal),
781+
pageSize: Math.min(preferredPageSize, effectiveTotal),
788782
count: $n(effectiveTotal),
789783
},
790784
effectiveTotal,

i18n/locales/ar.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,6 @@
768768
"paginated": "مقسم إلى صفحات",
769769
"items_per_page": "عدد العناصر في الصفحة",
770770
"per_page": "{count} / صفحة",
771-
"all_yolo": "الكل (إنما هي حياة واحدة)",
772771
"showing": "{start}-{end} من {total}",
773772
"previous": "الصفحة السابقة",
774773
"next": "الصفحة التالية",

i18n/locales/az-AZ.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,6 @@
850850
"paginated": "Səhifələnmiş",
851851
"items_per_page": "Səhifə başına element",
852852
"per_page": "{count} / səhifə",
853-
"all_yolo": "Hamısı (YOLO)",
854853
"showing": "{start}-{end} / {total}",
855854
"previous": "Əvvəlki səhifə",
856855
"next": "Növbəti səhifə",

i18n/locales/bg-BG.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,6 @@
841841
"paginated": "Със страници",
842842
"items_per_page": "Елементи на страница",
843843
"per_page": "{count} / страница",
844-
"all_yolo": "Всички (YOLO)",
845844
"showing": "{start}-{end} от {total}",
846845
"previous": "Предишна страница",
847846
"next": "Следваща страница",

i18n/locales/bn-IN.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,6 @@
654654
"paginated": "পাতায়িত",
655655
"items_per_page": "প্রতি পাতায় আইটেম",
656656
"per_page": "{count} / পাতায়",
657-
"all_yolo": "সব (YOLO)",
658657
"showing": "{total} এর মধ্যে {start}-{end}",
659658
"previous": "আগের পাতা",
660659
"next": "পরের পাতা",

0 commit comments

Comments
 (0)