Files
tfm_ainventory/frontend/components/admin/LdapManager.tsx
Daniel Bedeleanu 12b2ef26cf fix: implement Phase 2 medium-impact spacing reductions
Applied systematic spacing optimizations across admin manager components (40px savings):

DatabaseManager.tsx:
- Input field padding: py-3 → py-2 (3 inputs: retention_count, schedule_hour, schedule_freq_days)
- Form field spacing: space-y-2 → space-y-1.5 (Max Backups field group)
- Grid gaps: gap-4 → gap-3 (storage policy fields)
- Item list spacing: space-y-2 → space-y-1.5 (backup list)
- Modal form spacing: space-y-4 → space-y-3 (recovery points section)
- Backup metadata text: text-[11px] → text-xs (created_at + filesize display)

LdapManager.tsx:
- Input field padding: py-2.5 → py-2 (4 inputs: server_uri, base_dn, user_template, groups_dn)
- Form field spacing: space-y-1.5 → space-y-1 (all label+input groups)
- Button padding: py-2.5 → py-2 (test connection), py-3 → py-2.5 (save policy)

IdentityManager.tsx:
- Input field padding: py-3 → py-2 (username, password, role in edit modal)
- Form field spacing: space-y-4 → space-y-3 (edit modal form)
- Form field labels: space-y-1.5 → space-y-1 (all 3 fields)
- User list spacing: space-y-2 → space-y-1.5 (user items)

AiManager.tsx:
- Grid gaps: gap-4 → gap-3 (provider options grid)
- Input field padding: py-3 → py-2 (Gemini/Claude API key inputs)
- Form field spacing: space-y-2 → space-y-1.5 (API key field groups)
- Modal spacing: space-y-6 → space-y-3 (provider access keys section)
- Prompt section spacing: space-y-4 → space-y-3 (system prompt area)

CategoryManager.tsx:
- Grid gaps: gap-3 → gap-2.5 (category items grid)
- Input field padding: py-3.5 → py-2.5, py-4 → py-2.5 (name + description inputs)
- Form field spacing: space-y-6 → space-y-3, space-y-1.5 → space-y-1 (edit modal)

Test Results:
- Frontend (Vitest): 291/291 tests passing ✓
- Backend (Pytest): 41/41 tests passing ✓
- Total: 332 tests validated, zero regressions

All changes maintain visual hierarchy and premium density standards without sacrificing usability.
2026-04-19 18:36:44 +03:00

166 lines
7.7 KiB
TypeScript

