mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 12:24:30 +01:00
Fix CreateConfigDialog event propagation and mobile scrolling
This commit is contained in:
1 parent
c0c18a5bde
commit
d650287211
4 files changed
+47
-41
No files matched your search
@@ -71,6 +71,17 @@ A full-stack web application for running [OpenCode](https://github.com/sst/openc
|
||||
### File Context
|
||||

|
||||
|
||||
## Mobile Screenshots
|
||||
|
||||
### Repository List
|
||||
<img width="300" alt="Mobile Repository List" src="https://github.com/user-attachments/assets/4a854373-9e4d-41ac-9a6c-c0eb37b0ac42" />
|
||||
|
||||
### Chat Interface
|
||||
<img width="300" alt="Mobile Chat Interface" src="https://github.com/user-attachments/assets/57fe81c1-b169-43eb-b95f-6e027d7bea10" />
|
||||
|
||||
### OpenCode Configuration
|
||||
<img width="300" alt="Mobile OpenCode Configuration" src="https://github.com/user-attachments/assets/fcb16958-3134-434f-8c78-fb07259f5ce1" />
|
||||
|
||||
## Coming Soon
|
||||
|
||||
- **Authentication** - User authentication and session management
|
||||
|
||||
@@ -12,10 +12,9 @@ interface CreateConfigDialogProps {
|
||||
onOpenChange: (open: boolean) => void
|
||||
onCreate: (name: string, content: string, isDefault: boolean) => Promise<void>
|
||||
isUpdating: boolean
|
||||
children?: React.ReactNode
|
||||
}
|
||||
|
||||
export function CreateConfigDialog({ isOpen, onOpenChange, onCreate, isUpdating, children }: CreateConfigDialogProps) {
|
||||
export function CreateConfigDialog({ isOpen, onOpenChange, onCreate, isUpdating }: CreateConfigDialogProps) {
|
||||
const [name, setName] = useState('')
|
||||
const [content, setContent] = useState('')
|
||||
const [isDefault, setIsDefault] = useState(false)
|
||||
@@ -23,7 +22,10 @@ export function CreateConfigDialog({ isOpen, onOpenChange, onCreate, isUpdating,
|
||||
const [errorLine, setErrorLine] = useState<number | null>(null)
|
||||
const textareaRef = useRef<HTMLTextAreaElement>(null)
|
||||
|
||||
const handleSubmit = async () => {
|
||||
const handleSubmit = async (event?: React.MouseEvent) => {
|
||||
event?.preventDefault()
|
||||
event?.stopPropagation()
|
||||
|
||||
if (!name.trim() || !content.trim()) return
|
||||
|
||||
try {
|
||||
@@ -90,16 +92,14 @@ export function CreateConfigDialog({ isOpen, onOpenChange, onCreate, isUpdating,
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
{children}
|
||||
<Dialog open={isOpen} onOpenChange={onOpenChange}>
|
||||
<DialogContent className="max-w-2xl">
|
||||
<DialogHeader>
|
||||
<Dialog open={isOpen} onOpenChange={onOpenChange}>
|
||||
<DialogContent className="max-w-2xl max-h-[90vh] sm:max-h-[85vh] flex flex-col">
|
||||
<DialogHeader className="flex-shrink-0">
|
||||
<DialogTitle>Create OpenCode Config</DialogTitle>
|
||||
</DialogHeader>
|
||||
<div className="space-y-4">
|
||||
<div className="space-y-4 overflow-y-auto flex-1 pr-2">
|
||||
<div>
|
||||
<Label htmlFor="config-name">Config Name</Label>
|
||||
<Label htmlFor="config-name" className="pb-1">Config Name</Label>
|
||||
<Input
|
||||
id="config-name"
|
||||
value={name}
|
||||
@@ -109,7 +109,7 @@ export function CreateConfigDialog({ isOpen, onOpenChange, onCreate, isUpdating,
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<Label htmlFor="config-upload">Upload JSON File</Label>
|
||||
<Label htmlFor="config-upload" className="pb-1">Upload JSON File</Label>
|
||||
<Input
|
||||
id="config-upload"
|
||||
type="file"
|
||||
@@ -119,14 +119,14 @@ export function CreateConfigDialog({ isOpen, onOpenChange, onCreate, isUpdating,
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<Label htmlFor="config-content">Config Content (JSON)</Label>
|
||||
<Label htmlFor="config-content" className="pb-1">Config Content (JSON)</Label>
|
||||
<Textarea
|
||||
id="config-content"
|
||||
ref={textareaRef}
|
||||
value={content}
|
||||
onChange={(e) => handleContentChange(e.target.value)}
|
||||
placeholder='{"$schema": "https://opencode.ai/config.json", "theme": "dark"}'
|
||||
rows={20}
|
||||
rows={12}
|
||||
className="font-mono text-sm"
|
||||
/>
|
||||
{error && (
|
||||
@@ -147,22 +147,22 @@ export function CreateConfigDialog({ isOpen, onOpenChange, onCreate, isUpdating,
|
||||
/>
|
||||
<Label htmlFor="config-default">Set as default configuration</Label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex justify-end gap-2">
|
||||
<Button variant="outline" onClick={() => onOpenChange(false)}>
|
||||
Cancel
|
||||
</Button>
|
||||
<Button
|
||||
onClick={handleSubmit}
|
||||
disabled={isUpdating || !name.trim() || !content.trim()}
|
||||
>
|
||||
{isUpdating && <Loader2 className="h-4 w-4 mr-2 animate-spin" />}
|
||||
Create
|
||||
</Button>
|
||||
</div>
|
||||
<div className="flex justify-end gap-2 flex-shrink-0 pt-4 border-t">
|
||||
<Button variant="outline" onClick={() => onOpenChange(false)}>
|
||||
Cancel
|
||||
</Button>
|
||||
<Button
|
||||
type="button"
|
||||
onClick={(e) => handleSubmit(e)}
|
||||
disabled={isUpdating || !name.trim() || !content.trim()}
|
||||
>
|
||||
{isUpdating && <Loader2 className="h-4 w-4 mr-2 animate-spin" />}
|
||||
Create
|
||||
</Button>
|
||||
</div>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</>
|
||||
)
|
||||
}
|
||||
@@ -2,7 +2,6 @@ import { useState, useEffect } from 'react'
|
||||
import { Loader2, Plus, Trash2, Edit, Star, StarOff, Download, RotateCcw } from 'lucide-react'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'
|
||||
import { DialogTrigger } from '@/components/ui/dialog'
|
||||
import { Label } from '@/components/ui/label'
|
||||
import { Badge } from '@/components/ui/badge'
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'
|
||||
@@ -194,19 +193,16 @@ export function OpenCodeConfigManager() {
|
||||
)}
|
||||
Restart Server
|
||||
</Button>
|
||||
<CreateConfigDialog
|
||||
<Button type="button" onClick={() => setIsCreateDialogOpen(true)}>
|
||||
<Plus className="h-4 w-4 mr-2" />
|
||||
New Config
|
||||
</Button>
|
||||
<CreateConfigDialog
|
||||
isOpen={isCreateDialogOpen}
|
||||
onOpenChange={setIsCreateDialogOpen}
|
||||
onCreate={createConfig}
|
||||
isUpdating={isUpdating}
|
||||
>
|
||||
<DialogTrigger asChild>
|
||||
<Button>
|
||||
<Plus className="h-4 w-4 mr-2" />
|
||||
New Config
|
||||
</Button>
|
||||
</DialogTrigger>
|
||||
</CreateConfigDialog>
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -222,12 +218,11 @@ export function OpenCodeConfigManager() {
|
||||
<Card key={config.id}>
|
||||
<CardHeader className="pb-3">
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex items-center gap-2">
|
||||
<div className="flex items-center gap-2 flex-wrap">
|
||||
<CardTitle className="text-base">{config.name}</CardTitle>
|
||||
{config.isDefault && (
|
||||
<Badge variant="default" className="text-xs">
|
||||
<Star className="h-3 w-3 mr-1" />
|
||||
Default
|
||||
<Badge variant="default" className="">
|
||||
<Star className="h-4 w-4" />
|
||||
</Badge>
|
||||
)}
|
||||
</div>
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "opencode-webui",
|
||||
"version": "0.3.1",
|
||||
"version": "0.3.2",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"packageManager": "pnpm@9.15.0",
|
||||
|
||||
Reference in new issue
Block a user