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 [users, setUsers] = useState<any[]>([])
const [roles, setRoles] = useState<any[]>([]) const [roles, setRoles] = useState<any[]>([])
const [editing, setEditing] = useState(false) 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(() => { useEffect(() => {
api.get<Project>(`/projects/${id}`).then(({ data }) => { api.get<Project>(`/projects/${id}`).then(({ data }) => {
setProject(data) setProject(data)
setEditForm({ setEditForm({
owner: data.owner || '', owner: data.owner || '',
repo: data.repo || '',
description: data.description || '', description: data.description || '',
sub_projects: data.sub_projects || [], sub_projects: data.sub_projects || [],
related_projects: data.related_projects || [], related_projects: data.related_projects || [],

View File

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

View File

@@ -14,7 +14,9 @@ export interface Project {
owner: string owner: string
description: string | null description: string | null
owner_id: number owner_id: number
owner_name: string | null
project_code: string | null project_code: string | null
repo: string | null
sub_projects: string[] | null sub_projects: string[] | null
related_projects: string[] | null related_projects: string[] | null
created_at: string created_at: string