diff --git a/beszel/site/src/components/add-system.tsx b/beszel/site/src/components/add-system.tsx index 1f1cc8b..499584f 100644 --- a/beszel/site/src/components/add-system.tsx +++ b/beszel/site/src/components/add-system.tsx @@ -49,8 +49,8 @@ export function AddSystemButton({ className }: { className?: string }) { ) } - function copyDockerCompose(port = "45876", publicKey: string) { - copyToClipboard(`services: +function copyDockerCompose(port = "45876", publicKey: string) { + copyToClipboard(`services: beszel-agent: image: "henrygd/beszel-agent" container_name: "beszel-agent" @@ -63,22 +63,22 @@ export function AddSystemButton({ className }: { className?: string }) { environment: PORT: ${port} KEY: "${publicKey}"`) - } +} - function copyDockerRun(port = "45876", publicKey: string) { - copyToClipboard( - `docker run -d --name beszel-agent --network host --restart unless-stopped -v /var/run/docker.sock:/var/run/docker.sock:ro -e KEY="${publicKey}" -e PORT=${port} henrygd/beszel-agent:latest` - ) - } +function copyDockerRun(port = "45876", publicKey: string) { + copyToClipboard( + `docker run -d --name beszel-agent --network host --restart unless-stopped -v /var/run/docker.sock:/var/run/docker.sock:ro -e KEY="${publicKey}" -e PORT=${port} henrygd/beszel-agent:latest` + ) +} - function copyInstallCommand(port = "45876", publicKey: string) { - let cmd = `curl -sL https://raw.githubusercontent.com/henrygd/beszel/main/supplemental/scripts/install-agent.sh -o install-agent.sh && chmod +x install-agent.sh && ./install-agent.sh -p ${port} -k "${publicKey}"` - // add china mirrors flag if zh-CN - if ((i18n.locale + navigator.language).includes("zh-CN")) { - cmd += ` --china-mirrors` - } - copyToClipboard(cmd) +function copyInstallCommand(port = "45876", publicKey: string) { + let cmd = `curl -sL https://raw.githubusercontent.com/henrygd/beszel/main/supplemental/scripts/install-agent.sh -o install-agent.sh && chmod +x install-agent.sh && ./install-agent.sh -p ${port} -k "${publicKey}"` + // add china mirrors flag if zh-CN + if ((i18n.locale + navigator.language).includes("zh-CN")) { + cmd += ` --china-mirrors` } + copyToClipboard(cmd) +} /** * SystemDialog component for adding or editing a system. @@ -112,9 +112,12 @@ export const SystemDialog = memo(({ setOpen, system }: { setOpen: (open: boolean } return ( - { - setHostValue(system?.host ?? "") - }}> + { + setHostValue(system?.host ?? "") + }} + > @@ -207,35 +210,21 @@ export const SystemDialog = memo(({ setOpen, system }: { setOpen: (open: boolean {/* Docker */} -
- -
- - - - - - copyDockerRun(isUnixSocket ? hostValue : port.current?.value, publicKey)}> - Copy docker run - - - -
+ copyDockerCompose(isUnixSocket ? hostValue : port.current?.value, publicKey)} + dropdownText={t`Copy` + " docker run"} + dropdownOnClick={() => copyDockerRun(isUnixSocket ? hostValue : port.current?.value, publicKey)} + />
{/* Binary */} - + copyInstallCommand(isUnixSocket ? hostValue : port.current?.value, publicKey)} + dropdownText={t`Manual setup instructions`} + dropdownUrl="https://beszel.dev/guide/agent-installation#binary" + /> {/* Save */} @@ -245,3 +234,40 @@ export const SystemDialog = memo(({ setOpen, system }: { setOpen: (open: boolean
) }) + +interface CopyButtonProps { + text: string + onClick: () => void + dropdownText: string + dropdownOnClick?: () => void + dropdownUrl?: string +} + +const CopyButton = memo((props: CopyButtonProps) => { + return ( +
+ +
+ + + + + + {props.dropdownUrl ? ( + + + {props.dropdownText} + + + ) : ( + {props.dropdownText} + )} + + +
+ ) +})