admin/accounts: button to delete all members of a group

Massimo Melina committed Feb 22, 2025 at 17:38 UTC 28441dd22e67271363938ad5eb50d95ca3a32e61
1 file changed +8 -2
admin/src/AccountForm.ts
+8 -2
@@ -6,7 +6,7 @@ import { Alert, Box } from '@mui/material'
6 import { apiCall } from './api'
7 import { alertDialog, useDialogBarColors } from './dialog'
8 import { formatTimestamp, isEqualLax, prefix, reactJoin, useIsMobile, wantArray } from './misc'
9 -import { IconBtn, NetmaskField, propsForModifiedValues, WildcardsSupported } from './mui'
9 +import { Btn, IconBtn, NetmaskField, propsForModifiedValues, WildcardsSupported } from './mui'
10 import { Account } from './AccountsPage'
11 import { createVerifierAndSalt, SRPParameters, SRPRoutines } from 'tssrp6a'
12 import { AutoDelete, Delete } from '@mui/icons-material'
@@ -82,7 +82,13 @@ export default function AccountForm({ account, done, groups, addToBar, reload }:
82 !members ? null
83 : isGroup && !members.length ? h(Box, {}, "No members")
84 : members.length > 0 && h(Box, {}, `${members.length} members: `,
85 - reactJoin(', ', account.members?.map((u: string) => h(groups.includes(u) ? 'i' : 'span', {}, u))) ),
85 + reactJoin(', ', account.members?.map(u => h(groups.includes(u) ? 'i' : 'span', {}, u))),
86 + h(Btn, {
87 + icon: Delete,
88 + confirm: `Delete ${account.members.length} accounts?`,
89 + onClick: () => Promise.all(account.members.map(u => apiCall('del_account', { username: u }))).finally(reload)
90 + }),
91 + ),
92 isGroup && h(Alert, { severity: 'info' }, `To add users to this group, select the user and then click "Inherit"`),
93 { k: 'belongs', comp: MultiSelectField, label: "Inherit from groups", options: belongsOptions, sm: 6,
94 helperText: "Specify groups to inherit permissions from"