Skip to content

Commit 5d3d56a

Browse files
committed
feat: show more maintainers
1 parent 9505597 commit 5d3d56a

2 files changed

Lines changed: 33 additions & 2 deletions

File tree

app/components/PackageMaintainers.vue

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,25 @@ const {
1818
const showAddOwner = shallowRef(false)
1919
const newOwnerUsername = shallowRef('')
2020
const isAdding = shallowRef(false)
21+
const showAllMaintainers = shallowRef(false)
22+
23+
const DEFAULT_VISIBLE_MAINTAINERS = 5
2124
2225
// Show admin controls when connected (let npm CLI handle permission errors)
2326
const canManageOwners = computed(() => isConnected.value)
2427
28+
// Computed for visible maintainers with show more/less support
29+
const visibleMaintainers = computed(() => {
30+
if (canManageOwners.value || showAllMaintainers.value) {
31+
return maintainerAccess.value
32+
}
33+
return maintainerAccess.value.slice(0, DEFAULT_VISIBLE_MAINTAINERS)
34+
})
35+
36+
const hiddenMaintainersCount = computed(() =>
37+
Math.max(0, maintainerAccess.value.length - DEFAULT_VISIBLE_MAINTAINERS),
38+
)
39+
2540
// Extract org name from scoped package
2641
const orgName = computed(() => {
2742
if (!props.packageName.startsWith('@')) return null
@@ -173,7 +188,7 @@ watch(
173188
</h2>
174189
<ul class="space-y-2 list-none m-0 p-0" :aria-label="$t('package.maintainers.list_label')">
175190
<li
176-
v-for="maintainer in maintainerAccess.slice(0, canManageOwners ? undefined : 5)"
191+
v-for="maintainer in visibleMaintainers"
177192
:key="maintainer.name ?? maintainer.email"
178193
class="flex items-center justify-between gap-2"
179194
>
@@ -214,6 +229,20 @@ watch(
214229
</li>
215230
</ul>
216231

232+
<!-- Show more/less toggle (only when not managing and there are hidden maintainers) -->
233+
<button
234+
v-if="!canManageOwners && hiddenMaintainersCount > 0"
235+
type="button"
236+
class="mt-2 text-xs text-fg-muted hover:text-fg transition-colors duration-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-fg/50 rounded"
237+
@click="showAllMaintainers = !showAllMaintainers"
238+
>
239+
{{
240+
showAllMaintainers
241+
? $t('package.maintainers.show_less')
242+
: $t('package.maintainers.show_more', { count: hiddenMaintainersCount })
243+
}}
244+
</button>
245+
217246
<!-- Add owner form (only when can manage) -->
218247
<div v-if="canManageOwners" class="mt-3">
219248
<div v-if="showAddOwner">

i18n/locales/en.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,9 @@
206206
"username_placeholder": "username...",
207207
"add_button": "add",
208208
"cancel_add": "Cancel adding owner",
209-
"add_owner": "+ Add owner"
209+
"add_owner": "+ Add owner",
210+
"show_more": "(show {count} more)",
211+
"show_less": "(show less)"
210212
},
211213
"downloads": {
212214
"title": "Weekly Downloads",

0 commit comments

Comments
 (0)