@@ -6,16 +6,13 @@ import { Switch } from '@/components/ui/switch'
66import { Badge } from '@/components/ui/badge'
77import { useToast } from '@/components/ui/use-toast'
88import {
9- Github ,
109 Mail ,
1110 Calendar ,
1211 FolderOpen ,
1312 Plus ,
1413 Unlink ,
1514 Loader2 ,
1615 ExternalLink ,
17- Activity ,
18- Clock ,
1916 RefreshCw
2017} from 'lucide-react'
2118import { useState , useEffect , useCallback } from 'react'
@@ -26,24 +23,8 @@ import {
2623 disconnectUserIntegration ,
2724 UserIntegration
2825} from '@/lib/user-settings'
29- import {
30- generateGitHubOAuthUrl ,
31- getGitHubScopes ,
32- revokeGitHubToken ,
33- isGitHubIntegrationHealthy ,
34- formatGitHubWebhookEvent ,
35- getGitHubEventIcon ,
36- type GitHubOAuthConfig
37- } from '@/lib/github-oauth'
3826
3927const availableIntegrations = [
40- {
41- id : 'github' ,
42- name : 'GitHub' ,
43- description : 'Access your repositories and collaborate on code' ,
44- icon : Github ,
45- color : 'bg-gray-900 text-white'
46- } ,
4728 {
4829 id : 'google-drive' ,
4930 name : 'Google Drive' ,
@@ -110,29 +91,6 @@ export default function IntegrationsSettings() {
11091 initializeIntegrations ( )
11192 } , [ session ?. user ?. id , loadIntegrations ] )
11293
113- useEffect ( ( ) => {
114- const urlParams = new URLSearchParams ( window . location . search )
115- const success = urlParams . get ( 'success' )
116- const error = urlParams . get ( 'error' )
117-
118- if ( success === 'github_connected' ) {
119- toast ( {
120- title : "Success" ,
121- description : "GitHub connected successfully!" ,
122- } )
123- window . history . replaceState ( { } , '' , window . location . pathname )
124- loadIntegrations ( )
125- }
126-
127- if ( error ) {
128- toast ( {
129- title : "Error" ,
130- description : decodeURIComponent ( error ) ,
131- variant : "destructive" ,
132- } )
133- window . history . replaceState ( { } , '' , window . location . pathname )
134- }
135- } , [ loadIntegrations , toast ] )
13694
13795 const getIntegrationStatus = useCallback ( ( serviceId : string ) => {
13896 const integration = integrations . find ( integration => integration . service_name === serviceId )
@@ -163,27 +121,6 @@ export default function IntegrationsSettings() {
163121 setConnecting ( serviceId )
164122
165123 try {
166- if ( serviceId === 'github' ) {
167- if ( ! process . env . NEXT_PUBLIC_GITHUB_CLIENT_ID ) {
168- throw new Error ( 'GitHub OAuth not configured. Please check environment variables.' )
169- }
170-
171- const redirectUri = process . env . NEXT_PUBLIC_SITE_URL
172- ? `${ process . env . NEXT_PUBLIC_SITE_URL } /api/auth/github`
173- : `${ window . location . origin } /api/auth/github`
174-
175- const config : GitHubOAuthConfig = {
176- clientId : process . env . NEXT_PUBLIC_GITHUB_CLIENT_ID ,
177- redirectUri : redirectUri ,
178- scopes : getGitHubScopes ( ) ,
179- }
180-
181- console . log ( 'Initiating GitHub OAuth with config:' , config )
182- const authUrl = generateGitHubOAuthUrl ( config )
183- window . location . href = authUrl
184- return
185- }
186-
187124 console . log ( `Connecting ${ serviceId } for user:` , session . user . id )
188125
189126 const success = await upsertUserIntegration ( session . user . id , serviceId , {
@@ -224,17 +161,6 @@ export default function IntegrationsSettings() {
224161 try {
225162 console . log ( `Disconnecting ${ serviceId } for user:` , session . user . id )
226163
227- if ( serviceId === 'github' ) {
228- const integration = getIntegrationStatus ( serviceId )
229- if ( integration ?. connection_data ?. access_token ) {
230- console . log ( 'Revoking GitHub token...' )
231- const revoked = await revokeGitHubToken ( integration . connection_data . access_token )
232- if ( ! revoked ) {
233- console . warn ( 'Failed to revoke GitHub token, but continuing with disconnect' )
234- }
235- }
236- }
237-
238164 const success = await disconnectUserIntegration ( session . user . id , serviceId )
239165
240166 if ( success ) {
@@ -288,8 +214,6 @@ export default function IntegrationsSettings() {
288214 )
289215 }
290216
291- const githubIntegration = getIntegrationStatus ( 'github' )
292-
293217 return (
294218 < div className = "space-y-6" >
295219 < div className = "flex items-center justify-between" >
@@ -330,7 +254,7 @@ export default function IntegrationsSettings() {
330254 const isConnecting = connecting === service . id
331255 const isDisconnecting = disconnecting === service . id
332256 const isProcessing = isConnecting || isDisconnecting
333- const isHealthy = service . id === 'github' && integration ? isGitHubIntegrationHealthy ( integration ) : isConnected
257+ const isHealthy = isConnected
334258
335259 console . log ( `Service ${ service . id } : connected=${ isConnected } , integration=` , integration )
336260
@@ -362,11 +286,6 @@ export default function IntegrationsSettings() {
362286 Connected { new Date ( integration . connection_data . connected_at ) . toLocaleDateString ( ) }
363287 </ p >
364288 ) }
365- { service . id === 'github' && isConnected && integration ?. connection_data ?. username && (
366- < p className = "text-xs text-muted-foreground" >
367- GitHub: @{ integration . connection_data . username }
368- </ p >
369- ) }
370289 { integration ?. connection_data ?. simulated && (
371290 < p className = "text-xs text-yellow-600" >
372291 Simulated connection
@@ -413,74 +332,6 @@ export default function IntegrationsSettings() {
413332 </ CardContent >
414333 </ Card >
415334
416- { githubIntegration ?. is_connected && (
417- < Card >
418- < CardHeader >
419- < CardTitle className = "flex items-center gap-2" >
420- < Activity className = "h-5 w-5" />
421- GitHub Integration Status
422- </ CardTitle >
423- < CardDescription >
424- Monitor your GitHub integration health and recent activity.
425- </ CardDescription >
426- </ CardHeader >
427- < CardContent >
428- < div className = "space-y-4" >
429- < div className = "flex items-center justify-between" >
430- < span className = "text-sm font-medium" > Connection Status</ span >
431- < div className = "flex items-center gap-2" >
432- < div className = { `h-2 w-2 rounded-full ${ isGitHubIntegrationHealthy ( githubIntegration ) ? 'bg-green-500' : 'bg-yellow-500' } ` } > </ div >
433- < span className = "text-sm text-muted-foreground" >
434- { isGitHubIntegrationHealthy ( githubIntegration ) ? 'Healthy' : 'Needs Attention' }
435- </ span >
436- </ div >
437- </ div >
438-
439- { githubIntegration . connection_data ?. github_user_id && (
440- < div className = "flex items-center justify-between" >
441- < span className = "text-sm font-medium" > GitHub User ID</ span >
442- < span className = "text-sm text-muted-foreground" >
443- { githubIntegration . connection_data . github_user_id }
444- </ span >
445- </ div >
446- ) }
447-
448- { githubIntegration . last_sync_at && (
449- < div className = "flex items-center justify-between" >
450- < span className = "text-sm font-medium flex items-center gap-2" >
451- < Clock className = "h-4 w-4" />
452- Last Sync
453- </ span >
454- < span className = "text-sm text-muted-foreground" >
455- { new Date ( githubIntegration . last_sync_at ) . toLocaleString ( ) }
456- </ span >
457- </ div >
458- ) }
459-
460- { githubIntegration . connection_data ?. last_webhook_event && (
461- < div className = "space-y-2" >
462- < span className = "text-sm font-medium" > Recent Activity</ span >
463- < div className = "p-3 bg-muted rounded-lg" >
464- < div className = "flex items-start gap-2" >
465- < span className = "text-lg" >
466- { getGitHubEventIcon ( githubIntegration . connection_data . last_webhook_event . type ) }
467- </ span >
468- < div className = "flex-1" >
469- < p className = "text-sm" >
470- { formatGitHubWebhookEvent ( githubIntegration . connection_data . last_webhook_event ) }
471- </ p >
472- < p className = "text-xs text-muted-foreground" >
473- { new Date ( githubIntegration . connection_data . last_webhook_event . timestamp ) . toLocaleString ( ) }
474- </ p >
475- </ div >
476- </ div >
477- </ div >
478- </ div >
479- ) }
480- </ div >
481- </ CardContent >
482- </ Card >
483- ) }
484335
485336 < Card >
486337 < CardHeader >
0 commit comments