fix: the copy icons of the Manager are shown only on a page opened over HTTPS, where the browser offers the clipboard.
Release / release (push) Successful in 22s

This commit is contained in:
slawek committed 2026-11-24 20:41:04 +01:00
1 parent 5c6fd90f37
commit 240255b2ff
7 files changed
+40 -20

No files matched your search

+11 -6
View File
@@ -404,16 +404,21 @@ export function Pairs(props: { rows: [string, string | ReactNode][] }) {
)
}
/** A value in monospace for Pairs with an action icon that puts it on the clipboard; label names it in the tooltip. */
/**
* A value in monospace for Pairs with an action icon that puts it on the clipboard, shown only on a page served over
* HTTPS, where the browser offers the clipboard; label names it in the tooltip.
*/
export function Copyable(props: { value: string; label: string }) {
return (
<Stack direction="row" sx={{ alignItems: 'center', gap: 1 }}>
<Box component="span" sx={{ fontFamily: 'monospace', fontSize: 13, wordBreak: 'break-all' }}>{props.value}</Box>
<Tooltip title={`Copy the ${props.label}`}>
<IconButton size="small" aria-label={`copy the ${props.label}`} onClick={() => void navigator.clipboard.writeText(props.value)}>
<ContentCopy fontSize="small" />
</IconButton>
</Tooltip>
{window.isSecureContext && (
<Tooltip title={`Copy the ${props.label}`}>
<IconButton size="small" aria-label={`copy the ${props.label}`} onClick={() => void navigator.clipboard.writeText(props.value)}>
<ContentCopy fontSize="small" />
</IconButton>
</Tooltip>
)}
</Stack>
)
}
+7 -4
View File
@@ -14,7 +14,8 @@ const PREFILLED_LINES = 2
* device's address, its peer's IPs, or a placeholder without them (ips null). The device's private key is a
* placeholder, which the server never has; a switch leaves out the [Interface] and PrivateKey lines, which a client such
* as WireGuard for Windows fills in for a new empty tunnel, and keeps its position in the browser's settings. Copy
* puts the configuration as shown on the clipboard.
* puts the configuration as shown on the clipboard; it is shown only on a page served over HTTPS, where the browser
* offers the clipboard.
*/
export default function WireGuardConfigDialog(props: { title: string; server: WireGuardServer; ips: string[] | null; onClose: () => void }) {
const [copied, setCopied] = useState(false)
@@ -43,9 +44,11 @@ export default function WireGuardConfigDialog(props: { title: string; server: Wi
</Box>
</DialogContent>
<DialogActions>
<Button startIcon={copied ? <Check /> : <ContentCopy />} onClick={() => void navigator.clipboard.writeText(text).then(() => setCopied(true))}>
{copied ? 'Copied' : 'Copy'}
</Button>
{window.isSecureContext && (
<Button startIcon={copied ? <Check /> : <ContentCopy />} onClick={() => void navigator.clipboard.writeText(text).then(() => setCopied(true))}>
{copied ? 'Copied' : 'Copy'}
</Button>
)}
<Button variant="contained" onClick={props.onClose}>Close</Button>
</DialogActions>
</Dialog>