@@ -27,10 +27,12 @@ import type { SyncRepoRequest, SyncRepoResponse } from "@/types/sync";
27
27
import { OwnerCombobox , OrganizationCombobox } from "./RepositoryComboboxes" ;
28
28
import type { RetryRepoRequest , RetryRepoResponse } from "@/types/retry" ;
29
29
import AddRepositoryDialog from "./AddRepositoryDialog" ;
30
+ import type { ConfigApiResponse } from "@/types/config" ;
30
31
31
32
export default function Repository ( ) {
32
33
const [ repositories , setRepositories ] = useState < Repository [ ] > ( [ ] ) ;
33
34
const [ isLoading , setIsLoading ] = useState ( true ) ;
35
+ const [ isGitHubConfigured , setIsGitHubConfigured ] = useState < boolean > ( true ) ;
34
36
const { user } = useAuth ( ) ;
35
37
const { filter, setFilter } = useFilterParams ( {
36
38
searchTerm : "" ,
@@ -76,8 +78,27 @@ export default function Repository() {
76
78
const fetchRepositories = useCallback ( async ( ) => {
77
79
if ( ! user ) return ;
78
80
79
- setIsLoading ( true ) ;
81
+ // First, check if GitHub is configured by fetching the user's config
80
82
try {
83
+ const configResponse = await apiRequest < ConfigApiResponse > (
84
+ `/config?userId=${ user . id } ` ,
85
+ {
86
+ method : "GET" ,
87
+ }
88
+ ) ;
89
+
90
+ // Check if GitHub credentials are configured
91
+ if ( ! configResponse ?. githubConfig ?. username || ! configResponse ?. githubConfig ?. token ) {
92
+ setIsLoading ( false ) ;
93
+ setIsGitHubConfigured ( false ) ;
94
+ // Don't show error toast for unconfigured GitHub - just return silently
95
+ return false ;
96
+ }
97
+
98
+ // GitHub is configured
99
+ setIsGitHubConfigured ( true ) ;
100
+ setIsLoading ( true ) ;
101
+
81
102
const response = await apiRequest < RepositoryApiResponse > (
82
103
`/github/repositories?userId=${ user . id } ` ,
83
104
{
@@ -436,16 +457,31 @@ export default function Repository() {
436
457
</ Button >
437
458
</ div >
438
459
439
- < RepositoryTable
440
- repositories = { repositories }
441
- isLoading = { isLoading || ! connected }
442
- filter = { filter }
443
- setFilter = { setFilter }
444
- onMirror = { handleMirrorRepo }
445
- onSync = { handleSyncRepo }
446
- onRetry = { handleRetryRepoAction }
447
- loadingRepoIds = { loadingRepoIds }
448
- />
460
+ { ! isGitHubConfigured ? (
461
+ < div className = "flex flex-col items-center justify-center p-8 border border-dashed rounded-md" >
462
+ < h3 className = "text-xl font-semibold mb-2" > GitHub Not Configured</ h3 >
463
+ < p className = "text-muted-foreground text-center mb-4" >
464
+ You need to configure your GitHub credentials before you can fetch and mirror repositories.
465
+ </ p >
466
+ < Button
467
+ variant = "default"
468
+ onClick = { ( ) => window . location . href = "/config" }
469
+ >
470
+ Go to Configuration
471
+ </ Button >
472
+ </ div >
473
+ ) : (
474
+ < RepositoryTable
475
+ repositories = { repositories }
476
+ isLoading = { isLoading || ! connected }
477
+ filter = { filter }
478
+ setFilter = { setFilter }
479
+ onMirror = { handleMirrorRepo }
480
+ onSync = { handleSyncRepo }
481
+ onRetry = { handleRetryRepoAction }
482
+ loadingRepoIds = { loadingRepoIds }
483
+ />
484
+ ) }
449
485
450
486
< AddRepositoryDialog
451
487
onAddRepository = { handleAddRepository }
0 commit comments