-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
810 lines (753 loc) · 38 KB
/
index.html
File metadata and controls
810 lines (753 loc) · 38 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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>GitHub Dashboard</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@tabler/icons-webfont@3.30.0/dist/tabler-icons.min.css" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap" rel="stylesheet" />
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%23ffd542' d='M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.012 8.012 0 0 0 16 8c0-4.42-3.58-8-8-8z'/%3E%3C/svg%3E" />
<script src="https://cdn.tailwindcss.com"></script>
<script>
tailwind.config = {
theme: {
extend: {
colors: {
base: '#0a0d12',
base2: '#0d1117',
panel: '#11161d',
panel2: '#161c25',
panelHover: '#1a212c',
line: '#232b36',
line2: '#30394a',
fg: '#e6edf3',
fg2: '#b1bac4',
muted: '#6e7781',
accent: '#ffd542',
accentDark: '#d9b21b',
ok: '#3fb950',
danger: '#f85149',
warn: '#d29922',
purple: '#bc8cff',
},
fontFamily: {
sans: ['Inter', '-apple-system', 'BlinkMacSystemFont', '"Segoe UI"', 'system-ui', 'sans-serif'],
},
animation: {
shimmer: 'shimmer 1.4s infinite',
modalIn: 'modalIn 0.12s ease-out',
},
keyframes: {
shimmer: {
'0%': { backgroundPosition: '200% 0' },
'100%': { backgroundPosition: '-200% 0' },
},
modalIn: {
from: { transform: 'translateY(-6px)', opacity: '0' },
to: { transform: 'translateY(0)', opacity: '1' },
},
},
},
},
};
</script>
<style type="text/tailwindcss">
@layer base {
:root { color-scheme: dark; }
input, button, select, textarea { color: inherit; }
body {
background:
radial-gradient(1200px 600px at 80% -10%, rgba(255, 213, 66, 0.10), transparent 60%),
radial-gradient(1000px 500px at -10% 100%, rgba(188, 140, 255, 0.06), transparent 60%),
#0a0d12;
}
a { color: inherit; text-decoration: none; }
}
@layer components {
.btn { @apply bg-panel2 border border-line2 text-fg px-3.5 py-1.5 rounded-md text-[13px] cursor-pointer transition-all hover:bg-panelHover; }
.btn-primary{ @apply bg-gradient-to-b from-[#2ea043] to-[#238636] border-[#2ea043] text-white font-medium hover:from-[#3ab450] hover:to-[#2a9943]; }
.icon-btn { @apply w-9 h-9 inline-flex items-center justify-center bg-panel border border-line rounded-lg text-fg2 cursor-pointer transition-all hover:bg-panelHover hover:text-fg hover:border-line2; }
.icon-btn > i { @apply text-base leading-none inline-block text-fg2; }
.icon-btn:hover > i { @apply text-fg; }
.icon-btn.spinning > i { @apply animate-spin; }
.badge { @apply inline-flex items-center gap-1 px-2 py-px rounded-full text-[11px] leading-relaxed border border-line2 text-fg2 font-medium; }
.badge-green { @apply text-ok border-ok/40 bg-ok/10; }
.badge-red { @apply text-danger border-danger/40 bg-danger/10; }
.badge-yellow { @apply text-warn border-warn/40 bg-warn/10; }
.card-head { @apply px-4 py-3 border-b border-line bg-panel2/50 flex items-center gap-2.5; }
.card-head h2 { @apply m-0 text-[13px] font-semibold tracking-wide; }
.card-head .count { @apply ml-auto text-muted text-[11px] tabular-nums; }
.card-head-icon { @apply w-6 h-6 rounded-md flex items-center justify-center; }
.card-head-icon > i { @apply text-[15px] leading-none; }
.input-field { @apply w-full px-2.5 py-2 bg-base2 border border-line rounded-md text-fg text-[13px] focus:outline-none focus:border-accentDark; }
.field-label { @apply block text-xs text-fg2 mb-1.5; }
.field-hint { @apply text-[11px] text-muted mt-1 leading-snug; }
.field-hint a { @apply text-accent hover:underline; }
.field-hint code{ @apply bg-base2 border border-line px-1.5 py-0.5 rounded text-[11px] text-accent font-mono; }
.item { @apply block px-3 py-2.5 rounded-lg transition-colors cursor-pointer text-fg hover:bg-panel2; }
.item + .item { @apply mt-0.5; }
.item .title-row{ @apply flex items-center gap-2 flex-wrap; }
.item .title { @apply font-medium text-fg text-[13.5px] overflow-hidden text-ellipsis whitespace-nowrap max-w-full transition-colors; }
.item:hover .title { @apply text-accent; }
.external-icon { @apply text-muted text-[10px] leading-none align-super inline-block; }
.item .desc { @apply text-fg2 text-[12.5px] mt-1 overflow-hidden line-clamp-2; }
.item .meta { @apply text-muted text-[11.5px] mt-1.5 flex gap-2.5 flex-wrap items-center; }
.item .meta span{ @apply inline-flex items-center gap-1; }
.item .meta i { @apply text-[13px] leading-none opacity-75; }
.lang-dot { @apply w-[9px] h-[9px] rounded-full inline-block; }
.result-avatar { @apply w-4 h-4 rounded-[4px] border border-line bg-base2 shrink-0; }
.result-org { @apply text-fg2 font-normal; }
.org-row { @apply flex items-center gap-2.5 px-2.5 py-2 rounded-lg cursor-pointer transition-colors hover:bg-panel2 relative; }
.org-row + .org-row { @apply mt-0.5; }
.org-row.active { @apply bg-panel2; box-shadow: inset 3px 0 0 #ffd542; }
.org-row.active .org-name { @apply text-accent; }
.org-row .avatar { @apply w-8 h-8 rounded-lg border border-line bg-base2 shrink-0; }
.org-row .org-name { @apply font-medium text-[13.5px] truncate; }
.org-row .org-login { @apply text-[11.5px] text-muted truncate; }
.org-row .repo-chip { @apply text-[11px] tabular-nums text-muted bg-base2 border border-line px-1.5 py-px rounded shrink-0; }
.empty-state { @apply px-5 py-10 text-center text-muted text-[13px]; }
.error-state { @apply text-danger bg-danger/5 rounded-lg m-1.5 p-3.5 text-left text-[12.5px] break-words; }
.skeleton-bar { @apply h-3 rounded animate-shimmer; background: linear-gradient(90deg, #161c25, #1a212c, #161c25); background-size: 200% 100%; }
}
</style>
<style>
/* Toggleable overlays — keep as plain CSS so .open works alongside Tailwind utilities */
.modal-root { display: none; }
.modal-root.open { display: flex; }
.popover-root { display: none; }
.popover-root.open { display: block; }
.layout-root { display: none; }
.layout-root.open { display: grid; }
.onboarding-root { display: none; }
.onboarding-root.open { display: block; }
/* scrollbar */
.scroll::-webkit-scrollbar { width: 8px; }
.scroll::-webkit-scrollbar-thumb { background: #232b36; border-radius: 4px; }
.scroll::-webkit-scrollbar-thumb:hover { background: #30394a; }
</style>
</head>
<body class="m-0 font-sans bg-base text-fg leading-normal text-sm antialiased min-h-screen">
<header class="backdrop-blur-sm bg-base/75 border-b border-line sticky top-0 z-20">
<div class="max-w-[1500px] mx-auto px-7 py-3.5 flex items-center gap-4 max-[720px]:px-4">
<div class="brand flex items-center gap-2.5 font-semibold text-[15px] tracking-tight cursor-pointer">
<svg viewBox="0 0 16 16" fill="currentColor" class="w-[22px] h-[22px] text-fg"><path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.012 8.012 0 0 0 16 8c0-4.42-3.58-8-8-8z"/></svg>
GitHub Dashboard
<span id="status-dot" class="w-1.5 h-1.5 rounded-full bg-muted" title="Idle"></span>
</div>
<button id="search-trigger" type="button" class="flex-1 max-w-[640px] mx-auto flex items-center gap-2.5 py-2 pl-3.5 pr-3 bg-panel border border-line rounded-lg text-muted cursor-pointer text-sm text-left transition-all hover:bg-panel2 hover:border-line2 hover:text-fg2">
<i class="ti ti-search text-base leading-none shrink-0 text-muted"></i>
<span class="flex-1 truncate">Search across all organizations…</span>
<kbd class="bg-panel2 border border-line2 rounded px-1.5 py-px text-[11px] text-muted font-mono">/</kbd>
</button>
<div class="flex gap-2 items-center">
<button id="reload" class="icon-btn" title="Refresh (R)"><i class="ti ti-refresh"></i></button>
<button id="settings-btn" class="icon-btn" title="Settings"><i class="ti ti-settings"></i></button>
</div>
</div>
<div id="settings-popover" class="popover-root absolute top-16 right-7 w-[360px] bg-panel border border-line2 rounded-xl shadow-2xl p-[18px] z-30">
<h3 class="m-0 mb-3.5 text-[13px] font-semibold tracking-wider text-fg2 uppercase">Settings</h3>
<div class="mb-3">
<label for="token" class="field-label">Personal Access Token</label>
<input id="token" type="password" placeholder="ghp_…" autocomplete="off" class="input-field" />
<div class="field-hint">
Needs <code>repo</code> and <code>read:org</code>.
<a href="https://github.com/settings/tokens" target="_blank">Create one <i class="ti ti-external-link external-icon"></i></a>
Stored only in your browser's <code>localStorage</code>.
</div>
</div>
<div class="flex justify-end gap-2 mt-1.5">
<button class="btn" id="settings-cancel">Cancel</button>
<button class="btn btn-primary" id="settings-save">Save & Reload</button>
</div>
</div>
</header>
<!-- Onboarding -->
<div id="onboarding" class="onboarding-root max-w-[720px] mx-auto my-20 p-9 bg-panel border border-line rounded-2xl text-center shadow-md">
<svg viewBox="0 0 16 16" fill="currentColor" class="w-12 h-12 text-accent mx-auto mb-3.5"><path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.012 8.012 0 0 0 16 8c0-4.42-3.58-8-8-8z"/></svg>
<h1 class="m-0 mb-2 text-[22px] font-semibold tracking-tight">Welcome to GitHub Dashboard</h1>
<p class="text-fg2 m-0 mb-6 text-sm">Pick a GitHub organization and see its repositories and active pull requests at a glance.</p>
<button class="btn btn-primary px-5 py-2.5 text-sm" id="onboarding-btn">Connect GitHub</button>
</div>
<!-- Search modal -->
<div id="search-modal" class="modal-root fixed inset-0 bg-black/60 backdrop-blur-sm z-[100] pt-20 px-6 pb-6 justify-center items-start" role="dialog" aria-modal="true">
<div class="bg-panel border border-line2 rounded-2xl w-full max-w-[760px] max-h-[calc(100vh-120px)] flex flex-col shadow-2xl overflow-hidden animate-modalIn">
<div class="flex items-center gap-3 px-4 py-3.5 border-b border-line">
<i class="ti ti-search text-lg leading-none text-muted shrink-0"></i>
<input id="modal-input" type="search" placeholder="Search across all organizations…" autocomplete="off" class="flex-1 bg-transparent border-0 text-fg text-base font-sans py-1 min-w-0 focus:outline-none placeholder:text-muted" />
<span id="modal-progress" class="text-[11px] text-muted shrink-0 tabular-nums"></span>
<span class="bg-panel2 border border-line2 rounded px-1.5 py-px text-[11px] text-muted font-mono shrink-0">esc</span>
</div>
<div class="overflow-y-auto flex-1 scroll">
<div class="border-b border-line">
<div class="px-4 py-2.5 text-[11px] font-semibold tracking-wider uppercase text-fg2 bg-panel2 flex justify-between items-center sticky top-0">
<span>Repositories</span>
<span id="modal-count-repos">—</span>
</div>
<ul id="modal-list-repos" class="list-none m-0 p-1.5"></ul>
</div>
<div>
<div class="px-4 py-2.5 text-[11px] font-semibold tracking-wider uppercase text-fg2 bg-panel2 flex justify-between items-center sticky top-0">
<span>Pull Requests</span>
<span id="modal-count-prs">—</span>
</div>
<ul id="modal-list-prs" class="list-none m-0 p-1.5"></ul>
</div>
</div>
</div>
</div>
<!-- Main layout -->
<div id="layout" class="layout-root max-w-[1500px] mx-auto px-7 py-6 grid-cols-[320px_minmax(0,1fr)] gap-6 items-start max-[920px]:grid-cols-1 max-[720px]:px-4">
<aside class="bg-panel border border-line rounded-xl shadow-md overflow-hidden sticky top-20 max-h-[calc(100vh-100px)] flex flex-col max-[920px]:static max-[920px]:max-h-none">
<div class="card-head">
<div class="card-head-icon text-purple"><i class="ti ti-building-community"></i></div>
<h2>Organizations</h2>
<span id="count-orgs" class="count">—</span>
</div>
<ul id="org-list" class="list-none m-0 p-1.5 overflow-y-auto flex-1 scroll"></ul>
</aside>
<main class="flex flex-col gap-5 min-w-0">
<div id="detail-header" class="bg-panel border border-line rounded-xl px-3.5 py-3 flex gap-3 items-center shadow-md"></div>
<div class="grid grid-cols-2 gap-5 max-[1200px]:grid-cols-1">
<section class="bg-panel border border-line rounded-xl overflow-hidden flex flex-col shadow-md">
<div class="card-head">
<div class="card-head-icon text-accent"><i class="ti ti-book-2"></i></div>
<h2>Repositories</h2>
<span id="count-repos" class="count">—</span>
</div>
<ul id="list-repos" class="list-none m-0 p-1.5 overflow-y-auto max-h-[calc(100vh-320px)] min-h-[200px] scroll"></ul>
</section>
<section class="bg-panel border border-line rounded-xl overflow-hidden flex flex-col shadow-md">
<div class="card-head">
<div class="card-head-icon text-ok"><i class="ti ti-git-pull-request"></i></div>
<h2>Active Pull Requests</h2>
<span id="count-prs" class="count">—</span>
</div>
<ul id="list-prs" class="list-none m-0 p-1.5 overflow-y-auto max-h-[calc(100vh-320px)] min-h-[200px] scroll"></ul>
</section>
</div>
</main>
</div>
<script>
const $ = (id) => document.getElementById(id);
const tokenEl = $("token");
const modalEl = $("search-modal"), modalInput = $("modal-input"), modalProgress = $("modal-progress");
const popover = $("settings-popover"), layout = $("layout"), onboarding = $("onboarding");
const statusDot = $("status-dot");
const state = {
orgs: [],
selected: null,
cache: {},
};
const ICONS = {
star: '<i class="ti ti-star"></i>',
clock: '<i class="ti ti-clock"></i>',
comment: '<i class="ti ti-message-circle"></i>',
lock: '<i class="ti ti-lock"></i>',
archive: '<i class="ti ti-archive"></i>',
};
const LANG_COLORS = {
JavaScript: "#f1e05a", TypeScript: "#3178c6", Python: "#3572A5", Go: "#00ADD8",
Rust: "#dea584", Java: "#b07219", PHP: "#4F5D95", Ruby: "#701516", "C++": "#f34b7d",
C: "#555555", "C#": "#178600", Shell: "#89e051", HTML: "#e34c26", CSS: "#563d7c",
Vue: "#41b883", Svelte: "#ff3e00", Kotlin: "#A97BFF", Swift: "#F05138", Dart: "#00B4AB",
Dockerfile: "#384d54", Lua: "#000080", Elixir: "#6e4a7e", Scala: "#c22d40",
};
function getToken() { return localStorage.getItem("gh_token") || ""; }
function setToken(t) { localStorage.setItem("gh_token", t); }
function getSelected() { return localStorage.getItem("gh_selected_org") || ""; }
function setSelected(s){ localStorage.setItem("gh_selected_org", s); }
function fmtDate(iso) {
if (!iso) return "";
const d = new Date(iso);
const days = Math.floor((Date.now() - d.getTime()) / 86400000);
if (days < 1) return "today";
if (days === 1) return "yesterday";
if (days < 30) return days + "d ago";
if (days < 365) return Math.floor(days / 30) + "mo ago";
return Math.floor(days / 365) + "y ago";
}
function setStatus(s) {
const colors = { idle: "#6e7781", loading: "#d29922", ok: "#3fb950", error: "#f85149" };
statusDot.style.background = colors[s] || colors.idle;
statusDot.style.boxShadow = s === "idle" ? "none" : `0 0 10px ${colors[s]}`;
statusDot.title = s.charAt(0).toUpperCase() + s.slice(1);
}
async function ghGraphQL(query, token, variables) {
const res = await fetch("https://api.github.com/graphql", {
method: "POST",
headers: { "Authorization": "Bearer " + token, "Content-Type": "application/json" },
body: JSON.stringify({ query, variables: variables || {} }),
});
if (!res.ok) throw new Error("GraphQL " + res.status + ": " + (await res.text()).slice(0, 200));
const json = await res.json();
// GitHub often returns partial data alongside errors (e.g. search rate
// limit on one alias while viewer/orgs succeed). Only throw if there is
// nothing usable to return; otherwise warn and pass through.
if (json.errors) {
if (!json.data) throw new Error(json.errors.map(e => e.message).join("; "));
console.warn("GraphQL partial errors:", json.errors);
}
return json.data;
}
const REPO_FIELDS = `
name nameWithOwner url description isPrivate isArchived stargazerCount updatedAt
primaryLanguage { name }
`;
const PR_FIELDS = `
... on PullRequest {
title url number isDraft updatedAt
repository { nameWithOwner }
author { login }
comments { totalCount }
}
`;
// One GraphQL request bundles everything:
// - viewer profile + personal repos (first 100, owner)
// - each org's repositories connection directly (first 100 each — this is
// the source of truth that respects team-restricted access etc.)
// - 3 aliased global PR searches (author / assignee / reviewer)
// Per-org pagination only kicks in for orgs that report hasNextPage.
async function loadAllData(token) {
const initial = await ghGraphQL(`
query {
viewer {
login name url avatarUrl bio
personalRepoCount: repositories(ownerAffiliations: OWNER) { totalCount }
ownedRepos: repositories(first: 100, ownerAffiliations: OWNER, orderBy: {field: UPDATED_AT, direction: DESC}) {
nodes { ${REPO_FIELDS} }
pageInfo { hasNextPage endCursor }
}
organizations(first: 100) {
nodes {
login name description url avatarUrl
repositories(first: 100, orderBy: {field: UPDATED_AT, direction: DESC}) {
totalCount
nodes { ${REPO_FIELDS} }
pageInfo { hasNextPage endCursor }
}
}
}
}
authorPRs: search(type: ISSUE, query: "is:open is:pr author:@me archived:false", first: 100) { nodes { ${PR_FIELDS} } }
assigneePRs: search(type: ISSUE, query: "is:open is:pr assignee:@me archived:false", first: 100) { nodes { ${PR_FIELDS} } }
reviewerPRs: search(type: ISSUE, query: "is:open is:pr user-review-requested:@me archived:false", first: 100) { nodes { ${PR_FIELDS} } }
}`, token);
const v = initial.viewer;
state.viewerLogin = v.login;
const personal = {
login: v.login, name: v.name || v.login, description: v.bio || "Personal account",
url: v.url, avatar: v.avatarUrl,
repoCount: v.personalRepoCount ? v.personalRepoCount.totalCount : 0,
isPersonal: true,
_hasMore: !!(v.ownedRepos && v.ownedRepos.pageInfo.hasNextPage),
_cursor: v.ownedRepos ? v.ownedRepos.pageInfo.endCursor : null,
};
const orgs = v.organizations.nodes.map(o => ({
login: o.login, name: o.name || o.login, description: o.description,
url: o.url, avatar: o.avatarUrl,
repoCount: o.repositories ? o.repositories.totalCount : 0,
isPersonal: false,
_hasMore: !!(o.repositories && o.repositories.pageInfo.hasNextPage),
_cursor: o.repositories ? o.repositories.pageInfo.endCursor : null,
}));
state.orgs = [personal, ...orgs];
state.cache = {};
for (const o of state.orgs) state.cache[o.login] = { loading: false, repos: [], prs: [] };
// Initial repo pages (per bucket)
appendReposToBucket(personal.login, v.ownedRepos ? v.ownedRepos.nodes : []);
for (const o of v.organizations.nodes) {
appendReposToBucket(o.login, o.repositories ? o.repositories.nodes : []);
}
// Bucket PRs by repo owner; merge 3 aliased searches into a relations set.
// Each alias may be null if its search hit the secondary rate limit while
// the rest of the query succeeded — defend against that so we don't drop
// PRs from the working aliases.
const sources = [
{ rel: "author", nodes: initial.authorPRs ? initial.authorPRs.nodes : [] },
{ rel: "assignee", nodes: initial.assigneePRs ? initial.assigneePRs.nodes : [] },
{ rel: "reviewer", nodes: initial.reviewerPRs ? initial.reviewerPRs.nodes : [] },
];
const byUrl = new Map();
for (const src of sources) {
for (const n of (src.nodes || [])) {
if (!n || !n.url) continue;
if (!byUrl.has(n.url)) byUrl.set(n.url, { n, relations: new Set() });
byUrl.get(n.url).relations.add(src.rel);
}
}
for (const { n, relations } of byUrl.values()) {
const owner = n.repository ? n.repository.nameWithOwner.split("/")[0] : null;
if (!owner || !state.cache[owner]) continue;
state.cache[owner].prs.push({
title: n.title, url: n.url, number: n.number,
repo: n.repository.nameWithOwner,
author: n.author ? n.author.login : "",
draft: n.isDraft, updated: n.updatedAt,
comments: n.comments ? n.comments.totalCount : 0,
relations: [...relations],
});
}
for (const login in state.cache) {
state.cache[login].prs.sort((a, b) => (b.updated || "").localeCompare(a.updated || ""));
}
const pendingOrgs = state.orgs.filter(o => o._hasMore);
if (pendingOrgs.length > 0) {
state.loadingMore = true;
paginateOrgRepos(token, pendingOrgs);
} else {
state.loadingMore = false;
}
}
function appendReposToBucket(login, nodes) {
if (!state.cache[login] || !nodes) return;
for (const r of nodes) {
state.cache[login].repos.push({
name: r.name, fullName: r.nameWithOwner, url: r.url,
description: r.description, private: r.isPrivate, archived: r.isArchived,
language: r.primaryLanguage ? r.primaryLanguage.name : null,
stars: r.stargazerCount, updated: r.updatedAt,
});
}
state.cache[login].repos.sort((a, b) => (b.updated || "").localeCompare(a.updated || ""));
}
async function paginateOrgRepos(token, pendingOrgs) {
const myGen = state.gen;
const personalQ = `
query($cursor: String!) {
viewer {
repositories(first: 100, after: $cursor, ownerAffiliations: OWNER, orderBy: {field: UPDATED_AT, direction: DESC}) {
nodes { ${REPO_FIELDS} }
pageInfo { hasNextPage endCursor }
}
}
}`;
const orgQ = `
query($login: String!, $cursor: String!) {
organization(login: $login) {
repositories(first: 100, after: $cursor, orderBy: {field: UPDATED_AT, direction: DESC}) {
nodes { ${REPO_FIELDS} }
pageInfo { hasNextPage endCursor }
}
}
}`;
for (const org of pendingOrgs) {
let cursor = org._cursor;
while (cursor) {
if (state.gen !== myGen) return;
const isP = org.isPersonal;
const variables = isP ? { cursor } : { login: org.login, cursor };
let data;
try { data = await ghGraphQL(isP ? personalQ : orgQ, token, variables); }
catch (e) { console.error("paginateOrgRepos:", org.login, e); break; }
if (state.gen !== myGen) return;
const conn = isP ? data.viewer.repositories : data.organization.repositories;
appendReposToBucket(org.login, conn.nodes);
if (state.selected) renderDetailLists();
renderSearchModal();
if (!conn.pageInfo.hasNextPage) break;
cursor = conn.pageInfo.endCursor;
}
}
if (state.gen === myGen) {
state.loadingMore = false;
if (state.selected) renderDetailLists();
renderSearchModal();
}
}
function escapeHtml(s) {
return (s || "").replace(/[&<>"']/g, c => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" }[c]));
}
function skeletonOrgs(n) {
return Array.from({ length: n }, () => `
<li class="flex items-center gap-2.5 px-2.5 py-2">
<div class="w-8 h-8 rounded-lg shrink-0 skeleton-bar"></div>
<div class="flex-1"><div class="skeleton-bar w-[70%]"></div><div class="skeleton-bar w-[40%] h-2.5 mt-1.5"></div></div>
</li>`).join("");
}
function skeletonItems(n) {
return Array.from({ length: n }, () => `
<li class="px-3 py-2.5"><div class="skeleton-bar w-[70%]"></div><div class="skeleton-bar w-[40%] h-2.5 mt-1.5"></div></li>`).join("");
}
function renderOrgList() {
$("count-orgs").textContent = state.orgs.length;
$("org-list").innerHTML = state.orgs.length === 0
? `<li class="empty-state">No organizations</li>`
: state.orgs.map(o => `
<li class="org-row ${o.login === state.selected ? "active" : ""}" data-login="${escapeHtml(o.login)}">
<img class="avatar" src="${escapeHtml(o.avatar)}" alt="" loading="lazy" />
<div class="min-w-0 flex-1">
<div class="org-name">${escapeHtml(o.name)}</div>
<div class="org-login">${escapeHtml(o.login)}</div>
</div>
<span class="repo-chip">${o.repoCount}</span>
</li>`).join("");
$("org-list").querySelectorAll(".org-row[data-login]").forEach(el => {
el.addEventListener("click", () => selectOrg(el.dataset.login));
});
}
function renderDetailHeader() {
const org = state.orgs.find(o => o.login === state.selected);
if (!org) {
$("detail-header").innerHTML = `<div class="empty-state m-0">Select an organization on the left.</div>`;
return;
}
const newRepoUrl = org.isPersonal
? "https://github.com/new"
: `https://github.com/organizations/${encodeURIComponent(org.login)}/repositories/new`;
$("detail-header").innerHTML = `
<img class="w-9 h-9 rounded-lg border border-line bg-base2 shrink-0" src="${escapeHtml(org.avatar)}" alt="" />
<div class="flex items-baseline gap-1.5 min-w-0 flex-1 overflow-hidden whitespace-nowrap">
<h1 class="m-0 text-sm font-semibold tracking-tight inline truncate"><a href="${org.url}" target="_blank" rel="noopener" class="hover:text-accent">${escapeHtml(org.name)} <i class="ti ti-external-link external-icon"></i></a></h1>
<span class="text-muted text-xs truncate">@${escapeHtml(org.login)} · ${org.repoCount} repos</span>
${org.description ? `<span class="text-fg2 text-[12.5px] truncate">· ${escapeHtml(org.description)}</span>` : ""}
</div>
<a href="${newRepoUrl}" target="_blank" rel="noopener" class="btn shrink-0 inline-flex items-center gap-1.5 text-[12px] px-2.5 py-1" title="Create a new repository">
<i class="ti ti-plus text-[13px] leading-none"></i>
New repository
</a>`;
}
function renderDetailLists() {
const cache = state.cache[state.selected];
// Repositories
if (!state.selected) {
$("list-repos").innerHTML = `<li class="empty-state">—</li>`;
$("count-repos").textContent = "—";
} else if (!cache || cache.loading) {
$("list-repos").innerHTML = skeletonItems(5);
$("count-repos").textContent = "—";
} else if (cache.reposError) {
$("list-repos").innerHTML = `<li class="error-state">${escapeHtml(cache.reposError)}</li>`;
$("count-repos").textContent = "—";
} else {
$("count-repos").textContent = cache.repos.length;
$("list-repos").innerHTML = cache.repos.length === 0
? `<li class="empty-state">No repositories</li>`
: cache.repos.map(r => `
<a class="item" href="${r.url}" target="_blank" rel="noopener">
<div class="title-row">
<span class="title">${escapeHtml(r.name)} <i class="ti ti-external-link external-icon"></i></span>
${r.private ? `<span class="badge">${ICONS.lock} private</span>` : ""}
${r.archived ? `<span class="badge badge-yellow">${ICONS.archive} archived</span>` : ""}
</div>
${r.description ? `<div class="desc">${escapeHtml(r.description)}</div>` : ""}
<div class="meta">
${r.language ? `<span><span class="lang-dot" style="background:${LANG_COLORS[r.language] || '#888'}"></span>${escapeHtml(r.language)}</span>` : ""}
${r.stars ? `<span>${ICONS.star} ${r.stars}</span>` : ""}
<span>${ICONS.clock} ${fmtDate(r.updated)}</span>
</div>
</a>`).join("");
}
// Pull requests
if (!state.selected) {
$("list-prs").innerHTML = `<li class="empty-state">—</li>`;
$("count-prs").textContent = "—";
} else if (!cache || cache.loading) {
$("list-prs").innerHTML = skeletonItems(5);
$("count-prs").textContent = "—";
} else if (cache.prsError) {
$("list-prs").innerHTML = `<li class="error-state">${escapeHtml(cache.prsError)}</li>`;
$("count-prs").textContent = "—";
} else {
$("count-prs").textContent = cache.prs.length;
$("list-prs").innerHTML = cache.prs.length === 0
? `<li class="empty-state">No active pull requests</li>`
: cache.prs.map(p => `
<a class="item" href="${p.url}" target="_blank" rel="noopener">
<div class="title-row">
<span class="title">${escapeHtml(p.title)} <i class="ti ti-external-link external-icon"></i></span>
${p.draft ? `<span class="badge">draft</span>` : ""}
${(p.relations || []).includes("author") ? `<span class="badge">author</span>` : ""}
${(p.relations || []).includes("assignee") ? `<span class="badge badge-green">assigned</span>` : ""}
${(p.relations || []).includes("reviewer") ? `<span class="badge badge-yellow">review</span>` : ""}
</div>
<div class="meta">
<span>${escapeHtml(p.repo.split("/").pop())} #${p.number}</span>
<span>by ${escapeHtml(p.author)}</span>
${p.comments ? `<span>${ICONS.comment} ${p.comments}</span>` : ""}
<span>${ICONS.clock} ${fmtDate(p.updated)}</span>
</div>
</a>`).join("");
}
}
function renderSearchModal() {
if (!modalEl.classList.contains("open")) return;
const term = modalInput.value.trim().toLowerCase();
const total = state.orgs.length;
modalProgress.textContent = state.loadingMore ? `loading more repos…` : `${total} orgs`;
if (!term) {
$("modal-count-repos").textContent = "—";
$("modal-count-prs").textContent = "—";
$("modal-list-repos").innerHTML = `<li class="empty-state">Type to search across every organization.</li>`;
$("modal-list-prs").innerHTML = "";
return;
}
const match = (s) => (s || "").toLowerCase().includes(term);
const repos = [];
const prs = [];
for (const org of state.orgs) {
const cache = state.cache[org.login];
if (!cache || cache.loading) continue;
for (const r of (cache.repos || [])) {
if (match(r.name) || match(r.description) || match(r.language) || match(org.login)) {
repos.push({ ...r, _org: org });
}
}
for (const p of (cache.prs || [])) {
if (match(p.title) || match(p.repo) || match(p.author) || match(org.login)) {
prs.push({ ...p, _org: org });
}
}
}
repos.sort((a, b) => (b.updated || "").localeCompare(a.updated || ""));
prs.sort((a, b) => (b.updated || "").localeCompare(a.updated || ""));
const emptyMsg = state.loadingMore ? "No matches yet — still loading repos" : "No matches";
$("modal-count-repos").textContent = repos.length;
$("modal-list-repos").innerHTML = repos.length === 0
? `<li class="empty-state">${emptyMsg}</li>`
: repos.map(r => `
<a class="item" href="${r.url}" target="_blank" rel="noopener">
<div class="title-row">
<img class="result-avatar" src="${escapeHtml(r._org.avatar)}" alt="" />
<span class="title"><span class="result-org">${escapeHtml(r._org.login)}/</span>${escapeHtml(r.name)} <i class="ti ti-external-link external-icon"></i></span>
${r.private ? `<span class="badge">${ICONS.lock} private</span>` : ""}
${r.archived ? `<span class="badge badge-yellow">${ICONS.archive} archived</span>` : ""}
</div>
${r.description ? `<div class="desc">${escapeHtml(r.description)}</div>` : ""}
<div class="meta">
${r.language ? `<span><span class="lang-dot" style="background:${LANG_COLORS[r.language] || '#888'}"></span>${escapeHtml(r.language)}</span>` : ""}
${r.stars ? `<span>${ICONS.star} ${r.stars}</span>` : ""}
<span>${ICONS.clock} ${fmtDate(r.updated)}</span>
</div>
</a>`).join("");
$("modal-count-prs").textContent = prs.length;
$("modal-list-prs").innerHTML = prs.length === 0
? `<li class="empty-state">${emptyMsg}</li>`
: prs.map(p => `
<a class="item" href="${p.url}" target="_blank" rel="noopener">
<div class="title-row">
<img class="result-avatar" src="${escapeHtml(p._org.avatar)}" alt="" />
<span class="title"><span class="result-org">${escapeHtml(p._org.login)}/</span>${escapeHtml(p.title)} <i class="ti ti-external-link external-icon"></i></span>
${p.draft ? `<span class="badge">draft</span>` : ""}
${(p.relations || []).includes("author") ? `<span class="badge">author</span>` : ""}
${(p.relations || []).includes("assignee") ? `<span class="badge badge-green">assigned</span>` : ""}
${(p.relations || []).includes("reviewer") ? `<span class="badge badge-yellow">review</span>` : ""}
</div>
<div class="meta">
<span>${escapeHtml(p.repo.split("/").pop())} #${p.number}</span>
<span>by ${escapeHtml(p.author)}</span>
${p.comments ? `<span>${ICONS.comment} ${p.comments}</span>` : ""}
<span>${ICONS.clock} ${fmtDate(p.updated)}</span>
</div>
</a>`).join("");
}
function openSearch() {
modalEl.classList.add("open");
setTimeout(() => modalInput.focus(), 0);
renderSearchModal();
}
function closeSearch() {
modalEl.classList.remove("open");
modalInput.value = "";
}
function render() {
renderOrgList();
renderDetailHeader();
renderDetailLists();
}
function selectOrg(login) {
if (!login) return;
state.selected = login;
setSelected(login);
render();
}
async function reload() {
const token = getToken();
if (!token) {
layout.classList.remove("open");
onboarding.classList.add("open");
return;
}
onboarding.classList.remove("open");
layout.classList.add("open");
setStatus("loading");
$("reload").classList.add("spinning");
$("org-list").innerHTML = skeletonOrgs(6);
$("list-repos").innerHTML = skeletonItems(5);
$("list-prs").innerHTML = skeletonItems(5);
$("count-repos").textContent = "—";
$("count-prs").textContent = "—";
$("detail-header").innerHTML = `
<div class="w-9 h-9 rounded-lg shrink-0 skeleton-bar"></div>
<div class="flex-1 min-w-0 flex items-baseline gap-2">
<div class="skeleton-bar w-32"></div>
<div class="skeleton-bar w-24 h-2.5"></div>
</div>`;
state.gen = (state.gen || 0) + 1;
try {
await loadAllData(token);
setStatus("ok");
} catch (e) {
$("org-list").innerHTML = `<li class="error-state">${escapeHtml(e.message)}</li>`;
setStatus("error");
$("reload").classList.remove("spinning");
return;
}
$("reload").classList.remove("spinning");
let target = getSelected();
if (!target || !state.orgs.find(o => o.login === target)) {
target = state.orgs[0] ? state.orgs[0].login : null;
}
renderOrgList();
if (target) selectOrg(target);
else { renderDetailHeader(); renderDetailLists(); }
}
function refreshCurrent() { reload(); }
// Settings popover
function togglePopover(open) {
popover.classList.toggle("open", open ?? !popover.classList.contains("open"));
if (popover.classList.contains("open")) tokenEl.value = getToken();
}
$("settings-btn").addEventListener("click", (e) => { e.stopPropagation(); togglePopover(); });
$("settings-cancel").addEventListener("click", () => togglePopover(false));
$("settings-save").addEventListener("click", () => {
setToken(tokenEl.value.trim());
togglePopover(false);
reload();
});
$("onboarding-btn").addEventListener("click", (e) => { e.stopPropagation(); togglePopover(true); });
document.addEventListener("click", (e) => {
if (popover.classList.contains("open") && !popover.contains(e.target) && e.target.id !== "settings-btn") {
togglePopover(false);
}
});
// Brand returns to first org
document.querySelector(".brand").addEventListener("click", () => {
if (state.orgs[0]) selectOrg(state.orgs[0].login);
});
// Search modal
$("search-trigger").addEventListener("click", openSearch);
modalInput.addEventListener("input", renderSearchModal);
modalEl.addEventListener("click", (e) => { if (e.target === modalEl) closeSearch(); });
// Keyboard shortcuts
document.addEventListener("keydown", (e) => {
if (e.key === "Escape") {
if (modalEl.classList.contains("open")) { closeSearch(); return; }
if (popover.classList.contains("open")) { togglePopover(false); return; }
}
if (e.target.tagName === "INPUT") {
if (e.key === "Enter" && e.target === tokenEl) {
setToken(tokenEl.value.trim()); togglePopover(false); reload();
}
return;
}
if (e.key === "/") { e.preventDefault(); openSearch(); }
if (e.key === "r" || e.key === "R") refreshCurrent();
});
$("reload").addEventListener("click", refreshCurrent);
if (getToken()) reload();
else { onboarding.classList.add("open"); layout.classList.remove("open"); }
</script>
</body>
</html>