forked from AOSSIE-Org/OrgExplorer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOverviewPage.jsx
More file actions
209 lines (190 loc) · 9.66 KB
/
Copy pathOverviewPage.jsx
File metadata and controls
209 lines (190 loc) · 9.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
import React, { useEffect, useState, useRef } from 'react'
import { useNavigate } from 'react-router-dom'
import { FiExternalLink, FiShare2, FiArrowRight } from 'react-icons/fi'
import { useApp } from '../context/AppContext'
import { C, StatCard, HealthBar } from '../components/UI'
import SocialShareButton from '../components/SocialShareButton';
import { AiOutlineInfoCircle } from "react-icons/ai";
import AnalysisBanner from '../components/AnalysisBanner'
import { OverviewSkeleton } from '../components/Orgexplorerskeletons'
import {formatNumber} from '../utils/formatNumber'
const LANG_COLORS = ['#22c55e', '#f5c518', '#3b82f6', '#ef4444', '#a855f7', '#f97316', '#06b6d4']
const fmt = n => n > 999 ? (n / 1000).toFixed(1) + 'k' : String(n)
export default function OverviewPage() {
const { orgs, model, totalRepo, isComplete, loading, runFullExplore } = useApp()
const navigate = useNavigate()
const [open, setOpen] = useState(false)
const infoRef = useRef(null)
useEffect(() => {
function handleClickOutside(event) {
if (infoRef.current && !infoRef.current.contains(event.target)) {
setOpen(false)
}
}
document.addEventListener('mousedown', handleClickOutside)
return () => {
document.removeEventListener('mousedown', handleClickOutside)
}
}, [])
if(loading) return <OverviewSkeleton />
if (!model) return null
const { totalRepos } = model
const isMulti = orgs.length > 1
const totalStars = totalRepos.reduce((s, r) => s + r.stargazers_count, 0)
const totalForks = totalRepos.reduce((s, r) => s + r.forks_count, 0)
const activeRepos = totalRepos.filter(r => r.activityClassification === 'Thriving' || r.activityClassification === 'Active').length
const langMap = {}
totalRepos.forEach(r => { if (r.language) langMap[r.language] = (langMap[r.language] || 0) + 1 })
const langs = Object.entries(langMap).sort((a, b) => b[1] - a[1]).slice(0, 7)
const langTotal = langs.reduce((s, [, c]) => s + c, 0)
const topRepos = [...totalRepos].sort((a, b) => b.healthScore - a.healthScore).slice(0, 5)
const NavCard = ({ to, label, sub }) => (
<div
onClick={() => navigate(to)}
onMouseEnter={e => e.currentTarget.style.borderColor = 'var(--accent)'}
onMouseLeave={e => e.currentTarget.style.borderColor = 'var(--border)'}
style={{ ...C.card, cursor: 'pointer', transition: 'border-color .2s' }}
>
<div style={{ fontWeight: 600, marginBottom: 4, fontSize: 14 }}>{label}</div>
<div style={{ fontSize: 12, color: 'var(--text2)', marginBottom: 12, minHeight: 32 }}>{sub}</div>
<span style={{ fontSize: 12, color: 'var(--accent)', fontWeight: 600, display: 'flex', alignItems: 'center', gap: 4 }}>
View {label} <FiArrowRight size={12} />
</span>
</div>
)
return (
<div style={{ padding: '32px 24px', maxWidth: 1100, margin: '0 auto' }} className="fade-up">
<AnalysisBanner
page="overview"
description="Organization insights are computed from a representative subset to balance speed and API usage. Connect a PAT to analyze every repository and access complete results."
analysisStatus={isComplete ? 'complete' : 'standard'}
loading={loading}
onRun={runFullExplore}
/>
{/* Org identity bar */}
<div style={{ display: 'flex', alignItems: 'center', gap: 14, marginBottom: 28 }}>
{isMulti ? (
<div style={{ display: 'flex' }}>
{orgs.slice(0, 3).map((o, i) => o.avatar_url && (
<img key={o.login} src={o.avatar_url} alt={o.login}
style={{ width: 36, height: 36, borderRadius: '50%', border: '2px solid var(--bg)', marginLeft: i ? -10 : 0 }} />
))}
</div>
) : (
orgs[0]?.avatar_url && (
<img src={orgs[0].avatar_url} alt="" style={{ width: 56, height: 56 }} />
)
)}
<div style={{ flex: 1 }}>
<h1 style={{ fontSize: 22, fontWeight: 700 }}>
{isMulti ? orgs.map(o => o.login).join(' + ') : (orgs[0]?.name || orgs[0]?.login)}
</h1>
<p style={{ fontSize: 13, color: 'var(--text2)', marginTop: 2 }}>
{isMulti
? `${orgs.length} organizations — combined portfolio view`
: (orgs[0]?.description || `@${orgs[0]?.login}`)}
</p>
</div>
<div style={{ display: 'flex', gap: 8 }}>
{!isMulti && orgs[0]?.html_url && (
<a href={orgs[0].html_url} target="_blank" rel="noreferrer"
style={{ ...C.btn('primary'), display: 'flex', alignItems: 'center', gap: 6, fontSize: 12 }}>
<FiExternalLink size={13} /> View on GitHub
</a>
)}
<SocialShareButton
theme="dark"
buttonStyle="ghost"
title={isMulti ? `OrgExplorer: ${orgs.map(o => o.login).join(' + ')}` : `OrgExplorer: ${orgs[0]?.name || orgs[0]?.login}`}
description={isMulti ? `${orgs.length} organizations — combined portfolio view` : (orgs[0]?.description || `@${orgs[0]?.login}`)}
/>
</div>
</div>
{/* Stats */}
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(4,1fr)', gap: 12, marginBottom: 24 }}>
<StatCard label="Total Repos" value={formatNumber(totalRepo)} />
<StatCard label="Total Stars" value={formatNumber(totalStars)} />
<StatCard label="Total Forks" value={formatNumber(totalForks)} />
<StatCard label="Active Repos" value={formatNumber(activeRepos)} sub={`${Math.round(activeRepos / totalRepo * 100)}% of total`} />
</div>
{/* Language + top repos */}
<div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 20, marginBottom: 20 }}>
<div style={C.card}>
<div style={{ fontWeight: 600, marginBottom: 4 }}>Language Distribution</div>
<div style={{ ...C.label, marginBottom: 16 }}>Technology Stack Analysis</div>
<div style={{ height: 10, borderRadius: 5, overflow: 'hidden', display: 'flex', marginBottom: 16 }}>
{langs.map(([lang, count], i) => (
<div key={lang} style={{ flex: count / langTotal, background: LANG_COLORS[i] }} title={lang} />
))}
</div>
<div style={{ display: 'flex', flexWrap: 'wrap', gap: 12 }}>
{langs.map(([lang, count], i) => (
<div key={lang} style={{ display: 'flex', alignItems: 'center', gap: 5 }}>
<div style={{ width: 8, height: 8, borderRadius: '50%', background: LANG_COLORS[i] }} />
<span style={{ fontSize: 12, color: 'var(--text2)' }}>
{lang} <strong style={{ color: 'var(--text)' }}>{Math.round(count / langTotal * 100)}%</strong>
</span>
</div>
))}
</div>
</div>
<div
style={C.card}
className="relative"
>
<div className="flex justify-between items-center font-semibold" ref={infoRef}>
<p>High Impact Repositories</p>
<button
onMouseEnter={()=>setOpen(true)}
onMouseLeave={()=>setOpen(false)}
className="p-3 rounded-full hover:bg-(--bg) transition"
>
<AiOutlineInfoCircle className="text-(--text) cursor-pointer" />
</button>
</div>
{open && (
<div
className="absolute top-16 right-2 w-80 z-50 rounded-lg border-2 border-(--border) bg-(--surface) p-4 shadow-xl text-xs"
>
<strong>Health Score</strong> estimates the overall health of a repository on a scale of 0 – 100.
<ul className="list-disc ml-4 mt-2 space-y-1">
<li>
<strong>Activity (40%)</strong> – How recently the repository has been updated.
</li>
<li>
<strong>Issue Health (30%)</strong> – Balance between open issues and maintenance.
</li>
<li>
<strong>Contributor Diversity (30%)</strong> – Number of active contributors.
</li>
</ul>
<p className="mt-2 text-xs text-(--text2)">
Higher scores indicate healthier and more actively maintained repositories.
</p>
</div>
)}
<div style={{ ...C.label, marginBottom: 16 }}>By Composite Health Score</div>
<div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
{topRepos.map(r => (
<div key={r.id}>
<div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: 4 }}>
<span style={{ fontSize: 12, fontWeight: 500 }}>{r.name}</span>
</div>
<HealthBar score={r.healthScore} />
</div>
))}
</div>
</div>
</div>
{/* Nav cards */}
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(3,1fr)', gap: 14 }}>
<NavCard to="/repositories" label="Repositories" sub="Explore and sort repos by health, and activity classification state" />
<NavCard to="/contributors" label="Contributors" sub="Analyze contribution patterns, bus factor, and connector signals" />
<NavCard to="/network" label="Network Graph" sub="Visualize contributor-repository relationships with D3 force graph" />
<NavCard to="/analytics" label="Analytics" sub="Time-series PR and issue velocity — weekly and monthly trends" />
<NavCard to="/governance" label="Governance" sub="Dead issues, zombie PRs, risky repos, license compliance" />
<NavCard to="/settings" label="Settings" sub="PAT authentication, API quota monitoring, cache management" />
</div>
</div>
)
}