refactor: remove legacy permission system, use only feature-overrides
AdminPanel.jsx: - Removed ai_enabled, ai_limit_day, export_enabled UI - Kept only role selection (Admin/User) - Added link to Feature-Overrides page - Simplified perms state to only role - Changed display to show tier and email AdminUserRestrictionsPage.jsx: - Removed legacy system warning - Clean interface, no confusion Result: - ONE consistent permission system (feature-overrides) - Clear separation: role in AdminPanel, limits in Feature-Overrides - No data migration needed (no old users exist) - System ready for production Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
b1a1925360
commit
3eae7eb43f
|
|
@ -143,10 +143,7 @@ function EmailEditor({ profileId, currentEmail, onSaved }) {
|
||||||
function ProfileCard({ profile, currentId, onRefresh }) {
|
function ProfileCard({ profile, currentId, onRefresh }) {
|
||||||
const [expanded, setExpanded] = useState(false)
|
const [expanded, setExpanded] = useState(false)
|
||||||
const [perms, setPerms] = useState({
|
const [perms, setPerms] = useState({
|
||||||
ai_enabled: profile.ai_enabled ?? 1,
|
role: profile.role || 'user',
|
||||||
ai_limit_day: profile.ai_limit_day || '',
|
|
||||||
export_enabled: profile.export_enabled ?? 1,
|
|
||||||
role: profile.role || 'user',
|
|
||||||
})
|
})
|
||||||
const [saving, setSaving] = useState(false)
|
const [saving, setSaving] = useState(false)
|
||||||
const [newPin, setNewPin] = useState('')
|
const [newPin, setNewPin] = useState('')
|
||||||
|
|
@ -157,10 +154,7 @@ function ProfileCard({ profile, currentId, onRefresh }) {
|
||||||
setSaving(true)
|
setSaving(true)
|
||||||
try {
|
try {
|
||||||
await api.adminSetPermissions(profile.id, {
|
await api.adminSetPermissions(profile.id, {
|
||||||
ai_enabled: perms.ai_enabled,
|
role: perms.role,
|
||||||
ai_limit_day: perms.ai_limit_day ? parseInt(perms.ai_limit_day) : null,
|
|
||||||
export_enabled: perms.export_enabled,
|
|
||||||
role: perms.role,
|
|
||||||
})
|
})
|
||||||
await onRefresh()
|
await onRefresh()
|
||||||
} finally { setSaving(false) }
|
} finally { setSaving(false) }
|
||||||
|
|
@ -196,9 +190,8 @@ function ProfileCard({ profile, currentId, onRefresh }) {
|
||||||
{isSelf && <span style={{fontSize:10,color:'var(--text3)'}}>Du</span>}
|
{isSelf && <span style={{fontSize:10,color:'var(--text3)'}}>Du</span>}
|
||||||
</div>
|
</div>
|
||||||
<div style={{fontSize:11,color:'var(--text3)'}}>
|
<div style={{fontSize:11,color:'var(--text3)'}}>
|
||||||
KI: {profile.ai_enabled?`✓${profile.ai_limit_day?` (max ${profile.ai_limit_day}/Tag)`:''}` : '✗'} ·
|
Tier: {profile.tier || 'free'} ·
|
||||||
Export: {profile.export_enabled?'✓':'✗'} ·
|
Email: {profile.email || 'nicht gesetzt'}
|
||||||
Calls heute: {profile.ai_calls_today||0}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div style={{display:'flex',gap:6}}>
|
<div style={{display:'flex',gap:6}}>
|
||||||
|
|
@ -233,23 +226,19 @@ function ProfileCard({ profile, currentId, onRefresh }) {
|
||||||
</button>
|
</button>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
<button className="btn btn-primary btn-full" style={{marginTop:8}} onClick={savePerms} disabled={saving}>
|
||||||
|
{saving?'Speichern…':'Rolle speichern'}
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Toggle value={!!perms.ai_enabled} onChange={v=>setPerms(p=>({...p,ai_enabled:v?1:0}))} label="KI-Analysen erlaubt"/>
|
{/* Feature-Overrides */}
|
||||||
{!!perms.ai_enabled && (
|
<div style={{marginBottom:12,padding:10,background:'var(--accent-light)',borderRadius:6,fontSize:12}}>
|
||||||
<div className="form-row" style={{paddingTop:6}}>
|
<strong>Feature-Limits:</strong> Nutze die neue{' '}
|
||||||
<label className="form-label" style={{fontSize:12}}>Max. KI-Calls/Tag</label>
|
<Link to="/admin/user-restrictions" style={{color:'var(--accent-dark)',fontWeight:600}}>
|
||||||
<input type="number" className="form-input" style={{width:70}} min={1} max={100}
|
User Feature-Overrides
|
||||||
placeholder="∞" value={perms.ai_limit_day}
|
</Link>{' '}
|
||||||
onChange={e=>setPerms(p=>({...p,ai_limit_day:e.target.value}))}/>
|
Seite um individuelle Limits zu setzen.
|
||||||
<span className="form-unit" style={{fontSize:11}}>/Tag</span>
|
</div>
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
<Toggle value={!!perms.export_enabled} onChange={v=>setPerms(p=>({...p,export_enabled:v?1:0}))} label="Daten-Export erlaubt"/>
|
|
||||||
|
|
||||||
<button className="btn btn-primary btn-full" style={{marginTop:10}} onClick={savePerms} disabled={saving}>
|
|
||||||
{saving?'Speichern…':'Berechtigungen speichern'}
|
|
||||||
</button>
|
|
||||||
|
|
||||||
{/* Email */}
|
{/* Email */}
|
||||||
<div style={{marginTop:12,paddingTop:12,borderTop:'1px solid var(--border)'}}>
|
<div style={{marginTop:12,paddingTop:12,borderTop:'1px solid var(--border)'}}>
|
||||||
|
|
|
||||||
|
|
@ -252,24 +252,6 @@ export default function AdminUserRestrictionsPage() {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Legacy System Warning */}
|
|
||||||
<div style={{
|
|
||||||
padding: 12, background: '#FFF3CD', borderRadius: 8,
|
|
||||||
marginBottom: 16, fontSize: 12, color: '#856404',
|
|
||||||
display: 'flex', gap: 8, alignItems: 'flex-start',
|
|
||||||
border: '1px solid #FFE69C'
|
|
||||||
}}>
|
|
||||||
<AlertCircle size={16} style={{ marginTop: 2, flexShrink: 0 }} />
|
|
||||||
<div>
|
|
||||||
<strong>⚠️ Legacy-System aktiv:</strong> In der Benutzerverwaltung existiert noch das alte Berechtigungssystem
|
|
||||||
("KI-Analysen erlaubt", "Max. KI-Calls/Tag", "Daten-Export erlaubt").
|
|
||||||
Diese Einstellungen können mit den neuen Feature-Overrides kollidieren.
|
|
||||||
<strong> Das neue Feature-Override-System hat Vorrang.</strong>
|
|
||||||
<br/><br/>
|
|
||||||
<strong>Empfehlung:</strong> Verwende nur noch Feature-Overrides. Das alte System wird in einer zukünftigen Version entfernt.
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Messages */}
|
{/* Messages */}
|
||||||
{error && (
|
{error && (
|
||||||
<div style={{
|
<div style={{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user