fix: SettingsRechte TypeScript errors fixed — entity permission types + ConfirmDialog props
This commit is contained in:
@@ -3,6 +3,7 @@ import { useTranslation } from 'react-i18next';
|
||||
import { SettingsRolesPage } from './SettingsRoles';
|
||||
import { SettingsGroupsPage } from './SettingsGroups';
|
||||
import { useAllEntityPermissions, useEntityRegistry } from '@/api/entityPermissionHooks';
|
||||
import { type EntityPermission, type EntityRegistryEntry } from '@/api/entityPermissions';
|
||||
import { useAuditLog, type AuditLogEntry } from '@/api/audit';
|
||||
import { usePermission } from '@/hooks/usePermission';
|
||||
import { Table, type TableColumn } from '@/components/ui/Table';
|
||||
@@ -19,25 +20,14 @@ import { apiDelete } from '@/api/client';
|
||||
import { Search, Trash2, Shield, Users, Share2, History } from 'lucide-react';
|
||||
import clsx from 'clsx';
|
||||
|
||||
// ─── Types ─────────────────────────────────────────────────────────────────
|
||||
// ─── Helpers ────────────────────────────────────────────────────────────────
|
||||
|
||||
interface EntityPermission {
|
||||
id: string;
|
||||
entity_type: string;
|
||||
entity_id: string;
|
||||
principal_type: string;
|
||||
principal_id: string;
|
||||
principal_name: string | null;
|
||||
permission_level: string;
|
||||
expires_at: string | null;
|
||||
created_by: string | null;
|
||||
created_at: string | null;
|
||||
function getPrincipalName(p: EntityPermission): string | null {
|
||||
return p.principal_type === 'user' ? p.user_name : p.group_name;
|
||||
}
|
||||
|
||||
interface EntityRegistryEntry {
|
||||
entity_type: string;
|
||||
display_name: string;
|
||||
description: string | null;
|
||||
function getPrincipalId(p: EntityPermission): string | null {
|
||||
return p.principal_type === 'user' ? p.user_id : p.group_id;
|
||||
}
|
||||
|
||||
// ─── Permission Level Badge ────────────────────────────────────────────────
|
||||
@@ -129,9 +119,12 @@ function FreigabenTab() {
|
||||
if (filterPrincipal) {
|
||||
const q = filterPrincipal.toLowerCase();
|
||||
items = items.filter(
|
||||
(p) =>
|
||||
(p.principal_name && p.principal_name.toLowerCase().includes(q)) ||
|
||||
p.principal_id.toLowerCase().includes(q)
|
||||
(p) => {
|
||||
const name = getPrincipalName(p);
|
||||
const id = getPrincipalId(p);
|
||||
return (name && name.toLowerCase().includes(q)) ||
|
||||
(id && id.toLowerCase().includes(q));
|
||||
}
|
||||
);
|
||||
}
|
||||
return items;
|
||||
@@ -162,12 +155,16 @@ function FreigabenTab() {
|
||||
{
|
||||
key: 'principal_type',
|
||||
header: 'Principal',
|
||||
render: (row) => (
|
||||
render: (row) => {
|
||||
const name = getPrincipalName(row);
|
||||
const id = getPrincipalId(row);
|
||||
return (
|
||||
<div className="flex items-center gap-2">
|
||||
<PrincipalTypeBadge type={row.principal_type} />
|
||||
<span>{row.principal_name || row.principal_id.slice(0, 8) + '…'}</span>
|
||||
<span>{name || (id ? id.slice(0, 8) + '…' : '—')}</span>
|
||||
</div>
|
||||
),
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
key: 'permission_level',
|
||||
@@ -251,7 +248,7 @@ function FreigabenTab() {
|
||||
{confirmDelete && (
|
||||
<ConfirmDialog
|
||||
open={!!confirmDelete}
|
||||
onClose={() => setConfirmDelete(null)}
|
||||
onCancel={() => setConfirmDelete(null)}
|
||||
onConfirm={handleDelete}
|
||||
title="Berechtigung löschen"
|
||||
message={`Soll die Berechtigung für ${entityTypeMap.get(confirmDelete.entity_type) || confirmDelete.entity_type} wirklich gelöscht werden?`}
|
||||
|
||||
Reference in New Issue
Block a user