admin/accounts: preview account.belongs

Massimo Melina committed Mar 2, 2022 at 23:25 UTC e57e5563a3faa62b28e44924e58c292168ffa3e1
2 files changed +11 -4
admin/src/AccountsPage.ts
+7 -1
@@ -25,6 +25,7 @@ interface Account {
25 hasPassword?: boolean
26 ignore_limits?: boolean
27 redirect?: string
28 + belongs?: string[]
29 }
30
31 export default function AccountsPage() {
@@ -89,7 +90,12 @@ export default function AccountsPage() {
90 h(TreeItem, {
91 key: ac.username,
92 nodeId: ac.username,
92 - label: h('div', { className: styles.label }, account2icon(ac), ac.username ),
93 + label: h('div', { className: styles.label },
94 + account2icon(ac),
95 + ac.username,
96 + Boolean(ac.belongs?.length) && h(Box, { sx: { color: 'text.secondary', fontSize: 'small' } },
97 + '(', ac.belongs?.join(', '), ')')
98 + ),
99 })
100 )
101 )
src/perm.ts
+4 -3
@@ -74,9 +74,10 @@ export async function updateAccount(account: Account, changer?:Changer) {
74 console.log('please reset password for account', username)
75 process.exit(1)
76 }
77 - account.belongs = wantArray(account.belongs).filter(b =>
78 - b in accounts // at this stage the group record may still be null if specified later in the file
79 - || console.error(`account ${username} belongs to non-existing ${b}`) )
77 + if (account.belongs)
78 + account.belongs = wantArray(account.belongs).filter(b =>
79 + b in accounts // at this stage the group record may still be null if specified later in the file
80 + || console.error(`account ${username} belongs to non-existing ${b}`) )
81 if (was !== JSON.stringify(account))
82 saveAccountsAsap()
83 }