diff --git a/web/src/App.css b/web/src/App.css index 3ab77c3..06dfebe 100644 --- a/web/src/App.css +++ b/web/src/App.css @@ -190,6 +190,29 @@ background: var(--border-soft); } +.ts-context-menu { + position: fixed; + z-index: 30; + display: flex; + flex-direction: column; + min-width: 200px; + padding: 0.25rem; + background: var(--bg-toolbar-1); + border: 1px solid var(--border); + border-radius: 4px; + box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3); +} + +.ts-context-menu-title { + padding: 0.35rem 0.5rem; + font-size: 11px; + font-weight: 600; + color: var(--text-muted); + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} + .ts-toolbar { display: flex; flex-direction: column; diff --git a/web/src/App.tsx b/web/src/App.tsx index c645262..c90472b 100644 --- a/web/src/App.tsx +++ b/web/src/App.tsx @@ -218,6 +218,7 @@ function ChannelTree({ onSwitchChannel, onOpenPrivateChat, onPokeClient, + onClientContextMenu, }: { channels: ChannelInfo[]; clients: ClientInfo[]; @@ -229,6 +230,7 @@ function ChannelTree({ onSwitchChannel: (channelId: number) => void; onOpenPrivateChat: (clientId: number, clientName: string) => void; onPokeClient: (clientId: number, clientName: string) => void; + onClientContextMenu: (e: React.MouseEvent, clientId: number, clientName: string, isSelf: boolean) => void; }) { const t = useT(); const children = channels.filter((c) => c.parent === parent).sort((a, b) => a.order - b.order); @@ -260,6 +262,7 @@ function ChannelTree({ talkers.has(c.id) ? " ts-talking" : "" }`} onClick={c.id === ownClientId ? undefined : () => onOpenPrivateChat(c.id, c.name)} + onContextMenu={(e) => onClientContextMenu(e, c.id, c.name, c.id === ownClientId)} title={c.id === ownClientId ? undefined : `${t("tree.privateChatWith")} ${c.name}`} > @@ -295,6 +298,7 @@ function ChannelTree({ onSwitchChannel={onSwitchChannel} onOpenPrivateChat={onOpenPrivateChat} onPokeClient={onPokeClient} + onClientContextMenu={onClientContextMenu} /> ))} @@ -1406,6 +1410,14 @@ function AppInner() { const [pokeMessage, setPokeMessage] = useState(""); const pokeBackdrop = useBackdropDismiss(() => setPokeTarget(null)); const [demoForceMobile, setDemoForceMobile] = useState(false); + const [clientContextMenu, setClientContextMenu] = useState<{ + x: number; + y: number; + clientId: number; + clientName: string; + isSelf: boolean; + } | null>(null); + const clientContextMenuRef = useRef(null); const [activeTab, setActiveTab] = useState("channel"); const [theme, setTheme] = useState<"light" | "dark">(() => window.matchMedia?.("(prefers-color-scheme: dark)").matches ? "dark" : "light" @@ -1944,6 +1956,22 @@ function AppInner() { }; }, [awayMenuOpen]); + useEffect(() => { + if (!clientContextMenu) return; + const onPointerDown = (e: MouseEvent) => { + if (!clientContextMenuRef.current?.contains(e.target as Node)) setClientContextMenu(null); + }; + const onKeyDown = (e: KeyboardEvent) => { + if (e.key === "Escape") setClientContextMenu(null); + }; + window.addEventListener("mousedown", onPointerDown); + window.addEventListener("keydown", onKeyDown); + return () => { + window.removeEventListener("mousedown", onPointerDown); + window.removeEventListener("keydown", onKeyDown); + }; + }, [clientContextMenu]); + useEffect(() => { if (!extrasMenuOpen) return; const onPointerDown = (e: MouseEvent) => { @@ -2126,6 +2154,18 @@ function AppInner() { setPokeMessage(""); }; + const handleClientContextMenu = ( + e: React.MouseEvent, + clientId: number, + clientName: string, + isSelf: boolean + ) => { + e.preventDefault(); + const x = Math.min(e.clientX, window.innerWidth - 220); + const y = Math.min(e.clientY, window.innerHeight - 300); + setClientContextMenu({ x, y, clientId, clientName, isSelf }); + }; + const handleSendPoke = () => { if (!pokeTarget) return; socketRef.current?.send( @@ -2582,6 +2622,70 @@ function AppInner() { ))} + {clientContextMenu && ( +
+
{clientContextMenu.clientName}
+ + + +
+ + + {!clientContextMenu.isSelf && ( + <> +
+ + + + )} +
+ )} +
@@ -2605,6 +2709,7 @@ function AppInner() { onSwitchChannel={handleSwitchChannel} onOpenPrivateChat={handleOpenPrivateChat} onPokeClient={handlePokeClient} + onClientContextMenu={handleClientContextMenu} /> ) : ( diff --git a/web/src/i18n.tsx b/web/src/i18n.tsx index 9083276..9d602a0 100644 --- a/web/src/i18n.tsx +++ b/web/src/i18n.tsx @@ -206,6 +206,15 @@ const translations: Record> = { "poke.pokedYou": "hat dich angestupst", "poke.dismiss": "Schließen", + "clientContext.privateChat": "Privater Chat", + "clientContext.poke": "Anstupsen", + "clientContext.copyName": "Namen kopieren", + "clientContext.assignChannelGroup": "Channel-Gruppe zuweisen", + "clientContext.assignServerGroup": "Server-Gruppe zuweisen", + "clientContext.kick": "Vom Server kicken", + "clientContext.ban": "Bannen", + "clientContext.notSupported": "Im Web-Client noch nicht unterstützt", + "connectError.dismiss": "Schließen", "dialog.close": "Schließen", @@ -434,6 +443,15 @@ const translations: Record> = { "poke.pokedYou": "poked you", "poke.dismiss": "Dismiss", + "clientContext.privateChat": "Private chat", + "clientContext.poke": "Poke", + "clientContext.copyName": "Copy name", + "clientContext.assignChannelGroup": "Assign channel group", + "clientContext.assignServerGroup": "Assign server group", + "clientContext.kick": "Kick from server", + "clientContext.ban": "Ban", + "clientContext.notSupported": "Not yet supported in the web client", + "connectError.dismiss": "Dismiss", "dialog.close": "Close",