mirror of
https://github.com/Moepchi/webspeak3.git
synced 2026-12-01 00:42:49 +08:00
Add read-only permission overview ("Eigene Rechte anzeigen")
Partial progress on #71 (full permissions editor). A genuine full editor - server/channel/group permission grids across 5 permission scopes with add/remove/modify for hundreds of possible permissions - is a much bigger undertaking than fits in one pass, so this lands a real, useful slice of it first: a read-only view of the caller's own effective permissions in their current channel. - Connector: "permoverview" (raw command, no typed builder exists) requests the caller's effective permission set for cid+cldbid. Permission IDs are opaque numeric values server-side, so results are name-resolved via a "permissionlist" id->name/description lookup that's fetched once and cached for the connection's lifetime. The two requests are chained (list first, overview second) with buffering in case the overview reply somehow arrives first. - Gateway: typed passthrough for the merged, name-resolved entries. - Frontend: new dialog wired to "Eigene Rechte anzeigen" in the Rechte menu (previously disabled) - a filterable table of permission name/value/negated/skip. Verified against the real server: initially got a clean "ParameterNotFound" error revealing that permoverview needs an explicit permid=0 ("all permissions") even though tsclientlib's generated type treats it as optional; after adding that argument the command reaches the server correctly and returns the expected permission-denied response for the guest test account (same pattern as every other admin-gated feature this session). The remaining scope of #71 - editable server-group/channel-group/ channel/client permission grids - is unchanged and left for later. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0f8576ac6c
commit
41ac845fbc
7 files changed
+305
-3
No files matched your search
@@ -1148,6 +1148,15 @@
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.ts-permission-overview-dialog {
|
||||
width: 640px;
|
||||
}
|
||||
|
||||
.ts-permission-overview-scroll {
|
||||
max-height: 400px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.ts-server-protocol-log-line {
|
||||
padding: 0.15rem 0.4rem;
|
||||
border-bottom: 1px solid var(--border-soft);
|
||||
|
||||
+113
-1
@@ -320,6 +320,14 @@ interface GroupEntry {
|
||||
name: string;
|
||||
}
|
||||
|
||||
interface PermissionOverviewEntry {
|
||||
name: string;
|
||||
description: string;
|
||||
value: number;
|
||||
negated: boolean;
|
||||
skip: boolean;
|
||||
}
|
||||
|
||||
interface ClientConnectionInfoData {
|
||||
clientId: number;
|
||||
pingMs: number | null;
|
||||
@@ -1608,6 +1616,86 @@ function GroupAssignDialog({
|
||||
);
|
||||
}
|
||||
|
||||
function PermissionOverviewDialog({
|
||||
entries,
|
||||
onClose,
|
||||
}: {
|
||||
entries: PermissionOverviewEntry[] | null;
|
||||
onClose: () => void;
|
||||
}) {
|
||||
const t = useT();
|
||||
const backdrop = useBackdropDismiss(onClose);
|
||||
const [search, setSearch] = useState("");
|
||||
const [timedOut, setTimedOut] = useState(false);
|
||||
useEffect(() => {
|
||||
setTimedOut(false);
|
||||
if (entries) return;
|
||||
const id = window.setTimeout(() => setTimedOut(true), 6000);
|
||||
return () => window.clearTimeout(id);
|
||||
}, [entries]);
|
||||
|
||||
const filtered = entries?.filter((e) => e.name.toLowerCase().includes(search.toLowerCase())) ?? null;
|
||||
|
||||
return (
|
||||
<div className="ts-dialog-backdrop" {...backdrop}>
|
||||
<div className="ts-dialog ts-permission-overview-dialog" onClick={(e) => e.stopPropagation()}>
|
||||
<div className="ts-dialog-titlebar">
|
||||
<span>{t("permissionOverview.title")}</span>
|
||||
<button onClick={onClose} title={t("dialog.close")}>
|
||||
✕
|
||||
</button>
|
||||
</div>
|
||||
<div className="ts-dialog-body">
|
||||
{!entries ? (
|
||||
<div className="ts-connection-info-loading">
|
||||
{timedOut ? t("connectionInfo.unavailable") : t("connectionInfo.loading")}
|
||||
</div>
|
||||
) : entries.length === 0 ? (
|
||||
<div className="ts-connection-info-loading">{t("permissionOverview.empty")}</div>
|
||||
) : (
|
||||
<>
|
||||
<div className="ts-dialog-row">
|
||||
<label className="ts-dialog-field ts-dialog-field-grow">
|
||||
{t("clientLog.filter")}
|
||||
<input value={search} onChange={(e) => setSearch(e.target.value)} />
|
||||
</label>
|
||||
</div>
|
||||
<div className="ts-permission-overview-scroll">
|
||||
<table className="ts-ban-list-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{t("permissionOverview.name")}</th>
|
||||
<th>{t("permissionOverview.value")}</th>
|
||||
<th>{t("permissionOverview.negated")}</th>
|
||||
<th>{t("permissionOverview.skip")}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{filtered!.map((e, i) => (
|
||||
<tr key={`${e.name}-${i}`} title={e.description || undefined}>
|
||||
<td>{e.name}</td>
|
||||
<td>{e.value}</td>
|
||||
<td>{e.negated ? "✔️" : ""}</td>
|
||||
<td>{e.skip ? "✔️" : ""}</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
<div className="ts-dialog-buttons">
|
||||
<div />
|
||||
<div className="ts-dialog-buttons-right">
|
||||
<button onClick={onClose}>{t("dialog.close")}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function ServerProtocolLogDialog({
|
||||
lines,
|
||||
onClose,
|
||||
@@ -3102,6 +3190,8 @@ function AppInner() {
|
||||
clientId: number;
|
||||
clientName: string;
|
||||
} | null>(null);
|
||||
const [permissionOverviewOpen, setPermissionOverviewOpen] = useState(false);
|
||||
const [permissionOverview, setPermissionOverview] = useState<PermissionOverviewEntry[] | null>(null);
|
||||
const [treeWidth, setTreeWidth] = useState(260);
|
||||
const [upperHeight, setUpperHeight] = useState(340);
|
||||
const [selected, setSelected] = useState<SelectedItem | null>(null);
|
||||
@@ -3698,6 +3788,9 @@ function AppInner() {
|
||||
case "serverGroupList":
|
||||
setServerGroups(data.entries);
|
||||
break;
|
||||
case "permissionOverview":
|
||||
setPermissionOverview(data.entries);
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -4446,6 +4539,12 @@ function AppInner() {
|
||||
}
|
||||
};
|
||||
|
||||
const handleShowPermissionOverview = () => {
|
||||
setPermissionOverviewOpen(true);
|
||||
setPermissionOverview(null);
|
||||
socketRef.current?.send(JSON.stringify({ type: "getPermissionOverview" }));
|
||||
};
|
||||
|
||||
const handleSendPoke = () => {
|
||||
if (!pokeTarget) return;
|
||||
socketRef.current?.send(
|
||||
@@ -4734,7 +4833,13 @@ function AppInner() {
|
||||
<span className="ts-menu-item-label">{t("menu.rights.overview")}</span>
|
||||
</button>
|
||||
<div className="ts-menu-separator" />
|
||||
<button className="ts-menu-item" disabled title={t("clientContext.notSupported")}>
|
||||
<button
|
||||
className="ts-menu-item"
|
||||
onClick={() => {
|
||||
handleShowPermissionOverview();
|
||||
setRightsMenuOpen(false);
|
||||
}}
|
||||
>
|
||||
<span className="ts-menu-item-icon">🙋</span>
|
||||
<span className="ts-menu-item-label">{t("menu.rights.myRights")}</span>
|
||||
</button>
|
||||
@@ -5277,6 +5382,13 @@ function AppInner() {
|
||||
/>
|
||||
)}
|
||||
|
||||
{permissionOverviewOpen && (
|
||||
<PermissionOverviewDialog
|
||||
entries={permissionOverview}
|
||||
onClose={() => setPermissionOverviewOpen(false)}
|
||||
/>
|
||||
)}
|
||||
|
||||
{contactsOpen && (
|
||||
<ContactsDialog
|
||||
contacts={contacts}
|
||||
|
||||
@@ -367,6 +367,23 @@ export class DemoSocket {
|
||||
// No observable effect - the demo has no real ServerQuery backend to
|
||||
// authenticate against.
|
||||
break;
|
||||
case "getPermissionOverview": {
|
||||
this.after(400, () =>
|
||||
this.emit({
|
||||
type: "permissionOverview",
|
||||
entries: [
|
||||
{ name: "b_client_info_view", description: "View own client info", value: 1, negated: false, skip: false },
|
||||
{ name: "b_client_permissionoverview_view", description: "View permission overview", value: 1, negated: false, skip: false },
|
||||
{ name: "i_channel_join_power", description: "Power to join channels", value: 25, negated: false, skip: false },
|
||||
{ name: "i_client_talk_power", description: "Talk power", value: 25, negated: false, skip: false },
|
||||
{ name: "b_client_use_priority_speaker", description: "Use priority speaker", value: 0, negated: true, skip: false },
|
||||
{ name: "i_client_max_channel_subscriptions", description: "Max channel subscriptions", value: -1, negated: false, skip: false },
|
||||
{ name: "b_channel_join_permanent", description: "Join permanent channels", value: 1, negated: false, skip: false },
|
||||
],
|
||||
})
|
||||
);
|
||||
break;
|
||||
}
|
||||
// "disconnect" is intentionally unhandled here: handleDisconnect() in
|
||||
// App.tsx always calls socket.close() right after sending it, and
|
||||
// close() already emits the "disconnected" event below.
|
||||
|
||||
@@ -404,6 +404,13 @@ const translations: Record<Lang, Record<string, string>> = {
|
||||
"serverQueryLogin.password": "Passwort",
|
||||
"serverQueryLogin.login": "Anmelden",
|
||||
|
||||
"permissionOverview.title": "Eigene Rechte",
|
||||
"permissionOverview.empty": "Keine Rechte gefunden.",
|
||||
"permissionOverview.name": "Recht",
|
||||
"permissionOverview.value": "Wert",
|
||||
"permissionOverview.negated": "Negiert",
|
||||
"permissionOverview.skip": "Skip",
|
||||
|
||||
"clientContext.privateChat": "Privater Chat",
|
||||
"clientContext.poke": "Anstupsen",
|
||||
"clientContext.copyName": "Namen kopieren",
|
||||
@@ -850,6 +857,13 @@ const translations: Record<Lang, Record<string, string>> = {
|
||||
"serverQueryLogin.password": "Password",
|
||||
"serverQueryLogin.login": "Login",
|
||||
|
||||
"permissionOverview.title": "My Permissions",
|
||||
"permissionOverview.empty": "No permissions found.",
|
||||
"permissionOverview.name": "Permission",
|
||||
"permissionOverview.value": "Value",
|
||||
"permissionOverview.negated": "Negated",
|
||||
"permissionOverview.skip": "Skip",
|
||||
|
||||
"clientContext.privateChat": "Private chat",
|
||||
"clientContext.poke": "Poke",
|
||||
"clientContext.copyName": "Copy name",
|
||||
|
||||
Reference in new issue
Block a user