// LDAP 用户导入弹窗(OU 选择 + 用户列表多选 + 导入结果) // Logan.Li import { Button } from '@/components/ui/button'; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from '@/components/ui/table'; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from '@/components/ui/dialog'; import { Network, Loader2, RefreshCw, CheckCircle, XCircle } from 'lucide-react'; interface LdapImportDialogProps { importDialogOpen: 'csv' | 'ldap' | null; setImportDialogOpen: (v: 'csv' | 'ldap' | null) => void; ldapUsers: any[]; setLdapUsers: ( u: any[]) => void; ldapSelected: Set; setLdapSelected: (s: Set) => void; ldapLoading: boolean; ldapImportOUs: any[]; ldapImportOUDN: string; setLdapImportOUDN: (v: string) => void; loadLdapUsers: (ouDn?: string) => void; handleLdapImport: () => void; importing: boolean; importResult: any; setImportResult: ( r: any) => void; } // LdapImportDialog 展示 LDAP 用户检索和多选导入流程 // Logan.Li export function LdapImportDialog({ importDialogOpen, setImportDialogOpen, ldapUsers, setLdapUsers, ldapSelected, setLdapSelected, ldapLoading, ldapImportOUs, ldapImportOUDN, setLdapImportOUDN, loadLdapUsers, handleLdapImport, importing, importResult, setImportResult, }: LdapImportDialogProps) { return ( !v && setImportDialogOpen(null)}> 从 LDAP 导入用户 从 LDAP 服务器检索用户列表,选择需要导入的用户 {!importResult ? ( <>
选择 OU

{ldapUsers.length > 0 ? `找到 ${ldapUsers.length} 个用户` : '选择 OU 或点击刷新获取用户列表'}

{ldapUsers.length > 0 && (
0} onChange={(e) => { if (e.target.checked) { setLdapSelected(new Set(ldapUsers.map((u) => u.dn))); } else { setLdapSelected(new Set()); } }} /> 用户名 显示名 邮箱 DN {ldapUsers.map((u) => ( { const next = new Set(ldapSelected); if (e.target.checked) next.add(u.dn); else next.delete(u.dn); setLdapSelected(next); }} /> {u.uid} {u.cn} {u.mail} {u.dn} ))}
)}
) : (
{importResult.code === 200 ? ( ) : ( )} {importResult.message}
)}
); }