ernestmindres commited on
Commit
9a232c5
·
verified ·
1 Parent(s): 5bfd22a

Add files via upload

Browse files
a6ea61c8-951a-413a-ba9d-7365d83fbd4d/ernestmind/templates/new_pull_requests.html ADDED
@@ -0,0 +1,632 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en" class="light">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>GitForge | Repository - Compare Changes</title>
7
+ <link rel="icon" type="image/png" href="https://i.postimg.cc/t4NCGNzD/gitforge-png.png">
8
+ <script src="https://cdn.tailwindcss.com"></script>
9
+ <script src="https://unpkg.com/lucide@latest"></script>
10
+ <link rel="stylesheet"
11
+ href="https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL,GRAD@24,400,0,0" />
12
+ <style>
13
+ /* Inter Font Configuration */
14
+ body { font-family: 'Inter', sans-serif; }
15
+
16
+ /* Theme Variables and Transitions (Light Mode) */
17
+ .transition-colors-theme { transition: background-color 0.3s, color 0.3s, border-color 0.3s; }
18
+
19
+ .light {
20
+ --bg-page: #FFFFFF;
21
+ --bg-header: #F6F8FA; /* Matches the light gray header */
22
+ --bg-card: #FFFFFF;
23
+ --bg-active: #F3F4F6;
24
+ --border-color: #D0D7DE;
25
+ --text-color: #24292F;
26
+ --text-secondary: #57606A;
27
+ --text-link: #0969DA;
28
+ --primary-color: #2DA44E; /* Green button */
29
+ --primary-hover: #2C974B;
30
+ --bg-warning: #FFF8C5; /* Yellow warning banner */
31
+ --border-warning: #E2B200;
32
+ }
33
+
34
+ /* Utility classes for theme variables */
35
+ .bg-page-var { background-color: var(--bg-page); } .bg-card-var { background-color: var(--bg-card); }
36
+ .bg-header-var { background-color: var(--bg-header); } .border-color-var { border-color: var(--border-color); }
37
+ .text-color-var { color: var(--text-color); } .text-secondary-var { color: var(--text-secondary); }
38
+ .text-link-var { color: var(--text-link); }
39
+ .bg-primary-color-var { background-color: var(--primary-color); } .hover\:bg-primary-hover-var:hover { background-color: var(--primary-hover); }
40
+ .bg-active-var { background-color: var(--bg-active); } .hover\:bg-active-var:hover { background-color: var(--bg-active); }
41
+ .focus\:ring-link-var:focus { --tw-ring-color: var(--text-link); }
42
+
43
+ /* Repository Navigation Link Styles */
44
+ .repo-nav-link {
45
+ padding: 0.5rem 1rem; border-bottom: 2px solid transparent;
46
+ margin-right: 0.5rem;
47
+ white-space: nowrap; /* Prevents wrapping in the horizontal nav */
48
+ }
49
+ .repo-nav-link.active {
50
+ border-bottom-color: #F78166; /* Vibrant orange/red for active tab */
51
+ color: var(--text-color) !important;
52
+ font-weight: 600;
53
+ }
54
+
55
+ /* Sidebar Styles (identical to previous file) */
56
+ #sidebar {
57
+ position: fixed;
58
+ top: 0;
59
+ left: 0;
60
+ width: 300px;
61
+ height: 100%;
62
+ background-color: var(--bg-card);
63
+ transform: translateX(-100%);
64
+ transition: transform 0.3s ease-in-out;
65
+ box-shadow: 2px 0 5px rgba(0,0,0,0.1);
66
+ z-index: 100;
67
+ }
68
+ #sidebar.open {
69
+ transform: translateX(0);
70
+ }
71
+ #overlay {
72
+ position: fixed;
73
+ top: 0;
74
+ left: 0;
75
+ width: 100%;
76
+ height: 100%;
77
+ background: rgba(0, 0, 0, 0.5);
78
+ z-index: 90;
79
+ display: none;
80
+ }
81
+ #overlay.open {
82
+ display: block;
83
+ }
84
+
85
+ /* Branch Dropdown Card Styles */
86
+ .dropdown-card {
87
+ position: absolute;
88
+ top: 100%; /* Position below the button */
89
+ left: 0;
90
+ width: 300px;
91
+ background-color: var(--bg-card);
92
+ border: 1px solid var(--border-color);
93
+ border-radius: 0.5rem;
94
+ box-shadow: 0 4px 6px rgba(0,0,0,0.1);
95
+ z-index: 50;
96
+ display: none;
97
+ overflow: hidden;
98
+ max-height: 400px; /* Limite la hauteur du dropdown */
99
+ }
100
+ .dropdown-card.open {
101
+ display: block;
102
+ }
103
+
104
+ /* NOUVEAUX STYLES: Spinner */
105
+ .spinner {
106
+ border: 4px solid var(--border-color);
107
+ border-top: 4px solid var(--text-link); /* Couleur du spinner */
108
+ border-radius: 50%;
109
+ width: 20px;
110
+ height: 20px;
111
+ animation: spin 1s linear infinite;
112
+ }
113
+ .spinner-large {
114
+ width: 30px;
115
+ height: 30px;
116
+ }
117
+ @keyframes spin {
118
+ 0% { transform: rotate(0deg); }
119
+ 100% { transform: rotate(360deg); }
120
+ }
121
+
122
+ /* Scrollbar pour la liste des branches dans le dropdown */
123
+ .dropdown-content-scroll {
124
+ max-height: 300px;
125
+ overflow-y: auto;
126
+ }
127
+ </style>
128
+ </head>
129
+
130
+ <body class="bg-page-var text-color-var min-h-screen transition-colors-theme">
131
+
132
+ <div id="overlay"></div>
133
+
134
+ <div id="sidebar" class="p-4 border-r border-color-var text-color-var transition-colors-theme">
135
+ <div class="flex justify-between items-center pb-4 border-b border-color-var/50 mb-4">
136
+ <i data-lucide="git-fork" class="text-3xl text-link-var"></i>
137
+ <button id="close-sidebar" class="text-secondary-var hover:text-color-var">
138
+ <i data-lucide="x" class="text-2xl"></i>
139
+ </button>
140
+ </div>
141
+
142
+ <nav class="space-y-1">
143
+ <a href="/mindus/nexus/dashboard?repo_slug={{ repo_slug }}" class="flex items-center p-2 rounded-lg hover:bg-active-var transition-colors-theme">
144
+ <i data-lucide="home" class="w-5 h-5 mr-3"></i> Home
145
+ </a>
146
+ <a href="#" class="flex items-center p-2 rounded-lg hover:bg-active-var transition-colors-theme">
147
+ <i data-lucide="alert-circle" class="w-5 h-5 mr-3"></i> Issues
148
+ </a>
149
+ <a href="/mindus/nexus/pull_request?repo_slug={{ repo_slug }}" class="flex items-center p-2 rounded-lg bg-active-var transition-colors-theme font-semibold text-link-var">
150
+ <i data-lucide="git-pull-request" class="w-5 h-5 mr-3"></i> Pull requests
151
+ </a>
152
+ <a href="#" class="flex items-center p-2 rounded-lg hover:bg-active-var transition-colors-theme">
153
+ <i data-lucide="layout-grid" class="w-5 h-5 mr-3"></i> Projects
154
+ </a>
155
+ <a href="#" class="flex items-center p-2 rounded-lg hover:bg-active-var transition-colors-theme">
156
+ <i data-lucide="message-square" class="w-5 h-5 mr-3"></i> Discussions
157
+ </a>
158
+ <a href="/mindus/nexus/repo_files?repo_slug={{ repo_slug }}" class="flex items-center p-2 rounded-lg hover:bg-active-var transition-colors-theme">
159
+ <i data-lucide="code" class="w-5 h-5 mr-3"></i> Codespaces
160
+ </a>
161
+ <a href="#" class="flex items-center p-2 rounded-lg hover:bg-active-var transition-colors-theme">
162
+ <i data-lucide="cpu" class="w-5 h-5 mr-3"></i> Copilot
163
+ </a>
164
+ </nav>
165
+
166
+ <div class="border-t border-color-var/50 my-4 pt-4 space-y-1">
167
+ <a href="#" class="flex items-center p-2 rounded-lg hover:bg-active-var transition-colors-theme">
168
+ <i data-lucide="compass" class="w-5 h-5 mr-3"></i> Explore
169
+ </a>
170
+ <a href="#" class="flex items-center p-2 rounded-lg hover:bg-active-var transition-colors-theme">
171
+ <i data-lucide="store" class="w-5 h-5 mr-3"></i> Marketplace
172
+ </a>
173
+ <a href="#" class="flex items-center p-2 rounded-lg hover:bg-active-var transition-colors-theme">
174
+ <i data-lucide="link" class="w-5 h-5 mr-3"></i> MCP registry
175
+ </a>
176
+ </div>
177
+ </div>
178
+
179
+
180
+ <header class="w-full bg-header-var border-b border-color-var transition-colors-theme">
181
+ <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
182
+ <div class="flex justify-between items-center h-16">
183
+
184
+ <div class="flex items-center space-x-4">
185
+ <button id="open-sidebar" class="p-2 rounded-lg text-color-var hover:bg-active-var transition-colors-theme">
186
+ <i data-lucide="menu" class="w-6 h-6"></i>
187
+ </button>
188
+
189
+ <span class="text-xl font-bold text-color-var transition-colors-theme hidden md:block">GitForge</span>
190
+ <span class="text-secondary-var hidden md:block">/</span>
191
+ <a href="#" class="text-color-var hover:text-link-var text-lg font-semibold transition-colors-theme flex items-center">
192
+ <span id="repo-user">{{ user.username if user.username else 'current_user' }}</span> / <span id="repo-name">{{ repo_name if repo_name else repo_slug }}</span>
193
+ <i data-lucide="lock" class="w-4 h-4 ml-2 text-secondary-var"></i>
194
+ </a>
195
+ </div>
196
+
197
+ <div class="flex items-center space-x-3">
198
+ <div class="hidden sm:block">
199
+ <input type="text" placeholder="Type / to search"
200
+ class="bg-page-var border border-color-var text-color-var rounded-lg p-1.5 text-sm w-40 md:w-48 transition-colors-theme focus:outline-none focus:border-link-var focus:ring-1 focus:ring-link-var">
201
+ </div>
202
+ <a href="/mindus/nexus/notentification?repo_slug={{ repo_slug }}" class="p-2 rounded-full text-secondary-var hover:text-link-var transition-colors-theme">
203
+ <i data-lucide="bell" class="w-5 h-5"></i>
204
+ </a>
205
+ <a href="/mindus/nexus/nouveau_project?repo_slug={{ repo_slug }}" class="p-2 rounded-full text-secondary-var hover:text-link-var transition-colors-theme">
206
+ <i data-lucide="plus" class="w-5 h-5"></i>
207
+ </a>
208
+ <a href="/mindus/nexus/profile?repo_slug={{ repo_slug }}" class="p-2 rounded-full text-secondary-var hover:text-link-var transition-colors-theme">
209
+ <i data-lucide="user-circle" class="w-5 h-5"></i>
210
+ </a>
211
+ </div>
212
+ </div>
213
+ </div>
214
+
215
+ <div class="w-full border-b border-color-var bg-page-var transition-colors-theme">
216
+ <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
217
+ <nav class="flex space-x-1 overflow-x-auto text-sm font-medium">
218
+ <a href="/mindus/nexus/repo_files?repo_slug={{ repo_slug }}" class="repo-nav-link text-color-var active transition-colors-theme flex items-center">
219
+ <i data-lucide="code" class="w-4 h-4 mr-1"></i> Code
220
+ </a>
221
+ <a href="/mindus/nexus/new_issue?repo_slug={{ repo_slug }}" class="repo-nav-link text-secondary-var hover:text-color-var transition-colors-theme flex items-center">
222
+ <i data-lucide="alert-circle" class="w-4 h-4 mr-1"></i> Issues
223
+ </a>
224
+ <a href="/mindus/nexus/repo_files?repo_slug={{ repo_slug }}" class="repo-nav-link text-secondary-var hover:text-color-var transition-colors-theme flex items-center">
225
+ <i data-lucide="git-pull-request" class="w-4 h-4 mr-1"></i> Pull requests
226
+ </a>
227
+ <a href="#" class="repo-nav-link text-secondary-var hover:text-color-var transition-colors-theme flex items-center">
228
+ <i data-lucide="check-square" class="w-4 h-4 mr-1"></i> Actions
229
+ </a>
230
+ <a href="#" class="repo-nav-link text-secondary-var hover:text-color-var transition-colors-theme flex items-center">
231
+ <i data-lucide="box" class="w-4 h-4 mr-1"></i> Projects
232
+ </a>
233
+ <a href="#" class="repo-nav-link text-secondary-var hover:text-color-var transition-colors-theme flex items-center">
234
+ <i data-lucide="shield" class="w-4 h-4 mr-1"></i> Security
235
+ </a>
236
+ <a href="#" class="repo-nav-link text-secondary-var hover:text-color-var transition-colors-theme flex items-center">
237
+ <i data-lucide="trending-up" class="w-4 h-4 mr-1"></i> Insights
238
+ </a>
239
+ <a href="/mindus/nexus/settings?repo_slug={{ repo_slug }}" class="repo-nav-link text-secondary-var hover:text-color-var transition-colors-theme flex items-center">
240
+ <i data-lucide="settings" class="w-4 h-4 mr-1"></i> Settings
241
+ </a>
242
+ </nav>
243
+ </div>
244
+ </div>
245
+ </header>
246
+
247
+
248
+ <main id="main-content" class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-6 transition-colors-theme">
249
+
250
+ <h1 class="text-3xl font-semibold text-color-var mb-2">Compare changes</h1>
251
+ <p class="text-secondary-var mb-6 text-sm">
252
+ Compare changes across branches, commits, tags, and more below. If you need to, you can also
253
+ <a href="#" class="text-link-var hover:underline">compare across forks</a>.
254
+ </p>
255
+
256
+ <div class="p-4 border border-color-var rounded-xl bg-active-var/50 mb-6">
257
+ <div class="flex items-center space-x-2 relative">
258
+
259
+ <div class="relative inline-block" id="base-branch-container">
260
+ <button id="base-branch-button" data-branch-type="base" class="branch-dropdown-button flex items-center px-3 py-1.5 text-sm bg-card-var border border-color-var rounded-lg text-color-var hover:bg-active-var transition-colors-theme font-semibold">
261
+ <i data-lucide="git-branch" class="w-4 h-4 mr-1 text-secondary-var"></i> base: <span id="base-branch-name" class="ml-1 text-link-var">main</span>
262
+ <i data-lucide="chevron-down" class="w-4 h-4 ml-1"></i>
263
+ </button>
264
+
265
+ <div id="base-dropdown-card" class="dropdown-card">
266
+ <div class="p-3 border-b border-color-var/50 flex justify-between items-center">
267
+ <span class="text-sm font-semibold">Choose a base ref</span>
268
+ <button class="text-secondary-var hover:text-color-var" onclick="closeDropdown('base')">
269
+ <i data-lucide="x" class="w-4 h-4"></i>
270
+ </button>
271
+ </div>
272
+ <div class="p-2">
273
+ <input type="text" placeholder="Find a branch" id="base-branch-search"
274
+ class="w-full p-2 text-sm rounded-lg border border-color-var bg-page-var focus:outline-none focus:border-link-var focus:ring-1 focus:ring-link-var mb-2">
275
+ <div class="flex border-b border-color-var/50 text-sm mb-2">
276
+ <button class="py-1 px-3 border-b-2 border-link-var text-link-var font-semibold">Branches</button>
277
+ <button class="py-1 px-3 text-secondary-var hover:text-color-var">Tags</button>
278
+ </div>
279
+ <div id="base-branch-list" class="dropdown-content-scroll">
280
+ <div class="flex justify-center py-4">
281
+ <div class="spinner"></div> </div>
282
+ </div>
283
+ </div>
284
+ </div>
285
+ </div>
286
+
287
+ <i data-lucide="arrow-left-right" class="w-4 h-4 text-secondary-var"></i>
288
+
289
+ <div class="relative inline-block" id="compare-branch-container">
290
+ <button id="compare-branch-button" data-branch-type="compare" class="branch-dropdown-button flex items-center px-3 py-1.5 text-sm bg-card-var border border-color-var rounded-lg text-color-var hover:bg-active-var transition-colors-theme font-semibold">
291
+ <i data-lucide="git-branch" class="w-4 h-4 mr-1 text-secondary-var"></i> compare: <span id="compare-branch-name" class="ml-1 text-link-var">main</span>
292
+ <i data-lucide="chevron-down" class="w-4 h-4 ml-1"></i>
293
+ </button>
294
+
295
+ <div id="compare-dropdown-card" class="dropdown-card">
296
+ <div class="p-3 border-b border-color-var/50 flex justify-between items-center">
297
+ <span class="text-sm font-semibold">Choose a head ref</span>
298
+ <button class="text-secondary-var hover:text-color-var" onclick="closeDropdown('compare')">
299
+ <i data-lucide="x" class="w-4 h-4"></i>
300
+ </button>
301
+ </div>
302
+ <div class="p-2">
303
+ <input type="text" placeholder="Find a branch" id="compare-branch-search"
304
+ class="w-full p-2 text-sm rounded-lg border border-color-var bg-page-var focus:outline-none focus:border-link-var focus:ring-1 focus:ring-link-var mb-2">
305
+ <div class="flex border-b border-color-var/50 text-sm mb-2">
306
+ <button class="py-1 px-3 border-b-2 border-link-var text-link-var font-semibold">Branches</button>
307
+ <button class="py-1 px-3 text-secondary-var hover:text-color-var">Tags</button>
308
+ </div>
309
+ <div id="compare-branch-list" class="dropdown-content-scroll">
310
+ <div class="flex justify-center py-4">
311
+ <div class="spinner"></div> </div>
312
+ </div>
313
+ </div>
314
+ </div>
315
+ </div>
316
+
317
+ </div>
318
+ </div>
319
+
320
+ <div id="pr-creation-banner" class="p-4 flex flex-col sm:flex-row justify-between items-start sm:items-center rounded-lg border border-border-warning bg-bg-warning mb-12 space-y-3 sm:space-y-0">
321
+ <p id="pr-banner-message" class="text-color-var text-sm">
322
+ Choose different branches or forks above to discuss and review changes.
323
+ <a href="#" class="text-link-var hover:underline font-medium">Learn about pull requests</a>.
324
+ </p>
325
+ <button id="create-pr-button" class="inline-flex items-center px-4 py-2 text-sm bg-primary-color-var text-white font-semibold rounded-lg hover:bg-primary-hover-var transition duration-150 whitespace-nowrap w-full sm:w-auto">
326
+ Create pull request
327
+ </button>
328
+ </div>
329
+
330
+ <div id="pr-creation-spinner-overlay" class="fixed inset-0 bg-black bg-opacity-10 z-50 items-center justify-center hidden">
331
+ <div class="p-6 bg-card-var rounded-lg shadow-xl flex flex-col items-center">
332
+ <div class="spinner spinner-large mb-3"></div>
333
+ <p class="text-color-var font-semibold">Creating Pull Request and checking for conflicts...</p>
334
+ </div>
335
+ </div>
336
+
337
+ </main>
338
+
339
+ <footer class="w-full border-t border-color-var mt-12 py-8 text-sm text-secondary-var">
340
+ <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 flex flex-col md:flex-row justify-between items-center">
341
+ <div class="flex items-center space-x-4 mb-4 md:mb-0">
342
+ <i data-lucide="git-fork" class="w-5 h-5"></i>
343
+ <span>&copy; 2025 GitForge, Inc.</span>
344
+ </div>
345
+ <nav class="flex flex-wrap justify-center space-x-4">
346
+ <a href="/mindus/nexus/conditions_utilisation?repo_slug={{ repo_slug }}" class="hover:text-link-var">Terms</a>
347
+ <a href="/mindus/nexus/mentions_legales?repo_slug={{ repo_slug }}" class="hover:text-link-var">Privacy</a>
348
+ <a href="/mindus/nexus/politique_confidentialite?repo_slug={{ repo_slug }}" class="hover:text-link-var">Security</a>
349
+ <a href="/mindus/nexus/statut?repo_slug={{ repo_slug }}" class="hover:text-link-var">Status</a>
350
+ <a href="#" class="hover:text-link-var">Community</a>
351
+ <a href="/mindus/nexus/documentation?repo_slug={{ repo_slug }}" class="hover:text-link-var">Docs</a>
352
+ <a href="/mindus/nexus/contact?repo_slug={{ repo_slug }}" class="hover:text-link-var">Contact</a>
353
+ </nav>
354
+ </div>
355
+ </footer>
356
+
357
+ <script>
358
+ // Variables de contexte (Jinja2)
359
+ const REPO_SLUG = "{{ repo_slug if repo_slug else 'mindus0/mindus' }}"; // Variable par défaut si non fournie
360
+ const API_BASE_URL = ""; // Assumer que les routes sont relatives (ex: /api/pr/create)
361
+ let BASE_BRANCH = 'main';
362
+ let COMPARE_BRANCH = 'main';
363
+ let ALL_BRANCHES = [];
364
+
365
+ // Initialiser Lucide Icons
366
+ lucide.createIcons();
367
+
368
+ // SIDEBAR LOGIC (inchangée)
369
+ const sidebar = document.getElementById('sidebar');
370
+ const overlay = document.getElementById('overlay');
371
+ const openButton = document.getElementById('open-sidebar');
372
+ const closeButton = document.getElementById('close-sidebar');
373
+
374
+ const toggleSidebar = () => {
375
+ sidebar.classList.toggle('open');
376
+ overlay.classList.toggle('open');
377
+ };
378
+
379
+ openButton.addEventListener('click', toggleSidebar);
380
+ closeButton.addEventListener('click', toggleSidebar);
381
+ overlay.addEventListener('click', toggleSidebar); // Close when clicking overlay
382
+
383
+ // Prevent scrolling when sidebar is open (for better mobile UX)
384
+ const body = document.body;
385
+ const observer = new MutationObserver(() => {
386
+ if (sidebar.classList.contains('open')) {
387
+ body.style.overflow = 'hidden';
388
+ } else {
389
+ body.style.overflow = '';
390
+ }
391
+ });
392
+
393
+ observer.observe(sidebar, { attributes: true, attributeFilter: ['class'] });
394
+
395
+ // ----------------------------------------------------------------------
396
+ // LOGIQUE DE GESTION DES BRANCHES & DES DROPDOWNS
397
+ // ----------------------------------------------------------------------
398
+
399
+ const baseButton = document.getElementById('base-branch-button');
400
+ const baseNameSpan = document.getElementById('base-branch-name');
401
+ const baseCard = document.getElementById('base-dropdown-card');
402
+ const baseList = document.getElementById('base-branch-list');
403
+ const baseSearch = document.getElementById('base-branch-search');
404
+
405
+ const compareButton = document.getElementById('compare-branch-button');
406
+ const compareNameSpan = document.getElementById('compare-branch-name');
407
+ const compareCard = document.getElementById('compare-dropdown-card');
408
+ const compareList = document.getElementById('compare-branch-list');
409
+ const compareSearch = document.getElementById('compare-branch-search');
410
+
411
+ const prBannerMessage = document.getElementById('pr-banner-message');
412
+ const createPrButton = document.getElementById('create-pr-button');
413
+ const prCreationSpinnerOverlay = document.getElementById('pr-creation-spinner-overlay');
414
+
415
+
416
+ /**
417
+ * Ferme une dropdown spécifique.
418
+ * @param {'base'|'compare'} type
419
+ */
420
+ const closeDropdown = (type) => {
421
+ const card = type === 'base' ? baseCard : compareCard;
422
+ card.classList.remove('open');
423
+ }
424
+
425
+ /**
426
+ * Ouvre/ferme le dropdown et charge les branches si nécessaire.
427
+ * @param {'base'|'compare'} type
428
+ */
429
+ const toggleDropdown = async (type) => {
430
+ const card = type === 'base' ? baseCard : compareCard;
431
+ const otherCard = type === 'base' ? compareCard : baseCard;
432
+
433
+ // Fermer l'autre carte si elle est ouverte
434
+ if (otherCard.classList.contains('open')) {
435
+ otherCard.classList.remove('open');
436
+ }
437
+
438
+ const isOpen = card.classList.toggle('open');
439
+
440
+ if (isOpen && ALL_BRANCHES.length === 0) {
441
+ await fetchBranches();
442
+ }
443
+
444
+ if (isOpen) {
445
+ renderBranchList(type, ALL_BRANCHES);
446
+ }
447
+ };
448
+
449
+ baseButton.addEventListener('click', (e) => {
450
+ e.stopPropagation();
451
+ toggleDropdown('base');
452
+ });
453
+
454
+ compareButton.addEventListener('click', (e) => {
455
+ e.stopPropagation();
456
+ toggleDropdown('compare');
457
+ });
458
+
459
+ // Fermer les dropdowns quand on clique ailleurs
460
+ document.addEventListener('click', (e) => {
461
+ if (baseCard.classList.contains('open') && !document.getElementById('base-branch-container').contains(e.target)) {
462
+ baseCard.classList.remove('open');
463
+ }
464
+ if (compareCard.classList.contains('open') && !document.getElementById('compare-branch-container').contains(e.target)) {
465
+ compareCard.classList.remove('open');
466
+ }
467
+ });
468
+
469
+ /**
470
+ * Simule un appel API pour charger les branches.
471
+ */
472
+ const fetchBranches = async () => {
473
+ try {
474
+ // Données simulées pour la démo
475
+ await new Promise(resolve => setTimeout(resolve, 500));
476
+ ALL_BRANCHES = ['main', 'feature/dev-2.0', 'feature/bugfix-101', 'docs/readme-update', 'release/v1.0'];
477
+
478
+ } catch (error) {
479
+ console.error("Erreur lors du chargement des branches:", error);
480
+ ALL_BRANCHES = ['main']; // Default fallback
481
+ }
482
+
483
+ // Met à jour les listes si elles sont ouvertes
484
+ if (baseCard.classList.contains('open')) renderBranchList('base', ALL_BRANCHES);
485
+ if (compareCard.classList.contains('open')) renderBranchList('compare', ALL_BRANCHES);
486
+ };
487
+
488
+ /**
489
+ * Rend la liste des branches dans le dropdown.
490
+ * @param {'base'|'compare'} type
491
+ * @param {string[]} branches
492
+ */
493
+ const renderBranchList = (type, branches) => {
494
+ const listElement = type === 'base' ? baseList : compareList;
495
+ const currentBranch = type === 'base' ? BASE_BRANCH : COMPARE_BRANCH;
496
+ const searchInput = type === 'base' ? baseSearch : compareSearch;
497
+
498
+ // Filtrer les branches
499
+ const searchTerm = searchInput.value.toLowerCase();
500
+ const filteredBranches = branches.filter(b => b.toLowerCase().includes(searchTerm));
501
+
502
+ listElement.innerHTML = ''; // Nettoyer le contenu
503
+
504
+ if (filteredBranches.length === 0) {
505
+ listElement.innerHTML = '<p class="text-secondary-var text-sm p-2">No branches found.</p>';
506
+ return;
507
+ }
508
+
509
+ filteredBranches.forEach(branch => {
510
+ const isSelected = branch === currentBranch;
511
+ const item = document.createElement('div');
512
+ item.className = `flex items-center justify-between p-2 rounded-lg text-sm cursor-pointer ${isSelected ? 'bg-active-var font-medium' : 'hover:bg-active-var'}`;
513
+ item.innerHTML = `
514
+ <span class="flex items-center ${isSelected ? 'text-link-var' : 'text-color-var'}">
515
+ ${isSelected ? '<i data-lucide="check" class="w-4 h-4 mr-2"></i>' : '<i data-lucide="git-branch" class="w-4 h-4 mr-2 text-secondary-var"></i>'}
516
+ ${branch}
517
+ </span>
518
+ ${branch === 'main' ? '<span class="text-xs text-secondary-var px-2 py-0.5 border border-color-var rounded-full">default</span>' : ''}
519
+ `;
520
+
521
+ // Mise à jour de la branche sélectionnée
522
+ item.addEventListener('click', () => {
523
+ if (type === 'base') {
524
+ BASE_BRANCH = branch;
525
+ baseNameSpan.textContent = branch;
526
+ } else {
527
+ COMPARE_BRANCH = branch;
528
+ compareNameSpan.textContent = branch;
529
+ }
530
+ updateBranchComparisonStatus();
531
+ closeDropdown(type);
532
+ lucide.createIcons(); // Rendre l'icône de check si nécessaire
533
+ });
534
+
535
+ listElement.appendChild(item);
536
+ });
537
+ lucide.createIcons(); // Rendre les icônes ajoutées
538
+ };
539
+
540
+ baseSearch.addEventListener('input', () => renderBranchList('base', ALL_BRANCHES));
541
+ compareSearch.addEventListener('input', () => renderBranchList('compare', ALL_BRANCHES));
542
+
543
+ /**
544
+ * Met à jour le message d'en-tête et l'état du bouton PR en fonction des branches sélectionnées.
545
+ */
546
+ const updateBranchComparisonStatus = () => {
547
+ if (BASE_BRANCH === COMPARE_BRANCH) {
548
+ prBannerMessage.innerHTML = `Choose different branches or forks above to discuss and review changes. <a href="#" class="text-link-var hover:underline font-medium">Learn about pull requests</a>.`;
549
+ createPrButton.disabled = true;
550
+ createPrButton.classList.remove('bg-primary-color-var', 'hover:bg-primary-hover-var');
551
+ createPrButton.classList.add('bg-secondary-var/50', 'cursor-not-allowed');
552
+ createPrButton.textContent = 'Create pull request';
553
+ } else {
554
+ prBannerMessage.innerHTML = `Ready to create a pull request from <span class="font-bold">${COMPARE_BRANCH}</span> to <span class="font-bold">${BASE_BRANCH}</span>. <a href="#" class="text-link-var hover:underline font-medium">Learn about pull requests</a>.`;
555
+ createPrButton.disabled = false;
556
+ createPrButton.classList.remove('bg-secondary-var/50', 'cursor-not-allowed');
557
+ createPrButton.classList.add('bg-primary-color-var', 'hover:bg-primary-hover-var');
558
+ createPrButton.textContent = `Create pull request for ${COMPARE_BRANCH}`;
559
+ }
560
+ };
561
+
562
+ // Initialisation
563
+ updateBranchComparisonStatus();
564
+
565
+
566
+ // ----------------------------------------------------------------------
567
+ // LOGIQUE DE CRÉATION DE PULL REQUEST
568
+ // ----------------------------------------------------------------------
569
+
570
+ createPrButton.addEventListener('click', async () => {
571
+ if (createPrButton.disabled) return;
572
+
573
+ // 1. Afficher le spinner centralisé
574
+ prCreationSpinnerOverlay.classList.remove('hidden');
575
+ prCreationSpinnerOverlay.classList.add('flex');
576
+
577
+ // Prompt pour le titre et la description
578
+ const title = prompt("Enter a title for your Pull Request (required):");
579
+ if (!title) {
580
+ alert("PR creation cancelled: Title is required.");
581
+ prCreationSpinnerOverlay.classList.remove('flex');
582
+ prCreationSpinnerOverlay.classList.add('hidden');
583
+ return;
584
+ }
585
+ const description = prompt("Enter a description (optional):") || "";
586
+
587
+ try {
588
+ // 2. Appel API pour la création
589
+ const response = await fetch(`${API_BASE_URL}/api/pr/create`, {
590
+ method: 'POST',
591
+ headers: {
592
+ 'Content-Type': 'application/json',
593
+ },
594
+ body: JSON.stringify({
595
+ repo_slug: REPO_SLUG,
596
+ source_branch: COMPARE_BRANCH, // Source / Head
597
+ target_branch: BASE_BRANCH, // Target / Base
598
+ title: title,
599
+ description: description
600
+ })
601
+ });
602
+
603
+ const result = await response.json();
604
+
605
+ // 3. Masquer le spinner
606
+ prCreationSpinnerOverlay.classList.remove('flex');
607
+ prCreationSpinnerOverlay.classList.add('hidden');
608
+
609
+ if (result.success) {
610
+ // REDIRECTION demandée après succès
611
+ window.location.href = `/mindus/nexus/pull_requests?repo_slug=${REPO_SLUG}`;
612
+ } else {
613
+ alert(`PR Creation Failed: ${result.message}`);
614
+ }
615
+
616
+ } catch (error) {
617
+ console.error("Error creating PR:", error);
618
+ prCreationSpinnerOverlay.classList.remove('flex');
619
+ prCreationSpinnerOverlay.classList.add('hidden');
620
+ alert("An error occurred during PR creation.");
621
+ }
622
+ });
623
+
624
+
625
+ // --- Initialisation au chargement de la page ---
626
+ document.addEventListener('DOMContentLoaded', () => {
627
+ // Pré-charger les branches
628
+ fetchBranches();
629
+ });
630
+ </script>
631
+ </body>
632
+ </html>