Skip to content

Commit 2fba950

Browse files
committed
Export Public Key
1 parent 74801f6 commit 2fba950

2 files changed

Lines changed: 26 additions & 2 deletions

File tree

src/components/realm/ExportDialog.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@ export function ExportDialog({
6565
value={exportData}
6666
readOnly
6767
rows={15}
68-
className="font-mono text-xs"
68+
className="font-mono text-xs break-all"
6969
/>
7070
</div>
7171

72-
<DialogFooter className="gap-2 sm:gap-0">
72+
<DialogFooter className="gap-2">
7373
<Button variant="outline" onClick={handleCopy}>
7474
<Copy className="mr-1.5 h-4 w-4" />
7575
{copied ? "Copied!" : "Copy"}

src/components/realm/RealmCard.tsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,20 @@ export function RealmCard() {
4646
setTimeout(() => setCopied(false), 2000);
4747
};
4848

49+
const handleDownloadPublicKey = () => {
50+
const blob = new Blob([activeRealm.keyPair.publicKeyHex], {
51+
type: "text/plain",
52+
});
53+
const url = URL.createObjectURL(blob);
54+
const a = document.createElement("a");
55+
a.href = url;
56+
a.download = `${activeRealm.name.toLowerCase().replace(/\s+/g, "-")}.pub`;
57+
document.body.appendChild(a);
58+
a.click();
59+
document.body.removeChild(a);
60+
URL.revokeObjectURL(url);
61+
};
62+
4963
const handleDelete = () => {
5064
deleteRealm(activeRealm.id);
5165
setShowDeleteDialog(false);
@@ -108,10 +122,20 @@ export function RealmCard() {
108122
variant="ghost"
109123
size="sm"
110124
onClick={handleCopyPublicKey}
125+
title="Copy to clipboard"
111126
>
112127
<Copy className="h-4 w-4" />
113128
<span className="sr-only">Copy</span>
114129
</Button>
130+
<Button
131+
variant="ghost"
132+
size="sm"
133+
onClick={handleDownloadPublicKey}
134+
title="Download public key"
135+
>
136+
<Download className="h-4 w-4" />
137+
<span className="sr-only">Download</span>
138+
</Button>
115139
</div>
116140
{copied && (
117141
<p className="mt-1 text-xs text-muted-foreground">

0 commit comments

Comments
 (0)