mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +01:00
feat: add copy buttons with toast notifications to OAuth dialog
- Add CopyButton component onCopy callback for custom actions - Add device code display and copy button in OAuthCallbackDialog - Add URL copy button next to Open Authorization Page button - Add authorization code input copy button - Show toast notifications: "Code copied to clipboard" and "URL copied to clipboard" - Extract device/user code from instructions using regex pattern
This commit is contained in:
1 parent
0836e324a3
commit
d19ebdd9e0
2 files changed
+58
-11
No files matched your search
@@ -8,6 +8,7 @@ interface CopyButtonProps {
|
||||
className?: string
|
||||
iconSize?: 'sm' | 'md'
|
||||
variant?: 'default' | 'ghost'
|
||||
onCopy?: () => void
|
||||
}
|
||||
|
||||
export function CopyButton({
|
||||
@@ -15,7 +16,8 @@ export function CopyButton({
|
||||
title = 'Copy',
|
||||
className = '',
|
||||
iconSize = 'md',
|
||||
variant = 'default'
|
||||
variant = 'default',
|
||||
onCopy
|
||||
}: CopyButtonProps) {
|
||||
const [copied, setCopied] = useState(false)
|
||||
|
||||
@@ -25,6 +27,7 @@ export function CopyButton({
|
||||
await navigator.clipboard.writeText(content)
|
||||
setCopied(true)
|
||||
setTimeout(() => setCopied(false), 2000)
|
||||
onCopy?.()
|
||||
} catch {
|
||||
const textArea = document.createElement('textarea')
|
||||
textArea.value = content
|
||||
@@ -37,6 +40,7 @@ export function CopyButton({
|
||||
if (successful) {
|
||||
setCopied(true)
|
||||
setTimeout(() => setCopied(false), 2000)
|
||||
onCopy?.()
|
||||
}
|
||||
} finally {
|
||||
document.body.removeChild(textArea)
|
||||
|
||||
Reference in new issue
Block a user