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