Files
opencode-manager/frontend/src/components/repo/RenameRepoDialog.tsx
T
Chris Scott 5bd688de4b feat(themes): apply OpenCode color themes app-wide with a settings picker (#364)
- Vendor the 36 OpenCode theme palettes into the shared package, synced
  from the pinned OpenCode release tag via pnpm themes:sync.
- Add a colorTheme user preference across the settings schema, defaults,
  and the assistant internal API.
- Extend palettes with success, warning, info, and diff colors, and add a
  resolver that maps palettes to CSS tokens and applies them to the DOM.
- Apply the theme app-wide through a ThemeProvider context, adopting the
  tokens in message, repo, session, and settings components, agent
  colors, git status styles, and diff viewers.
- Add a theme picker to General settings and make model quick-select
  follow the active theme (fixes #355).
2026-09-28 00:19:32 -04:00

95 lines
2.7 KiB
TypeScript

import { Dialog, DialogContent, DialogHeader, DialogTitle } from '@/components/ui/dialog'
import { Button } from '@/components/ui/button'
import { X, Check } from 'lucide-react'
import { useState, useRef, useEffect } from 'react'
interface RenameRepoDialogProps {
isOpen: boolean
currentName: string
derivedName: string
onClose: () => void
onSave: (name: string | null) => void
}
export function RenameRepoDialog({
isOpen,
currentName,
derivedName,
onClose,
onSave,
}: RenameRepoDialogProps) {
const [editName, setEditName] = useState(currentName)
const inputRef = useRef<HTMLInputElement>(null)
useEffect(() => {
if (isOpen) {
setEditName(currentName)
}
}, [isOpen, currentName])
const handleSubmit = (e: React.FormEvent) => {
e.preventDefault()
const trimmed = editName.trim()
onSave(trimmed.length > 0 ? trimmed : null)
onClose()
}
const handleCancel = () => {
setEditName(currentName)
onClose()
}
return (
<Dialog open={isOpen} onOpenChange={onClose}>
<DialogContent hideCloseButton className="sm:max-w-md">
<DialogHeader>
<DialogTitle>Rename repository</DialogTitle>
</DialogHeader>
<form onSubmit={handleSubmit} className="space-y-4">
<div className="relative">
<input
ref={inputRef}
type="text"
value={editName}
onChange={(e) => setEditName(e.target.value)}
placeholder={derivedName}
className="text-base font-semibold bg-background border border-border rounded-md px-3 py-2.5 pr-10 outline-none w-full focus:border-primary focus:ring-2 focus:ring-primary/20"
autoFocus
/>
{editName && (
<button
type="button"
aria-label="Clear"
onClick={() => {
setEditName('')
inputRef.current?.focus()
}}
className="absolute right-2 top-1/2 -translate-y-1/2 p-1.5 rounded-full hover:bg-destructive/10 text-destructive transition-colors"
>
<X className="w-5 h-5" />
</button>
)}
</div>
<div className="flex items-center gap-2">
<Button
type="button"
variant="outline"
onClick={handleCancel}
className="flex-1 h-10"
>
Cancel
</Button>
<Button
type="submit"
className="flex-1 h-10"
>
<Check className="w-4 h-4 mr-2" />
Save
</Button>
</div>
</form>
</DialogContent>
</Dialog>
)
}