diff --git a/frontend/src/components/deploy/ReleaseApplyDialog.tsx b/frontend/src/components/deploy/ReleaseApplyDialog.tsx new file mode 100644 index 0000000..69f7bea --- /dev/null +++ b/frontend/src/components/deploy/ReleaseApplyDialog.tsx @@ -0,0 +1,162 @@ +// 发布管理 - 新建发布申请弹窗(自包含表单状态 + 提交逻辑) // Logan.Li +import { useState, useEffect } from 'react'; +import { + Dialog, + DialogContent, + DialogDescription, + DialogFooter, + DialogHeader, + DialogTitle, +} from '@/components/ui/dialog'; +import { Button } from '@/components/ui/button'; +import { Input } from '@/components/ui/input'; +import { Label } from '@/components/ui/label'; +import { Textarea } from '@/components/ui/textarea'; +import { + Select, + SelectContent, + SelectItem, + SelectTrigger, + SelectValue, +} from '@/components/ui/select'; +import { Loader2 } from 'lucide-react'; +import { releaseApi } from '@/services/api'; +import { toast } from 'sonner'; + +interface ReleaseApplyDialogProps { + open: boolean; + onOpenChange: (open: boolean) => void; + onSuccess?: () => void; +} + +export function ReleaseApplyDialog({ open, onOpenChange, onSuccess }: ReleaseApplyDialogProps) { + const [submitting, setSubmitting] = useState(false); + const [form, setForm] = useState({ + appName: '', + version: '', + environment: 'dev', + commitId: '', + commitMsg: '', + description: '', + }); + + // 弹窗打开时重置表单 // Logan.Li + useEffect(() => { + if (open) { + setForm({ appName: '', version: '', environment: 'dev', commitId: '', commitMsg: '', description: '' }); + } + }, [open]); + + const handleSubmit = async () => { + if (!form.appName.trim() || !form.version.trim()) { + toast.error('请填写应用名称和版本号'); + return; + } + setSubmitting(true); + try { + await releaseApi.createRelease({ + app_name: form.appName.trim(), + version: form.version.trim(), + environment: form.environment, + commit_id: form.commitId.trim(), + commit_msg: form.commitMsg.trim(), + description: form.description.trim(), + }); + toast.success('发布申请已提交'); + onOpenChange(false); + onSuccess?.(); + } catch { + toast.error('创建失败'); + } finally { + setSubmitting(false); + } + }; + + return ( + + + + 新建发布 + 创建新的应用版本发布申请 + +
+
+ + setForm({ ...form, appName: e.target.value })} + placeholder="如:用户中心服务" + className="mt-1" + /> +
+
+
+ + setForm({ ...form, version: e.target.value })} + placeholder="v1.0.0" + className="mt-1" + /> +
+
+ + +
+
+
+
+ + setForm({ ...form, commitId: e.target.value })} + placeholder="abc1234" + className="mt-1" + /> +
+
+ + setForm({ ...form, commitMsg: e.target.value })} + placeholder="feat: 新增功能" + className="mt-1" + /> +
+
+
+ +