Files
openclaw/ui/src/components/connect-command.ts
Shakker 65e12328aa feat: refactor the Control UI architecture
Refactor the Control UI around route-owned page lifecycle and state while preserving existing behavior and design.

Prepared head SHA: bd51b6fa76
Co-authored-by: Shakker <165377636+shakkernerd@users.noreply.github.com>
Reviewed-by: @shakkernerd
2026-07-04 23:19:38 +01:00

44 lines
1.3 KiB
TypeScript

// Control UI component renders a copyable gateway connection command.
import { html } from "lit";
import { t } from "../i18n/index.ts";
import { renderCopyButton } from "./copy-button.ts";
import "./tooltip.ts";
async function copyCommand(command: string) {
try {
await navigator.clipboard.writeText(command);
} catch {
// Best effort only; the explicit copy button provides visible feedback.
}
}
export function renderConnectCommand(command: string) {
const copyLabel = t("overview.connection.copyCommand");
return html`
<openclaw-tooltip .content=${copyLabel}>
<div
class="login-gate__command"
role="button"
tabindex="0"
aria-label=${t("overview.connection.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>
`;
}