11import { useState } from "react" ;
22import { Header } from "../components/Header" ;
33import { formatRelative } from "../components/TaskDetailFields" ;
4- import { Dialog , DialogContent , DialogDescription , DialogHeader , DialogTitle } from "../components/ui/dialog" ;
4+ import { Button } from "../components/ui/button" ;
5+ import { Dialog , DialogContent , DialogDescription , DialogFooter , DialogHeader , DialogTitle } from "../components/ui/dialog" ;
56import { useCreateRepository , useDeleteRepository , useRepositories } from "../hooks/useRepositories" ;
67
78export function RepositoriesPage ( ) {
@@ -11,6 +12,7 @@ export function RepositoriesPage() {
1112 const [ showDialog , setShowDialog ] = useState ( false ) ;
1213 const [ newName , setNewName ] = useState ( "" ) ;
1314 const [ newUrl , setNewUrl ] = useState ( "" ) ;
15+ const [ repoToDelete , setRepoToDelete ] = useState < any | null > ( null ) ;
1416
1517 async function handleAdd ( ) {
1618 if ( ! newName . trim ( ) || ! newUrl . trim ( ) ) return ;
@@ -20,8 +22,10 @@ export function RepositoriesPage() {
2022 setShowDialog ( false ) ;
2123 }
2224
23- async function handleDelete ( id : string ) {
24- await deleteRepo . mutateAsync ( id ) ;
25+ async function handleDelete ( ) {
26+ if ( ! repoToDelete ) return ;
27+ await deleteRepo . mutateAsync ( repoToDelete . id ) ;
28+ setRepoToDelete ( null ) ;
2529 }
2630
2731 return (
@@ -61,7 +65,7 @@ export function RepositoriesPage() {
6165 < span className = "text-[11px] font-mono text-content-tertiary truncate hidden sm:inline" > { repo . url } </ span >
6266 </ div >
6367 < button
64- onClick = { ( ) => handleDelete ( repo . id ) }
68+ onClick = { ( ) => setRepoToDelete ( repo ) }
6569 disabled = { deleteRepo . isPending }
6670 className = "text-xs text-content-tertiary hover:text-error transition-colors shrink-0 ml-3 disabled:opacity-50"
6771 >
@@ -125,6 +129,26 @@ export function RepositoriesPage() {
125129 </ div >
126130 </ DialogContent >
127131 </ Dialog >
132+
133+ < Dialog open = { ! ! repoToDelete } onOpenChange = { ( open ) => ! open && setRepoToDelete ( null ) } >
134+ < DialogContent className = "sm:max-w-sm" >
135+ < DialogHeader >
136+ < DialogTitle > Remove Repository</ DialogTitle >
137+ < DialogDescription >
138+ Remove < span className = "font-mono text-content-primary" > { repoToDelete ?. name } </ span > from this workspace. Existing tasks linked to this
139+ repository will lose their repository association.
140+ </ DialogDescription >
141+ </ DialogHeader >
142+ < DialogFooter >
143+ < Button variant = "outline" onClick = { ( ) => setRepoToDelete ( null ) } >
144+ Cancel
145+ </ Button >
146+ < Button variant = "destructive" onClick = { handleDelete } disabled = { deleteRepo . isPending } >
147+ { deleteRepo . isPending ? "Removing..." : "Remove" }
148+ </ Button >
149+ </ DialogFooter >
150+ </ DialogContent >
151+ </ Dialog >
128152 </ div >
129153 ) ;
130154}
0 commit comments