feat: add repo field to Project

This commit is contained in:
Zhi
2026-03-12 12:06:46 +00:00
parent 529ceafde4
commit 98ba64e35c
3 changed files with 10 additions and 3 deletions

View File

@@ -19,13 +19,14 @@ export default function ProjectDetailPage() {
const [users, setUsers] = useState<any[]>([])
const [roles, setRoles] = useState<any[]>([])
const [editing, setEditing] = useState(false)
const [editForm, setEditForm] = useState({ owner: '', description: '', sub_projects: [] as string[], related_projects: [] as string[] })
const [editForm, setEditForm] = useState({ owner: '', repo: '', description: '', sub_projects: [] as string[], related_projects: [] as string[] })
useEffect(() => {
api.get<Project>(`/projects/${id}`).then(({ data }) => {
setProject(data)
setEditForm({
owner: data.owner || '',
repo: data.repo || '',
description: data.description || '',
sub_projects: data.sub_projects || [],
related_projects: data.related_projects || [],

View File

@@ -8,7 +8,7 @@ export default function ProjectsPage() {
const [projects, setProjects] = useState<Project[]>([])
const [users, setUsers] = useState<any[]>([])
const [showCreate, setShowCreate] = useState(false)
const [form, setForm] = useState({ name: '', description: '', owner_id: 1, sub_projects: [] as string[], related_projects: [] as string[] })
const [form, setForm] = useState({ name: '', description: '', owner_id: 1, repo: '', sub_projects: [] as string[], related_projects: [] as string[] })
const navigate = useNavigate()
const fetchProjects = () => {
@@ -30,7 +30,7 @@ export default function ProjectsPage() {
const createProject = async (e: React.FormEvent) => {
e.preventDefault()
await api.post('/projects', form)
setForm({ name: '', description: '', owner_id: 1, sub_projects: [], related_projects: [] })
setForm({ name: '', description: '', owner_id: 1, repo: '', sub_projects: [], related_projects: [] })
setShowCreate(false)
fetchProjects()
}
@@ -61,6 +61,10 @@ export default function ProjectsPage() {
placeholder="Description (optional)" value={form.description}
onChange={(e) => setForm({ ...form, description: e.target.value })}
/>
<input
placeholder="Repository URL (optional)" value={form.repo}
onChange={(e) => setForm({ ...form, repo: e.target.value })}
/>
<label>Sub-projects (Ctrl+Click to select multiple)</label>
<select multiple value={form.sub_projects} onChange={(e) => handleMulti(e, 'sub_projects')} style={{height:80}}>
{projectOptions.map((p) => (