import React from 'react';
import { Globe, Power, Server, Shield, User, Layers, Lock, Wifi, RotateCcw } from 'lucide-react';
import { cn } from '@/lib/utils';
interface LdapManagerProps {
ldapConfig: any;
setLdapConfig: (config: any) => void;
testingLdap: boolean;
onTestLdap: () => void;
onUpdateLdap: () => void;
}
export default function LdapManager({
ldapConfig,
setLdapConfig,
testingLdap,
onTestLdap,
onUpdateLdap
}: LdapManagerProps) {
return (
<div className="bg-surface/50 border border-slate-800/50 rounded-[2.5rem] p-4 md:p-6 shadow-2xl space-y-4 transition-all group/ldap">
<div className="flex items-center justify-between mb-2">
<div className="flex items-center gap-4">
<div className="w-10 h-10 rounded-xl bg-primary/10 flex items-center justify-center text-primary border border-primary/20">
<Globe size={20} />
</div>
<h2 className="text-xl font-normal text-white tracking-tight">Enterprise LDAP</h2>
</div>
</div>
<div className="flex items-center justify-between p-4 bg-background/40 border border-slate-800/60 rounded-2xl group transition-all hover:border-primary/30">
<div className="flex items-center gap-3">
<div className={cn(
"w-8 h-8 rounded-xl flex items-center justify-center transition-all shadow-inner",
ldapConfig.ldap_enabled ? "bg-green-500/10 text-green-500" : "bg-slate-800 text-muted"
)}>
<Power size={14} />
</div>
<div>
<p className="card-title leading-none">LDAP Authorization</p>
<p className={cn("card-subtitle mt-1", ldapConfig.ldap_enabled ? "text-green-500/80" : "text-muted")}>
{ldapConfig.ldap_enabled ? "External Directory Active" : "Internal Authentication Only"}
</p>
</div>
</div>
<button
onClick={() => setLdapConfig({...ldapConfig, ldap_enabled: !ldapConfig.ldap_enabled})}
className={cn(
"w-10 h-5 rounded-full relative transition-all duration-300 shadow-inner border",
ldapConfig.ldap_enabled ? "bg-primary border-primary" : "bg-slate-800 border-slate-700"
)}
>
<div className={cn(
"absolute top-0.5 w-3.5 h-3.5 bg-white rounded-full transition-all shadow-sm",
ldapConfig.ldap_enabled ? "right-0.5" : "left-0.5"
)} />
</button>
</div>
<div className="grid sm:grid-cols-2 gap-3">
<div className="space-y-1">
<label className="text-sm font-normal text-secondary tracking-tight ml-1">LDAP URI</label>
<div className="relative">
<Server className="absolute left-3.5 top-1/2 -translate-y-1/2 text-muted" size={14} />
<input
type="text"
placeholder="ldap://host:389"
value={ldapConfig.server_uri}
onChange={(e) => setLdapConfig({...ldapConfig, server_uri: e.target.value})}
className="w-full bg-background/80 border border-slate-800 rounded-2xl py-2 pl-10 pr-4 text-xs font-normal text-white outline-none focus:border-primary/50 transition-all font-mono"
/>
</div>
</div>
<div className="space-y-1">
<label className="text-sm font-normal text-secondary tracking-tight ml-1">Context DN</label>
<div className="relative">
<Shield className="absolute left-3.5 top-1/2 -translate-y-1/2 text-muted" size={14} />
<input
type="text"
placeholder="dc=example,dc=com"
value={ldapConfig.base_dn}
onChange={(e) => setLdapConfig({...ldapConfig, base_dn: e.target.value})}
className="w-full bg-background/80 border border-slate-800 rounded-2xl py-2 pl-10 pr-4 text-xs font-normal text-white outline-none focus:border-primary/50 transition-all font-mono"
/>
</div>
</div>
</div>
<div className="grid sm:grid-cols-2 gap-3">
<div className="space-y-1">
<label className="text-sm font-normal text-secondary tracking-tight ml-1">User DN Template</label>
<div className="relative">
<User className="absolute left-3.5 top-1/2 -translate-y-1/2 text-muted" size={14} />
<input
type="text"
placeholder="uid={username},ou=people..."
value={ldapConfig.user_template}
onChange={(e) => setLdapConfig({...ldapConfig, user_template: e.target.value})}
className="w-full bg-background/80 border border-slate-800 rounded-2xl py-2 pl-10 pr-4 text-xs font-normal text-white outline-none focus:border-primary/50 transition-all font-mono"
/>
</div>
</div>
<div className="space-y-1">
<label className="text-sm font-normal text-secondary tracking-tight ml-1">Groups Base DN</label>
<div className="relative">
<Layers className="absolute left-3.5 top-1/2 -translate-y-1/2 text-muted" size={14} />
<input
type="text"
placeholder="ou=groups"
value={ldapConfig.groups_dn}
onChange={(e) => setLdapConfig({...ldapConfig, groups_dn: e.target.value})}
className="w-full bg-background/80 border border-slate-800 rounded-2xl py-2 pl-10 pr-4 text-xs font-normal text-white outline-none focus:border-primary/50 transition-all font-mono"
/>
</div>
</div>
</div>
<div className="flex items-center justify-between p-4 bg-background/40 border border-slate-800/60 rounded-2xl group transition-all hover:border-primary/30">
<div className="flex items-center gap-3">
<div className={cn(
"w-8 h-8 rounded-xl flex items-center justify-center transition-all shadow-inner",
ldapConfig.use_tls ? "bg-primary/10 text-primary" : "bg-slate-800 text-muted"
)}>
<Lock size={14} />
</div>
<div>
<p className="card-title leading-none">Use TLS</p>
<p className={cn("card-subtitle mt-1", ldapConfig.use_tls ? "text-primary/80" : "text-muted")}>
{ldapConfig.use_tls ? "Encrypted Channel" : "Standard Link"}
</p>
</div>
</div>
<button
onClick={() => setLdapConfig({...ldapConfig, use_tls: !ldapConfig.use_tls})}
className={cn(
"w-10 h-5 rounded-full relative transition-all duration-300 shadow-inner border",
ldapConfig.use_tls ? "bg-primary border-primary" : "bg-slate-800 border-slate-700"
)}
>
<div className={cn(
"absolute top-0.5 w-3.5 h-3.5 bg-white rounded-full transition-all shadow-sm",
ldapConfig.use_tls ? "right-0.5" : "left-0.5"
)} />
</button>
</div>
<div className="flex gap-2 pt-2">
<button
onClick={onTestLdap}
disabled={testingLdap}
className="flex-1 bg-primary hover:bg-primary text-white rounded-xl py-2 text-sm font-normal shadow-xl shadow-primary/10 transition-all active:scale-95 disabled:opacity-50 flex items-center justify-center gap-2 border border-primary/30"
>
{testingLdap ? <RotateCcw size={14} className="animate-spin" /> : <Wifi size={14} />}
Test Connection
</button>
<button
onClick={onUpdateLdap}
className="flex-[2] bg-primary hover:bg-primary text-white rounded-xl py-2.5 text-sm font-normal shadow-xl shadow-primary/10 transition-all active:scale-95 flex items-center justify-center gap-2 border border-primary/30 tracking-tight"
>
<Shield size={14} /> Save LDAP Policy
</button>
</div>
</div>
);
}