Files
openclaw/ui/src/components/connect-command.ts
Peter Steinberger 2ecd485cd5 refactor(ui): deduplicate layout, clipboard, and polling scaffolds (#106003)
* refactor(ui): share dock panel layout

* refactor(ui): centralize clipboard writes

* refactor(ui): centralize polling lifecycle

* refactor(ui): reuse shared byte formatter

* chore(ci): refresh UI LOC ratchet

* fix(ui): keep dock layout type internal
2026-07-12 22:05:09 -07:00

41 lines
1.2 KiB
TypeScript

// Control UI component renders a copyable gateway connection command.
import { html } from "lit";
import { t } from "../i18n/index.ts";
import { copyToClipboard } from "../lib/clipboard.ts";
import { renderCopyButton } from "./copy-button.ts";
import "./tooltip.ts";
async function copyCommand(command: string) {
await copyToClipboard(command);
}
export function renderConnectCommand(command: string) {
const copyLabel = t("connection.help.copyCommand");
return html`
<openclaw-tooltip .content=${copyLabel}>
<div
class="login-gate__command"
role="button"
tabindex="0"
aria-label=${t("connection.help.copyCommandAria", { command })}
@click=${async (event: Event) => {
if ((event.target as HTMLElement | null)?.closest(".chat-copy-btn")) {
return;
}
await copyCommand(command);
}}
@keydown=${async (event: KeyboardEvent) => {
if (event.key !== "Enter" && event.key !== " ") {
return;
}
event.preventDefault();
await copyCommand(command);
}}
>
<code>${command}</code>
${renderCopyButton(command, copyLabel)}
</div>
</openclaw-tooltip>
`;
}