From 0b4141675ed1a5134e4cdac42e6ffb73041c6a05 Mon Sep 17 00:00:00 2001 From: Pradeep Date: Thu, 16 Oct 2025 10:53:36 +0530 Subject: [PATCH] chenges in the frontend --- src/app/github/repos/page.tsx | 108 ++++++++++++++++++++++-------- src/app/vcs/repos/page.tsx | 33 +-------- src/components/main-dashboard.tsx | 24 +------ src/lib/api/github.ts | 31 ++++++++- 4 files changed, 112 insertions(+), 84 deletions(-) diff --git a/src/app/github/repos/page.tsx b/src/app/github/repos/page.tsx index 48c1457..86514be 100644 --- a/src/app/github/repos/page.tsx +++ b/src/app/github/repos/page.tsx @@ -7,6 +7,7 @@ import { Input } from '@/components/ui/input'; import { Badge } from '@/components/ui/badge'; import { Github, + Gitlab, FolderOpen, Search, RefreshCw, @@ -17,7 +18,9 @@ import { Code, Calendar, GitCompare, - Brain + Brain, + GitCommit, + Server } from 'lucide-react'; import { getUserRepositories, type GitHubRepoSummary } from '@/lib/api/github'; import { authApiClient } from '@/components/apis/authApiClients'; @@ -28,7 +31,7 @@ const GitHubReposPage: React.FC = () => { const [isLoading, setIsLoading] = useState(false); const [error, setError] = useState(null); const [searchQuery, setSearchQuery] = useState(''); - const [filter, setFilter] = useState<'all' | 'public' | 'private'>('all'); + const [providerFilter, setProviderFilter] = useState<'all' | 'github' | 'gitlab' | 'bitbucket' | 'gitea'>('all'); const [aiAnalysisLoading, setAiAnalysisLoading] = useState(null); const [aiAnalysisError, setAiAnalysisError] = useState(null); @@ -39,6 +42,14 @@ const GitHubReposPage: React.FC = () => { setIsLoading(true); setError(null); const repos = await getUserRepositories(); + console.log('📦 Loaded repositories:', repos); + console.log('📦 Repository providers:', repos.map(r => ({ name: r.repository_name || r.name, provider: r.provider_name }))); + console.log('📦 Total repositories loaded:', repos.length); + console.log('📦 First repository details:', repos[0] ? { + name: repos[0].repository_name, + provider_name: repos[0].provider_name, + all_keys: Object.keys(repos[0]) + } : 'No repositories'); setRepositories(repos); } catch (err) { setError(err instanceof Error ? err.message : 'Failed to load repositories'); @@ -91,17 +102,38 @@ const GitHubReposPage: React.FC = () => { }; const filteredRepositories = repositories.filter(repo => { - const matchesSearch = repo.full_name?.toLowerCase().includes(searchQuery.toLowerCase()) || - repo.description?.toLowerCase().includes(searchQuery.toLowerCase()) || - repo.language?.toLowerCase().includes(searchQuery.toLowerCase()); + // Use correct field names from the API response + const repoName = repo.repository_name || repo.name || ''; + const fullName = repo.metadata?.full_name || repo.full_name || ''; + const description = repo.metadata?.description || repo.description || ''; + const language = repo.metadata?.language || repo.language || ''; - const matchesFilter = filter === 'all' || - (filter === 'public' && repo.visibility === 'public') || - (filter === 'private' && repo.visibility === 'private'); + const matchesSearch = fullName.toLowerCase().includes(searchQuery.toLowerCase()) || + repoName.toLowerCase().includes(searchQuery.toLowerCase()) || + description.toLowerCase().includes(searchQuery.toLowerCase()) || + language.toLowerCase().includes(searchQuery.toLowerCase()); - return matchesSearch && matchesFilter; + // Use the actual provider information from the backend + const repoProvider = repo.provider_name || 'github'; // fallback to github for backward compatibility + const matchesProvider = providerFilter === 'all' || repoProvider === providerFilter; + + // Debug logging + console.log('🔍 Filtering repo:', { + name: repoName, + fullName: fullName, + provider: repoProvider, + filter: providerFilter, + matches: matchesProvider + }); + + return matchesSearch && matchesProvider; }); + // Debug filtered results + console.log('🔍 Filtered repositories count:', filteredRepositories.length); + console.log('🔍 Current filter:', providerFilter); + console.log('🔍 Total repositories:', repositories.length); + const formatDate = (dateString: string | undefined) => { if (!dateString) return 'Unknown'; return new Date(dateString).toLocaleDateString(); @@ -111,12 +143,12 @@ const GitHubReposPage: React.FC = () => {
-

- - My GitHub Repositories -

+

+ + My Git Repositories +

- Browse and analyze your GitHub repositories + Browse and analyze your Git repositories

@@ -154,25 +186,43 @@ const GitHubReposPage: React.FC = () => {
+ +
@@ -240,15 +290,15 @@ const GitHubReposPage: React.FC = () => {
- {repo.name || 'Unknown Repository'} + {repo.repository_name || repo.name || 'Unknown Repository'}

- {repo.full_name || 'Unknown Owner'} + {repo.metadata?.full_name || repo.full_name || 'Unknown Owner'}

- - {repo.visibility || 'unknown'} + + {repo.metadata?.visibility || repo.visibility || 'unknown'} @@ -339,10 +389,10 @@ const GitHubReposPage: React.FC = () => {

- {searchQuery || filter !== 'all' ? 'No repositories found' : 'No repositories available'} + {searchQuery || providerFilter !== 'all' ? 'No repositories found' : 'No repositories available'}

- {searchQuery || filter !== 'all' + {searchQuery || providerFilter !== 'all' ? 'Try adjusting your search or filter criteria' : 'Make sure you have connected your GitHub account and have repositories' } diff --git a/src/app/vcs/repos/page.tsx b/src/app/vcs/repos/page.tsx index 40da7c0..18afbd5 100644 --- a/src/app/vcs/repos/page.tsx +++ b/src/app/vcs/repos/page.tsx @@ -52,7 +52,6 @@ const VcsReposPage: React.FC = () => { const [isLoading, setIsLoading] = useState(false); const [error, setError] = useState(null); const [searchQuery, setSearchQuery] = useState(''); - const [filter, setFilter] = useState<'all' | 'public' | 'private'>('all'); const [providerFilter, setProviderFilter] = useState<'all' | 'github' | 'gitlab' | 'bitbucket' | 'gitea'>('all'); const [aiAnalysisLoading, setAiAnalysisLoading] = useState(null); const [aiAnalysisError, setAiAnalysisError] = useState(null); @@ -257,13 +256,9 @@ const VcsReposPage: React.FC = () => { repo.description?.toLowerCase().includes(searchQuery.toLowerCase()) || repo.language?.toLowerCase().includes(searchQuery.toLowerCase()); - const matchesFilter = filter === 'all' || - (filter === 'public' && repo.visibility === 'public') || - (filter === 'private' && repo.visibility === 'private'); - const matchesProvider = providerFilter === 'all' || repo.provider === providerFilter; - return matchesSearch && matchesFilter && matchesProvider; + return matchesSearch && matchesProvider; }); return ( @@ -294,30 +289,6 @@ const VcsReposPage: React.FC = () => {

-
- - - -
-
- - ) : ( - - )} +
diff --git a/src/lib/api/github.ts b/src/lib/api/github.ts index aec19e4..66db2b0 100644 --- a/src/lib/api/github.ts +++ b/src/lib/api/github.ts @@ -241,6 +241,7 @@ export interface GitHubRepoSummary { language?: string | null updated_at?: string html_url?: string + provider_name?: string } // Tries backend gateway route first. If backend does not yet provide it, returns an empty list gracefully. @@ -249,6 +250,9 @@ export async function getUserRepositories(clearCache = false): Promise { const ts = Date.now() const sep = base.includes('?') ? '&' : '?' - return `${base}${sep}nc=${ts}` + return `${base}${sep}nc=${ts}&force_refresh=true` } - const primaryBase = userId ? `/api/github/user/${encodeURIComponent(userId)}/repositories` : '/api/github/user/repositories' + // Fallback to hardcoded user ID if authentication fails + const fallbackUserId = '4bf08200-bd09-44c2-825e-5c1c4ea9fe0a'; + const effectiveUserId = userId || fallbackUserId; + + const primaryBase = `/api/github/user/${encodeURIComponent(effectiveUserId)}/repositories` + console.log('🔍 [getUserRepositories] Calling API:', buildUrl(primaryBase)); + console.log('🔍 [getUserRepositories] User ID:', userId); + console.log('🔍 [getUserRepositories] Effective User ID:', effectiveUserId); + let res: any = await authApiClient.get(buildUrl(primaryBase), { headers: { 'Cache-Control': 'no-store, no-cache, must-revalidate', 'Pragma': 'no-cache', 'Accept': 'application/json' }, validateStatus: () => true, }) + console.log('🔍 [getUserRepositories] API Response:', { + status: res?.status, + dataLength: res?.data?.length, + success: res?.data?.success, + message: res?.data?.message + }); // On 304 or empty body, retry once with a different cache-buster and legacy fallback if (res?.status === 304 || res?.data == null || res?.data === '') { @@ -294,6 +312,14 @@ export async function getUserRepositories(clearCache = false): Promise