22
33import { Button } from "@/components/ui/button"
44import type { ColumnDef } from "@tanstack/react-table"
5- import { ArrowUpDown , Clock , Loader2 , CheckCircle2 , XCircle , Trash2 , Check , ListFilter } from "lucide-react"
5+ import { ArrowUpDown , Clock , Loader2 , CheckCircle2 , Check , ListFilter } from "lucide-react"
66import Image from "next/image"
77import { Tooltip , TooltipContent , TooltipProvider , TooltipTrigger } from "@/components/ui/tooltip"
88import { cn , getRepoImageSrc } from "@/lib/utils"
9- import { RepoIndexingStatus } from "@sourcebot/db" ;
109import { DropdownMenu , DropdownMenuContent , DropdownMenuItem , DropdownMenuTrigger } from "@/components/ui/dropdown-menu"
1110import Link from "next/link"
1211import { getBrowsePath } from "../browse/hooks/utils"
1312
13+ export type RepoStatus = 'syncing' | 'indexed' | 'not-indexed' ;
14+
1415export type RepositoryColumnInfo = {
1516 repoId : number
1617 repoName : string ;
1718 repoDisplayName : string
1819 imageUrl ?: string
19- repoIndexingStatus : RepoIndexingStatus
20+ status : RepoStatus
2021 lastIndexed : string
2122}
2223
23- const statusLabels = {
24- [ RepoIndexingStatus . NEW ] : "Queued" ,
25- [ RepoIndexingStatus . IN_INDEX_QUEUE ] : "Queued" ,
26- [ RepoIndexingStatus . INDEXING ] : "Indexing" ,
27- [ RepoIndexingStatus . INDEXED ] : "Indexed" ,
28- [ RepoIndexingStatus . FAILED ] : "Failed" ,
29- [ RepoIndexingStatus . IN_GC_QUEUE ] : "Deleting" ,
30- [ RepoIndexingStatus . GARBAGE_COLLECTING ] : "Deleting" ,
31- [ RepoIndexingStatus . GARBAGE_COLLECTION_FAILED ] : "Deletion Failed"
24+ const statusLabels : Record < RepoStatus , string > = {
25+ 'syncing' : "Syncing" ,
26+ 'indexed' : "Indexed" ,
27+ 'not-indexed' : "Pending" ,
3228} ;
3329
34- const StatusIndicator = ( { status } : { status : RepoIndexingStatus } ) => {
30+ const StatusIndicator = ( { status } : { status : RepoStatus } ) => {
3531 let icon = null
3632 let description = ""
3733 let className = ""
3834
3935 switch ( status ) {
40- case RepoIndexingStatus . NEW :
41- case RepoIndexingStatus . IN_INDEX_QUEUE :
42- icon = < Clock className = "h-3.5 w-3.5" />
43- description = "Repository is queued for indexing"
44- className = "text-yellow-600 bg-yellow-50 dark:bg-yellow-900/20 dark:text-yellow-400"
45- break
46- case RepoIndexingStatus . INDEXING :
36+ case 'syncing' :
4737 icon = < Loader2 className = "h-3.5 w-3.5 animate-spin" />
48- description = "Repository is being indexed "
38+ description = "Repository is currently syncing "
4939 className = "text-blue-600 bg-blue-50 dark:bg-blue-900/20 dark:text-blue-400"
5040 break
51- case RepoIndexingStatus . INDEXED :
41+ case 'indexed' :
5242 icon = < CheckCircle2 className = "h-3.5 w-3.5" />
53- description = "Repository has been successfully indexed"
43+ description = "Repository has been successfully indexed and is up to date "
5444 className = "text-green-600 bg-green-50 dark:bg-green-900/20 dark:text-green-400"
5545 break
56- case RepoIndexingStatus . FAILED :
57- icon = < XCircle className = "h-3.5 w-3.5" />
58- description = "Repository indexing failed"
59- className = "text-red-600 bg-red-50 dark:bg-red-900/20 dark:text-red-400"
60- break
61- case RepoIndexingStatus . IN_GC_QUEUE :
62- case RepoIndexingStatus . GARBAGE_COLLECTING :
63- icon = < Trash2 className = "h-3.5 w-3.5" />
64- description = "Repository is being deleted"
65- className = "text-gray-600 bg-gray-50 dark:bg-gray-900/20 dark:text-gray-400"
66- break
67- case RepoIndexingStatus . GARBAGE_COLLECTION_FAILED :
68- icon = < XCircle className = "h-3.5 w-3.5" />
69- description = "Repository deletion failed"
70- className = "text-red-600 bg-red-50 dark:bg-red-900/20 dark:text-red-400"
46+ case 'not-indexed' :
47+ icon = < Clock className = "h-3.5 w-3.5" />
48+ description = "Repository is pending initial sync"
49+ className = "text-yellow-600 bg-yellow-50 dark:bg-yellow-900/20 dark:text-yellow-400"
7150 break
7251 }
7352
@@ -130,9 +109,9 @@ export const columns = (domain: string): ColumnDef<RepositoryColumnInfo>[] => [
130109 } ,
131110 } ,
132111 {
133- accessorKey : "repoIndexingStatus " ,
112+ accessorKey : "status " ,
134113 header : ( { column } ) => {
135- const uniqueLabels = Array . from ( new Set ( Object . values ( statusLabels ) ) ) ;
114+ const uniqueLabels = Object . values ( statusLabels ) ;
136115 const currentFilter = column . getFilterValue ( ) as string | undefined ;
137116
138117 return (
@@ -173,12 +152,12 @@ export const columns = (domain: string): ColumnDef<RepositoryColumnInfo>[] => [
173152 )
174153 } ,
175154 cell : ( { row } ) => {
176- return < StatusIndicator status = { row . original . repoIndexingStatus } />
155+ return < StatusIndicator status = { row . original . status } />
177156 } ,
178157 filterFn : ( row , id , value ) => {
179158 if ( value === undefined ) return true ;
180159
181- const status = row . getValue ( id ) as RepoIndexingStatus ;
160+ const status = row . getValue ( id ) as RepoStatus ;
182161 return statusLabels [ status ] === value ;
183162 } ,
184163 } ,
@@ -191,14 +170,14 @@ export const columns = (domain: string): ColumnDef<RepositoryColumnInfo>[] => [
191170 onClick = { ( ) => column . toggleSorting ( column . getIsSorted ( ) === "asc" ) }
192171 className = "px-0 font-medium hover:bg-transparent focus:bg-transparent active:bg-transparent focus-visible:ring-0 focus-visible:ring-offset-0"
193172 >
194- Last Indexed
173+ Last Synced
195174 < ArrowUpDown className = "ml-2 h-3.5 w-3.5" />
196175 </ Button >
197176 </ div >
198177 ) ,
199178 cell : ( { row } ) => {
200179 if ( ! row . original . lastIndexed ) {
201- return < div > - </ div > ;
180+ return < div className = "text-muted-foreground" > Never </ div > ;
202181 }
203182 const date = new Date ( row . original . lastIndexed )
204183 return (
0 commit comments