feat: add repo field to project editing
This commit is contained in:
@@ -12,12 +12,12 @@ export default function ProjectDetailPage() {
|
|||||||
const [issues, setIssues] = useState<Issue[]>([])
|
const [issues, setIssues] = useState<Issue[]>([])
|
||||||
const [milestones, setMilestones] = useState<Milestone[]>([])
|
const [milestones, setMilestones] = useState<Milestone[]>([])
|
||||||
const [editing, setEditing] = useState(false)
|
const [editing, setEditing] = useState(false)
|
||||||
const [editForm, setEditForm] = useState({ name: '', description: '' })
|
const [editForm, setEditForm] = useState({ name: '', description: '', repo: '' })
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
api.get<Project>(`/projects/${id}`).then(({ data }) => {
|
api.get<Project>(`/projects/${id}`).then(({ data }) => {
|
||||||
setProject(data)
|
setProject(data)
|
||||||
setEditForm({ name: data.name, description: data.description || '' })
|
setEditForm({ name: data.name, description: data.description || '', repo: data.repo || '' })
|
||||||
})
|
})
|
||||||
api.get<ProjectMember[]>(`/projects/${id}/members`).then(({ data }) => setMembers(data))
|
api.get<ProjectMember[]>(`/projects/${id}/members`).then(({ data }) => setMembers(data))
|
||||||
api.get<PaginatedResponse<Issue>>(`/issues?project_id=${id}&page_size=10`).then(({ data }) => setIssues(data.items))
|
api.get<PaginatedResponse<Issue>>(`/issues?project_id=${id}&page_size=10`).then(({ data }) => setIssues(data.items))
|
||||||
@@ -42,6 +42,7 @@ export default function ProjectDetailPage() {
|
|||||||
<form className="inline-form" onSubmit={updateProject}>
|
<form className="inline-form" onSubmit={updateProject}>
|
||||||
<input value={editForm.name} onChange={(e) => setEditForm({ ...editForm, name: e.target.value })} required />
|
<input value={editForm.name} onChange={(e) => setEditForm({ ...editForm, name: e.target.value })} required />
|
||||||
<input value={editForm.description} onChange={(e) => setEditForm({ ...editForm, description: e.target.value })} placeholder="描述" />
|
<input value={editForm.description} onChange={(e) => setEditForm({ ...editForm, description: e.target.value })} placeholder="描述" />
|
||||||
|
<input value={editForm.repo} onChange={(e) => setEditForm({ ...editForm, repo: e.target.value })} placeholder="仓库地址" />
|
||||||
<button type="submit" className="btn-primary">保存</button>
|
<button type="submit" className="btn-primary">保存</button>
|
||||||
<button type="button" className="btn-back" onClick={() => setEditing(false)}>取消</button>
|
<button type="button" className="btn-back" onClick={() => setEditing(false)}>取消</button>
|
||||||
</form>
|
</form>
|
||||||
@@ -49,6 +50,7 @@ export default function ProjectDetailPage() {
|
|||||||
<>
|
<>
|
||||||
<h2>📁 {project.name}</h2>
|
<h2>📁 {project.name}</h2>
|
||||||
<p style={{ color: 'var(--text-dim)', marginTop: 4 }}>{project.description || '暂无描述'}</p>
|
<p style={{ color: 'var(--text-dim)', marginTop: 4 }}>{project.description || '暂无描述'}</p>
|
||||||
|
{project.repo && <p style={{ color: 'var(--text-dim)', marginTop: 4 }}>📦 {project.repo}</p>}
|
||||||
<button className="btn-transition" style={{ marginTop: 8 }} onClick={() => setEditing(true)}>编辑</button>
|
<button className="btn-transition" style={{ marginTop: 8 }} onClick={() => setEditing(true)}>编辑</button>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ export interface Project {
|
|||||||
name: string
|
name: string
|
||||||
description: string | null
|
description: string | null
|
||||||
owner_id: number
|
owner_id: number
|
||||||
|
repo: string | null
|
||||||
created_at: string
|
created_at: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user