diff --git a/frontend/src/components/automation/AnsibleDetailDialog.tsx b/frontend/src/components/automation/AnsibleDetailDialog.tsx new file mode 100644 index 0000000..ee18f94 --- /dev/null +++ b/frontend/src/components/automation/AnsibleDetailDialog.tsx @@ -0,0 +1,47 @@ +// Ansible 查看 Playbook 内容弹窗 // Logan.Li +import { FileCode, Edit } from 'lucide-react'; +import { Button } from '@/components/ui/button'; +import { + Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription, DialogFooter, +} from '@/components/ui/dialog'; +import { ScrollArea } from '@/components/ui/scroll-area'; +import type { Playbook } from './ansible-helpers'; + +interface Props { + open: boolean; + onOpenChange: (open: boolean) => void; + playbook: Playbook | null; + onEdit: (pb: Playbook) => void; +} + +const AnsibleDetailDialog: React.FC = ({ open, onOpenChange, playbook, onEdit }) => { + return ( + + + + + + {playbook?.name} + + {playbook?.description} + + +
+            {playbook?.content || '(空)'}
+          
+
+ + + {playbook && ( + + )} + +
+
+ ); +}; + +export default AnsibleDetailDialog; diff --git a/frontend/src/components/automation/AnsibleFormDialog.tsx b/frontend/src/components/automation/AnsibleFormDialog.tsx new file mode 100644 index 0000000..114e611 --- /dev/null +++ b/frontend/src/components/automation/AnsibleFormDialog.tsx @@ -0,0 +1,111 @@ +// Ansible 新建/编辑 Playbook 弹窗 // Logan.Li +import { CheckCircle } from 'lucide-react'; +import { Button } from '@/components/ui/button'; +import { Input } from '@/components/ui/input'; +import { + Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription, DialogFooter, +} from '@/components/ui/dialog'; +import { + Select, SelectContent, SelectItem, SelectTrigger, SelectValue, +} from '@/components/ui/select'; +import { Label } from '@/components/ui/label'; +import { Textarea } from '@/components/ui/textarea'; +import { categories } from './ansible-helpers'; + +export interface PlaybookFormData { + name: string; + description: string; + content: string; + category: string; + tags: string; + timeout: number; +} + +interface Props { + open: boolean; + onOpenChange: (open: boolean) => void; + editingId: number | null; + formData: PlaybookFormData; + setFormData: React.Dispatch>; + onSave: () => void; +} + +const AnsibleFormDialog: React.FC = ({ open, onOpenChange, editingId, formData, setFormData, onSave }) => { + return ( + + + + {editingId !== null ? '编辑 Playbook' : '新建 Playbook'} + 编写 Ansible Playbook 实现自动化运维 + +
+
+
+ + setFormData({ ...formData, name: e.target.value })} + placeholder="Playbook 名称" + /> +
+
+ + +
+
+
+ + setFormData({ ...formData, description: e.target.value })} + placeholder="Playbook 描述" + /> +
+
+
+ + setFormData({ ...formData, tags: e.target.value })} + placeholder="如: nginx, web, 部署" + /> +
+
+ + setFormData({ ...formData, timeout: Number(e.target.value) })} + placeholder="600" + /> +
+
+
+ +