Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 46 additions & 4 deletions app/components/PackageMaintainers.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,25 @@ const {
const showAddOwner = shallowRef(false)
const newOwnerUsername = shallowRef('')
const isAdding = shallowRef(false)
const showAllMaintainers = shallowRef(false)

const DEFAULT_VISIBLE_MAINTAINERS = 5

// Show admin controls when connected (let npm CLI handle permission errors)
const canManageOwners = computed(() => isConnected.value)

// Computed for visible maintainers with show more/fewer support
const visibleMaintainers = computed(() => {
if (canManageOwners.value || showAllMaintainers.value) {
return maintainerAccess.value
}
return maintainerAccess.value.slice(0, DEFAULT_VISIBLE_MAINTAINERS)
})

const hiddenMaintainersCount = computed(() =>
Math.max(0, maintainerAccess.value.length - DEFAULT_VISIBLE_MAINTAINERS),
)

// Extract org name from scoped package
const orgName = computed(() => {
if (!props.packageName.startsWith('@')) return null
Expand Down Expand Up @@ -173,14 +188,17 @@ watch(
</h2>
<ul class="space-y-2 list-none m-0 p-0" :aria-label="$t('package.maintainers.list_label')">
<li
v-for="maintainer in maintainerAccess.slice(0, canManageOwners ? undefined : 5)"
v-for="maintainer in visibleMaintainers"
:key="maintainer.name ?? maintainer.email"
class="flex items-center justify-between gap-2"
>
<div class="flex items-center gap-2 min-w-0">
<NuxtLink
v-if="maintainer.name"
:to="{ name: '~username', params: { username: maintainer.name } }"
:to="{
name: '~username',
params: { username: maintainer.name },
}"
class="link-subtle font-mono text-sm shrink-0"
>
@{{ maintainer.name }}
Expand All @@ -192,7 +210,11 @@ watch(
v-if="isConnected && maintainer.accessVia?.length && !isLoadingAccess"
class="text-xs text-fg-subtle truncate"
>
{{ $t('package.maintainers.via', { teams: maintainer.accessVia.join(', ') }) }}
{{
$t('package.maintainers.via', {
teams: maintainer.accessVia.join(', '),
})
}}
</span>
<span
v-if="canManageOwners && maintainer.name === npmUser"
Expand All @@ -206,14 +228,34 @@ watch(
v-if="canManageOwners && maintainer.name && maintainer.name !== npmUser"
type="button"
class="p-1 text-fg-subtle hover:text-red-400 transition-colors duration-200 shrink-0 rounded focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-fg/50"
:aria-label="$t('package.maintainers.remove_owner', { name: maintainer.name })"
:aria-label="
$t('package.maintainers.remove_owner', {
name: maintainer.name,
})
"
@click="handleRemoveOwner(maintainer.name)"
>
<span class="i-carbon-close block w-3.5 h-3.5" aria-hidden="true" />
</button>
</li>
</ul>

<!-- Show more/less toggle (only when not managing and there are hidden maintainers) -->
<button
v-if="!canManageOwners && hiddenMaintainersCount > 0"
type="button"
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"
@click="showAllMaintainers = !showAllMaintainers"
>
{{
showAllMaintainers
? $t('package.maintainers.show_less')
: $t('package.maintainers.show_more', {
count: hiddenMaintainersCount,
})
}}
</button>

<!-- Add owner form (only when can manage) -->
<div v-if="canManageOwners" class="mt-3">
<div v-if="showAddOwner">
Expand Down
4 changes: 3 additions & 1 deletion i18n/locales/de-DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,9 @@
"username_placeholder": "Benutzername...",
"add_button": "Hinzufügen",
"cancel_add": "Owner-Hinzufügung abbrechen",
"add_owner": "+ Owner hinzufügen"
"add_owner": "+ Owner hinzufügen",
"show_more": "({count} weitere anzeigen)",
"show_less": "(weniger anzeigen)"
},
"downloads": {
"title": "Wöchentliche Downloads",
Expand Down
4 changes: 3 additions & 1 deletion i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,9 @@
"username_placeholder": "username...",
"add_button": "add",
"cancel_add": "Cancel adding owner",
"add_owner": "+ Add owner"
"add_owner": "+ Add owner",
"show_more": "(show {count} more)",
"show_less": "(show fewer)"
},
"downloads": {
"title": "Weekly Downloads",
Expand Down
4 changes: 3 additions & 1 deletion i18n/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,9 @@
"username_placeholder": "nombre de usuario...",
"add_button": "agregar",
"cancel_add": "Cancelar agregar propietario",
"add_owner": "+ Agregar propietario"
"add_owner": "+ Agregar propietario",
"show_more": "(mostrar {count} más)",
"show_less": "(mostrar menos)"
},
"downloads": {
"title": "Descargas Semanales",
Expand Down
4 changes: 3 additions & 1 deletion i18n/locales/fr-FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,9 @@
"username_placeholder": "nom d'utilisateur...",
"add_button": "ajouter",
"cancel_add": "Annuler l'ajout de propriétaire",
"add_owner": "+ Ajouter un propriétaire"
"add_owner": "+ Ajouter un propriétaire",
"show_more": "(afficher {count} de plus)",
"show_less": "(afficher moins)"
},
"downloads": {
"title": "Téléchargements hebdomadaires",
Expand Down
4 changes: 3 additions & 1 deletion i18n/locales/it-IT.json
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,9 @@
"username_placeholder": "nome utente...",
"add_button": "aggiungi",
"cancel_add": "Cancella aggiunta proprietario",
"add_owner": "+ Aggiungi proprietario"
"add_owner": "+ Aggiungi proprietario",
"show_more": "(mostra altri {count})",
"show_less": "(mostra meno)"
},
"downloads": {
"title": "Downloads settimanali",
Expand Down
4 changes: 3 additions & 1 deletion i18n/locales/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,9 @@
"username_placeholder": "ユーザー名...",
"add_button": "追加",
"cancel_add": "オーナーの追加をキャンセル",
"add_owner": "+ オーナーを追加"
"add_owner": "+ オーナーを追加",
"show_more": "(他 {count} 個を表示)",
"show_less": "(折りたたむ)"
},
"downloads": {
"title": "週間ダウンロード数",
Expand Down
4 changes: 3 additions & 1 deletion i18n/locales/zh-CN.json
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@9romise I tried my best to get these right, let me know if you think the translations could be improved. I am better at romance langs haha

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never mind. I think it's perfect! ❤️

Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,9 @@
"username_placeholder": "用户名...",
"add_button": "添加",
"cancel_add": "取消添加拥有者",
"add_owner": "+ 添加拥有者"
"add_owner": "+ 添加拥有者",
"show_more": "(显示另外 {count} 个)",
"show_less": "(收起)"
},
"downloads": {
"title": "每周下载量",
Expand Down
4 changes: 3 additions & 1 deletion lunaria/files/de-DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,9 @@
"username_placeholder": "Benutzername...",
"add_button": "Hinzufügen",
"cancel_add": "Owner-Hinzufügung abbrechen",
"add_owner": "+ Owner hinzufügen"
"add_owner": "+ Owner hinzufügen",
"show_more": "({count} weitere anzeigen)",
"show_less": "(weniger anzeigen)"
},
"downloads": {
"title": "Wöchentliche Downloads",
Expand Down
4 changes: 3 additions & 1 deletion lunaria/files/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,9 @@
"username_placeholder": "username...",
"add_button": "add",
"cancel_add": "Cancel adding owner",
"add_owner": "+ Add owner"
"add_owner": "+ Add owner",
"show_more": "(show {count} more)",
"show_less": "(show fewer)"
},
"downloads": {
"title": "Weekly Downloads",
Expand Down
4 changes: 3 additions & 1 deletion lunaria/files/es-419.json
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,9 @@
"username_placeholder": "nombre de usuario...",
"add_button": "agregar",
"cancel_add": "Cancelar agregar propietario",
"add_owner": "+ Agregar propietario"
"add_owner": "+ Agregar propietario",
"show_more": "(mostrar {count} más)",
"show_less": "(mostrar menos)"
},
"downloads": {
"title": "Descargas Semanales",
Expand Down
4 changes: 3 additions & 1 deletion lunaria/files/es-ES.json
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,9 @@
"username_placeholder": "nombre de usuario...",
"add_button": "agregar",
"cancel_add": "Cancelar agregar propietario",
"add_owner": "+ Agregar propietario"
"add_owner": "+ Agregar propietario",
"show_more": "(mostrar {count} más)",
"show_less": "(mostrar menos)"
},
"downloads": {
"title": "Descargas Semanales",
Expand Down
4 changes: 3 additions & 1 deletion lunaria/files/fr-FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,9 @@
"username_placeholder": "nom d'utilisateur...",
"add_button": "ajouter",
"cancel_add": "Annuler l'ajout de propriétaire",
"add_owner": "+ Ajouter un propriétaire"
"add_owner": "+ Ajouter un propriétaire",
"show_more": "(afficher {count} de plus)",
"show_less": "(afficher moins)"
},
"downloads": {
"title": "Téléchargements hebdomadaires",
Expand Down
4 changes: 3 additions & 1 deletion lunaria/files/it-IT.json
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,9 @@
"username_placeholder": "nome utente...",
"add_button": "aggiungi",
"cancel_add": "Cancella aggiunta proprietario",
"add_owner": "+ Aggiungi proprietario"
"add_owner": "+ Aggiungi proprietario",
"show_more": "(mostra altri {count})",
"show_less": "(mostra meno)"
},
"downloads": {
"title": "Downloads settimanali",
Expand Down
4 changes: 3 additions & 1 deletion lunaria/files/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,9 @@
"username_placeholder": "ユーザー名...",
"add_button": "追加",
"cancel_add": "オーナーの追加をキャンセル",
"add_owner": "+ オーナーを追加"
"add_owner": "+ オーナーを追加",
"show_more": "(他 {count} 個を表示)",
"show_less": "(折りたたむ)"
},
"downloads": {
"title": "週間ダウンロード数",
Expand Down
4 changes: 3 additions & 1 deletion lunaria/files/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,9 @@
"username_placeholder": "用户名...",
"add_button": "添加",
"cancel_add": "取消添加拥有者",
"add_owner": "+ 添加拥有者"
"add_owner": "+ 添加拥有者",
"show_more": "(显示另外 {count} 个)",
"show_less": "(收起)"
},
"downloads": {
"title": "每周下载量",
Expand Down