flowpilot 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1962 @@
1
+ import { a as useRef, c as Fragment, i as useReducer, n as instance, r as useEffect, s as render, t as jsxDEV } from "./jsx-dev-runtime-DOO7Tqjo.js";
2
+ import { t as filterByRelevance } from "./search-cPm8k8mK.js";
3
+ //#region src/commands/release/client.tsx
4
+ const initPromise = typeof window !== "undefined" && window.__I18N_LOCALE__ && window.__I18N_RESOURCES__ ? instance.init({
5
+ lng: window.__I18N_LOCALE__,
6
+ fallbackLng: "zh-CN",
7
+ resources: window.__I18N_RESOURCES__,
8
+ interpolation: { escapeValue: false }
9
+ }) : Promise.resolve();
10
+ const t = instance.t;
11
+ const releaseStyle = `
12
+ .page-header {
13
+ margin-bottom: 28px;
14
+ animation: slide-up 0.3s cubic-bezier(0.16, 1, 0.3, 1) 0.05s both;
15
+ }
16
+ .page-header h2 {
17
+ font-size: 22px;
18
+ font-weight: 600;
19
+ letter-spacing: -0.02em;
20
+ margin-bottom: 6px;
21
+ }
22
+ .page-header p {
23
+ font-size: 13px;
24
+ color: var(--text-2);
25
+ font-weight: 300;
26
+ line-height: 1.5;
27
+ }
28
+
29
+ /* ── Pipeline ── */
30
+ .pipeline {
31
+ display: flex;
32
+ align-items: center;
33
+ gap: 0;
34
+ margin-bottom: 28px;
35
+ animation: slide-up 0.3s cubic-bezier(0.16, 1, 0.3, 1) 0.08s both;
36
+ }
37
+ .pipeline-step {
38
+ display: flex;
39
+ align-items: center;
40
+ gap: 6px;
41
+ font-size: 11px;
42
+ font-family: var(--mono);
43
+ color: var(--text-3);
44
+ font-weight: 400;
45
+ white-space: nowrap;
46
+ }
47
+ .pipeline-step.active {
48
+ color: var(--neon);
49
+ font-weight: 500;
50
+ }
51
+ .pipeline-step.done {
52
+ color: var(--cyan);
53
+ }
54
+ .pipeline-node {
55
+ width: 8px; height: 8px;
56
+ border-radius: 50%;
57
+ background: var(--text-3);
58
+ transition: background 0.3s, box-shadow 0.3s;
59
+ }
60
+ .pipeline-step.active .pipeline-node {
61
+ background: var(--neon);
62
+ box-shadow: 0 0 8px var(--neon-glow);
63
+ animation: neon-pulse 2s ease infinite;
64
+ }
65
+ .pipeline-step.done .pipeline-node {
66
+ background: var(--cyan);
67
+ box-shadow: 0 0 4px var(--cyan-glow);
68
+ }
69
+ .pipeline-line {
70
+ width: 32px;
71
+ height: 1px;
72
+ background: var(--border);
73
+ margin: 0 4px;
74
+ transition: background 0.3s;
75
+ }
76
+ .pipeline-line.done { background: var(--cyan); }
77
+
78
+ /* ── Generic select ── */
79
+ .sel {
80
+ position: relative;
81
+ margin-bottom: 16px;
82
+ animation: slide-up 0.3s cubic-bezier(0.16, 1, 0.3, 1) 0.12s both;
83
+ z-index: 1;
84
+ }
85
+ .sel-trigger {
86
+ width: 100%;
87
+ display: flex;
88
+ align-items: center;
89
+ gap: 8px;
90
+ padding: 12px 14px;
91
+ font-size: 13px;
92
+ font-family: var(--sans);
93
+ color: var(--text-1, #E2E8F0);
94
+ background: var(--bg-input, #0A0E14);
95
+ border: 1px solid var(--border);
96
+ border-radius: 8px;
97
+ cursor: pointer;
98
+ outline: none;
99
+ transition: border-color 0.2s, box-shadow 0.2s;
100
+ text-align: left;
101
+ }
102
+ .sel-trigger:hover { border-color: var(--border-active); }
103
+ .sel-trigger:focus,
104
+ .sel-trigger.open {
105
+ border-color: var(--neon);
106
+ box-shadow: 0 0 0 2px var(--neon-soft), 0 0 8px var(--neon-glow);
107
+ }
108
+ .sel-trigger-label {
109
+ font-size: 11px;
110
+ color: var(--text-3, #64748B);
111
+ flex-shrink: 0;
112
+ }
113
+ .sel-trigger-value {
114
+ flex: 1;
115
+ font-family: var(--mono);
116
+ font-size: 13px;
117
+ font-weight: 500;
118
+ color: var(--text-1, #E2E8F0);
119
+ }
120
+ .sel-trigger-value.empty {
121
+ color: var(--text-3);
122
+ font-weight: 300;
123
+ }
124
+ .sel-trigger-arrow {
125
+ color: var(--text-3, #64748B);
126
+ font-size: 10px;
127
+ transition: transform 0.2s;
128
+ }
129
+ .sel-trigger.open .sel-trigger-arrow {
130
+ transform: rotate(180deg);
131
+ }
132
+ .sel-dropdown {
133
+ position: absolute;
134
+ top: calc(100% + 6px);
135
+ left: 0; right: 0;
136
+ max-height: 280px;
137
+ overflow-y: auto;
138
+ background: var(--bg-card, #111820);
139
+ border: 1px solid rgba(0,255,136,0.08);
140
+ border-radius: 8px;
141
+ box-shadow: 0 8px 32px rgba(0,0,0,0.6), 0 0 12px rgba(0,255,136,0.03);
142
+ z-index: 1000;
143
+ animation: dropdown-in 0.12s ease both;
144
+ }
145
+ .sel-dropdown::-webkit-scrollbar { width: 6px; }
146
+ .sel-dropdown::-webkit-scrollbar-track { background: transparent; }
147
+ .sel-dropdown::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
148
+ .sel-search {
149
+ padding: 8px;
150
+ border-bottom: 1px solid var(--border);
151
+ position: sticky;
152
+ top: 0;
153
+ background: var(--bg-card, #111820);
154
+ z-index: 1;
155
+ }
156
+ .sel-search-input {
157
+ width: 100%;
158
+ padding: 6px 10px;
159
+ font-size: 12px;
160
+ font-family: var(--mono);
161
+ color: var(--text-1, #E2E8F0);
162
+ background: var(--bg-void, #0A0A0F);
163
+ border: 1px solid var(--border);
164
+ border-radius: 4px;
165
+ outline: none;
166
+ transition: border-color 0.15s;
167
+ }
168
+ .sel-search-input::placeholder { color: var(--text-3); }
169
+ .sel-search-input:focus { border-color: var(--neon); }
170
+ .sel-item {
171
+ padding: 10px 14px;
172
+ font-size: 13px;
173
+ cursor: pointer;
174
+ transition: background 0.1s;
175
+ border-left: 3px solid transparent;
176
+ color: var(--text-1, #E2E8F0);
177
+ }
178
+ .sel-item:first-child { border-radius: 7px 7px 0 0; }
179
+ .sel-item:last-child { border-radius: 0 0 7px 7px; }
180
+ .sel-item:hover,
181
+ .sel-item.highlighted { background: var(--bg-hover, rgba(0,255,136,0.04)); }
182
+ .sel-item.active {
183
+ background: var(--neon-soft, rgba(0,255,136,0.08));
184
+ border-left-color: var(--neon);
185
+ font-weight: 500;
186
+ }
187
+ .sel-item-name { font-weight: 500; color: var(--text-1, #E2E8F0); }
188
+ .sel-item-sub { font-size: 11px; color: var(--text-3, #64748B); font-family: var(--mono); margin-top: 2px; }
189
+ .sel-empty { padding: 12px; text-align: center; color: var(--text-3, #64748B); font-size: 12px; }
190
+
191
+ /* ── Spinner ── */
192
+ .spinner {
193
+ display: inline-block;
194
+ width: 14px; height: 14px;
195
+ border: 2px solid var(--border);
196
+ border-top-color: var(--neon);
197
+ border-radius: 50%;
198
+ animation: spin 0.6s linear infinite;
199
+ }
200
+ @keyframes spin { to { transform: rotate(360deg); } }
201
+ .loading-row {
202
+ display: flex;
203
+ align-items: center;
204
+ gap: 8px;
205
+ padding: 10px 14px;
206
+ color: var(--text-3);
207
+ font-size: 13px;
208
+ margin-bottom: 16px;
209
+ animation: slide-up 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
210
+ }
211
+
212
+ /* ── Version display ── */
213
+ .version-display {
214
+ display: flex;
215
+ align-items: center;
216
+ gap: 12px;
217
+ padding: 14px 20px;
218
+ background: var(--bg-card);
219
+ border: 1px solid rgba(0,212,255,0.08);
220
+ border-radius: 8px;
221
+ animation: slide-up 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
222
+ }
223
+ .version-tag { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.05em; font-family: var(--mono); }
224
+ .version-number { font-size: 20px; font-weight: 600; font-family: var(--mono); color: var(--cyan); letter-spacing: -0.01em; }
225
+ .version-error { color: var(--error); font-size: 13px; animation: slide-up 0.3s cubic-bezier(0.16, 1, 0.3, 1) both; }
226
+
227
+ .empty-hint { text-align: center; padding: 32px 0; color: var(--text-3); font-size: 13px; animation: slide-up 0.3s cubic-bezier(0.16, 1, 0.3, 1) 0.15s both; }
228
+ .state-error { color: var(--error); font-size: 13px; animation: slide-up 0.3s cubic-bezier(0.16, 1, 0.3, 1) both; }
229
+
230
+ /* ── Jira ── */
231
+ .jira-section { margin-top: 20px; animation: slide-up 0.3s cubic-bezier(0.16, 1, 0.3, 1) both; }
232
+ .jira-btn {
233
+ width: 100%;
234
+ min-height: 44px;
235
+ padding: 10px 20px;
236
+ font-size: 13px;
237
+ font-family: var(--sans);
238
+ font-weight: 500;
239
+ color: var(--bg-void);
240
+ background: var(--neon);
241
+ border: none;
242
+ border-radius: 8px;
243
+ cursor: pointer;
244
+ transition: background 0.15s, box-shadow 0.2s;
245
+ margin-top: 16px;
246
+ position: relative;
247
+ z-index: 1;
248
+ }
249
+ .jira-btn:hover { background: var(--neon-hover); box-shadow: 0 0 12px var(--neon-glow), 0 2px 12px rgba(0,255,136,0.2); }
250
+ .jira-btn:disabled { opacity: 0.5; cursor: not-allowed; }
251
+
252
+ /* ── Custom Checkbox ── */
253
+ input[type="checkbox"] {
254
+ appearance: none;
255
+ width: 16px;
256
+ height: 16px;
257
+ border: 1px solid var(--border, rgba(0,255,136,0.2));
258
+ border-radius: 3px;
259
+ background: var(--bg-input, #0A0E14);
260
+ cursor: pointer;
261
+ position: relative;
262
+ transition: border-color 0.15s, background 0.15s;
263
+ }
264
+ input[type="checkbox"]:checked {
265
+ background: var(--neon, #00ff88);
266
+ border-color: var(--neon, #00ff88);
267
+ }
268
+ input[type="checkbox"]:checked::after {
269
+ content: "✓";
270
+ position: absolute;
271
+ top: -1px;
272
+ left: 2px;
273
+ font-size: 12px;
274
+ font-weight: 700;
275
+ color: var(--bg-void, #0A0A0F);
276
+ }
277
+ input[type="checkbox"]:focus-visible {
278
+ outline: 2px solid var(--neon-soft, rgba(0,255,136,0.2));
279
+ outline-offset: 2px;
280
+ }
281
+ .jira-result {
282
+ margin-top: 12px;
283
+ padding: 12px 16px;
284
+ background: var(--bg-card);
285
+ border: 1px solid var(--border);
286
+ border-radius: 8px;
287
+ animation: slide-up 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
288
+ position: relative;
289
+ z-index: 1;
290
+ }
291
+ .jira-result-key {
292
+ font-family: var(--mono);
293
+ font-size: 14px;
294
+ font-weight: 600;
295
+ color: var(--neon);
296
+ text-decoration: none;
297
+ border-bottom: 1px dashed rgba(0,255,136,0.3);
298
+ transition: border-color 0.2s;
299
+ }
300
+ .jira-result-key:hover { border-bottom-color: var(--neon); }
301
+ .jira-result-label { font-size: 11px; color: var(--text-3); margin-bottom: 4px; }
302
+ .jira-result-badge { display: inline-block; font-size: 10px; padding: 2px 8px; border-radius: 4px; margin-left: 8px; font-weight: 500; }
303
+ .jira-result-badge.created { background: var(--neon-soft); color: var(--neon); }
304
+ .jira-result-badge.exists { background: var(--cyan-soft); color: var(--cyan); }
305
+ .jira-error { margin-top: 12px; color: var(--error); font-size: 13px; animation: slide-up 0.3s cubic-bezier(0.16, 1, 0.3, 1) both; }
306
+
307
+ /* ── History ── */
308
+ .history-section {
309
+ margin-bottom: 24px;
310
+ animation: slide-up 0.3s cubic-bezier(0.16, 1, 0.3, 1) 0.06s both;
311
+ }
312
+ .history-title {
313
+ font-size: 16px;
314
+ font-weight: 600;
315
+ margin-bottom: 12px;
316
+ color: var(--text-1);
317
+ }
318
+ .history-list {
319
+ display: flex;
320
+ flex-direction: column;
321
+ gap: 8px;
322
+ }
323
+ .history-item {
324
+ display: flex;
325
+ flex-direction: column;
326
+ padding: 12px 16px;
327
+ background: var(--bg-card);
328
+ border: 1px solid var(--border);
329
+ border-radius: 8px;
330
+ transition: border-color 0.15s, box-shadow 0.15s;
331
+ animation: slide-up 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
332
+ }
333
+ .history-item-row {
334
+ display: flex;
335
+ align-items: center;
336
+ justify-content: space-between;
337
+ }
338
+ .history-item:hover {
339
+ border-color: var(--border-active);
340
+ box-shadow: 0 2px 8px rgba(0,0,0,0.3);
341
+ }
342
+ .history-info {
343
+ display: flex;
344
+ align-items: center;
345
+ gap: 12px;
346
+ flex: 1;
347
+ }
348
+ .history-project { font-weight: 500; color: var(--text-1); font-size: 14px; }
349
+ .history-detail { font-size: 12px; color: var(--text-3); font-family: var(--mono); }
350
+ .history-actions { display: flex; align-items: center; gap: 8px; }
351
+ .history-quick-btn {
352
+ padding: 6px 14px;
353
+ font-size: 12px;
354
+ font-family: var(--sans);
355
+ font-weight: 500;
356
+ color: var(--bg-void);
357
+ background: var(--neon);
358
+ border: none;
359
+ border-radius: 6px;
360
+ cursor: pointer;
361
+ transition: background 0.15s;
362
+ }
363
+ .history-quick-btn:hover { background: var(--neon-hover); }
364
+ .history-quick-btn:disabled { opacity: 0.5; cursor: not-allowed; }
365
+ .history-quick-btn.executing {
366
+ background: var(--border);
367
+ color: var(--text-3);
368
+ }
369
+ .history-footer {
370
+ display: flex;
371
+ align-items: center;
372
+ justify-content: space-between;
373
+ margin-top: 16px;
374
+ padding-top: 16px;
375
+ border-top: 1px solid var(--border);
376
+ }
377
+ .history-new-btn {
378
+ padding: 8px 16px;
379
+ font-size: 13px;
380
+ font-family: var(--sans);
381
+ font-weight: 500;
382
+ color: var(--bg-void);
383
+ background: var(--neon);
384
+ border: none;
385
+ border-radius: 8px;
386
+ cursor: pointer;
387
+ transition: background 0.15s, box-shadow 0.2s;
388
+ }
389
+ .history-new-btn:hover { background: var(--neon-hover); box-shadow: 0 0 12px var(--neon-glow); }
390
+ .history-clear-btn {
391
+ padding: 8px 16px;
392
+ font-size: 13px;
393
+ font-family: var(--sans);
394
+ font-weight: 400;
395
+ color: var(--text-3);
396
+ background: transparent;
397
+ border: 1px solid var(--border);
398
+ border-radius: 8px;
399
+ cursor: pointer;
400
+ transition: border-color 0.15s, color 0.15s;
401
+ }
402
+ .history-clear-btn:hover { border-color: var(--error); color: var(--error); }
403
+ .history-result {
404
+ margin-top: 12px;
405
+ padding: 10px 14px;
406
+ background: var(--bg-void);
407
+ border: 1px solid rgba(0,255,136,0.08);
408
+ border-radius: 8px;
409
+ animation: slide-up 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
410
+ }
411
+ .history-result-key {
412
+ font-family: var(--mono);
413
+ font-size: 14px;
414
+ font-weight: 600;
415
+ color: var(--neon);
416
+ text-decoration: none;
417
+ }
418
+ .history-result-error {
419
+ color: var(--error);
420
+ font-size: 13px;
421
+ }
422
+
423
+ /* ── Modal ── */
424
+ .modal-overlay {
425
+ position: fixed;
426
+ top: 0; left: 0; right: 0; bottom: 0;
427
+ background: rgba(0,0,0,0.7);
428
+ display: flex;
429
+ align-items: center;
430
+ justify-content: center;
431
+ z-index: 2000;
432
+ animation: fade-in 0.2s ease both;
433
+ }
434
+ .modal-content {
435
+ width: 90%;
436
+ max-width: 560px;
437
+ background: var(--bg-void);
438
+ border: 1px solid var(--border);
439
+ border-radius: 12px;
440
+ padding: 24px;
441
+ animation: slide-up 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
442
+ }
443
+ .modal-header {
444
+ display: flex;
445
+ align-items: center;
446
+ justify-content: space-between;
447
+ margin-bottom: 20px;
448
+ }
449
+ .modal-title { font-size: 18px; font-weight: 600; color: var(--text-1); }
450
+ .modal-close {
451
+ width: 32px; height: 32px;
452
+ display: flex;
453
+ align-items: center;
454
+ justify-content: center;
455
+ font-size: 16px;
456
+ color: var(--text-3);
457
+ background: transparent;
458
+ border: 1px solid var(--border);
459
+ border-radius: 6px;
460
+ cursor: pointer;
461
+ transition: border-color 0.15s, color 0.15s;
462
+ }
463
+ .modal-close:hover { border-color: var(--text-2); color: var(--text-2); }
464
+ `;
465
+ const initial = {
466
+ jiraHost: "",
467
+ projects: [],
468
+ projectsLoading: true,
469
+ projectsError: "",
470
+ projectOpen: false,
471
+ projectSearch: "",
472
+ projectIndex: -1,
473
+ selected: null,
474
+ branches: [],
475
+ branchesLoading: false,
476
+ branchOpen: false,
477
+ branchSearch: "",
478
+ branchIndex: -1,
479
+ selectedBranch: "",
480
+ pomInfo: null,
481
+ pomLoading: false,
482
+ pomError: "",
483
+ jiraProjects: [],
484
+ jiraProjectsLoading: false,
485
+ jiraProjectOpen: false,
486
+ jiraProjectSearch: "",
487
+ jiraProjectIndex: -1,
488
+ selectedJiraProject: null,
489
+ jiraStatus: "idle",
490
+ jiraResult: null,
491
+ jiraError: "",
492
+ mrStatus: "idle",
493
+ mrUrl: "",
494
+ mrError: "",
495
+ mrBranches: [],
496
+ mrSourceBranch: "",
497
+ mrTargetBranch: "",
498
+ mrBranchOpen: false,
499
+ mrBranchSearch: "",
500
+ mrBranchIndex: -1,
501
+ history: [],
502
+ historyLoading: true,
503
+ quickExecuting: null,
504
+ quickResults: {},
505
+ quickErrors: {},
506
+ showNewModal: false,
507
+ clearConfirm: false,
508
+ createMrChecked: {}
509
+ };
510
+ const reducer = (state, action) => {
511
+ switch (action.type) {
512
+ case "SET_JIRA_HOST": return {
513
+ ...state,
514
+ jiraHost: action.host
515
+ };
516
+ case "PROJECTS_LOADED": return {
517
+ ...state,
518
+ projects: action.projects,
519
+ projectsLoading: false
520
+ };
521
+ case "PROJECTS_ERROR": return {
522
+ ...state,
523
+ projectsError: action.error,
524
+ projectsLoading: false
525
+ };
526
+ case "SET_PROJECT_OPEN": return {
527
+ ...state,
528
+ projectOpen: action.open,
529
+ ...action.open ? {} : {
530
+ projectSearch: "",
531
+ projectIndex: -1
532
+ }
533
+ };
534
+ case "SET_PROJECT_SEARCH": return {
535
+ ...state,
536
+ projectSearch: action.search,
537
+ projectIndex: -1
538
+ };
539
+ case "SET_PROJECT_INDEX": return {
540
+ ...state,
541
+ projectIndex: action.index
542
+ };
543
+ case "SELECT_PROJECT": return {
544
+ ...state,
545
+ selected: action.project,
546
+ projectOpen: false,
547
+ projectSearch: "",
548
+ projectIndex: -1,
549
+ branches: [],
550
+ branchesLoading: false,
551
+ selectedBranch: "",
552
+ branchOpen: false,
553
+ branchSearch: "",
554
+ branchIndex: -1,
555
+ pomInfo: null,
556
+ pomError: "",
557
+ selectedJiraProject: null,
558
+ jiraStatus: "idle",
559
+ jiraResult: null,
560
+ jiraError: "",
561
+ mrStatus: "idle",
562
+ mrUrl: "",
563
+ mrError: "",
564
+ mrBranches: [],
565
+ mrSourceBranch: "",
566
+ mrTargetBranch: "",
567
+ mrBranchOpen: false,
568
+ mrBranchSearch: "",
569
+ mrBranchIndex: -1
570
+ };
571
+ case "CLEAR_PROJECT": return {
572
+ ...state,
573
+ selected: null,
574
+ branches: [],
575
+ selectedBranch: "",
576
+ branchOpen: false,
577
+ branchSearch: "",
578
+ branchIndex: -1,
579
+ pomInfo: null,
580
+ pomError: "",
581
+ pomLoading: false,
582
+ selectedJiraProject: null,
583
+ jiraStatus: "idle",
584
+ jiraResult: null,
585
+ jiraError: "",
586
+ mrStatus: "idle",
587
+ mrUrl: "",
588
+ mrError: "",
589
+ mrBranches: [],
590
+ mrSourceBranch: "",
591
+ mrTargetBranch: "",
592
+ mrBranchOpen: false,
593
+ mrBranchSearch: "",
594
+ mrBranchIndex: -1
595
+ };
596
+ case "BRANCHES_LOADING": return {
597
+ ...state,
598
+ branchesLoading: true,
599
+ branches: [],
600
+ selectedBranch: ""
601
+ };
602
+ case "BRANCHES_LOADED": return {
603
+ ...state,
604
+ branches: action.branches,
605
+ branchesLoading: false
606
+ };
607
+ case "SET_BRANCH_OPEN": return {
608
+ ...state,
609
+ branchOpen: action.open,
610
+ ...action.open ? {} : {
611
+ branchSearch: "",
612
+ branchIndex: -1
613
+ }
614
+ };
615
+ case "SET_BRANCH_SEARCH": return {
616
+ ...state,
617
+ branchSearch: action.search,
618
+ branchIndex: -1
619
+ };
620
+ case "SET_BRANCH_INDEX": return {
621
+ ...state,
622
+ branchIndex: action.index
623
+ };
624
+ case "SELECT_BRANCH": return {
625
+ ...state,
626
+ selectedBranch: action.branch,
627
+ branchOpen: false,
628
+ branchSearch: "",
629
+ branchIndex: -1
630
+ };
631
+ case "POM_LOADING": return {
632
+ ...state,
633
+ pomLoading: true,
634
+ pomError: "",
635
+ pomInfo: null
636
+ };
637
+ case "POM_LOADED": return {
638
+ ...state,
639
+ pomLoading: false,
640
+ pomInfo: action.info
641
+ };
642
+ case "POM_ERROR": return {
643
+ ...state,
644
+ pomLoading: false,
645
+ pomError: action.error
646
+ };
647
+ case "JIRA_PROJECTS_LOADING": return {
648
+ ...state,
649
+ jiraProjectsLoading: true
650
+ };
651
+ case "JIRA_PROJECTS_LOADED": return {
652
+ ...state,
653
+ jiraProjects: action.projects,
654
+ jiraProjectsLoading: false
655
+ };
656
+ case "JIRA_PROJECTS_ERROR": return {
657
+ ...state,
658
+ jiraProjectsLoading: false
659
+ };
660
+ case "SET_JIRA_PROJECT_OPEN": return {
661
+ ...state,
662
+ jiraProjectOpen: action.open,
663
+ ...action.open ? {} : {
664
+ jiraProjectSearch: "",
665
+ jiraProjectIndex: -1
666
+ }
667
+ };
668
+ case "SET_JIRA_PROJECT_SEARCH": return {
669
+ ...state,
670
+ jiraProjectSearch: action.search,
671
+ jiraProjectIndex: -1
672
+ };
673
+ case "SET_JIRA_PROJECT_INDEX": return {
674
+ ...state,
675
+ jiraProjectIndex: action.index
676
+ };
677
+ case "SELECT_JIRA_PROJECT": return {
678
+ ...state,
679
+ selectedJiraProject: action.project,
680
+ jiraProjectOpen: false,
681
+ jiraProjectSearch: "",
682
+ jiraProjectIndex: -1,
683
+ jiraStatus: "idle",
684
+ jiraResult: null,
685
+ jiraError: ""
686
+ };
687
+ case "CLEAR_JIRA_PROJECT": return {
688
+ ...state,
689
+ selectedJiraProject: null,
690
+ jiraProjectOpen: false,
691
+ jiraProjectSearch: "",
692
+ jiraProjectIndex: -1,
693
+ jiraStatus: "idle",
694
+ jiraResult: null,
695
+ jiraError: ""
696
+ };
697
+ case "JIRA_CHECKING": return {
698
+ ...state,
699
+ jiraStatus: "checking",
700
+ jiraResult: null,
701
+ jiraError: ""
702
+ };
703
+ case "JIRA_CREATING": return {
704
+ ...state,
705
+ jiraStatus: "creating"
706
+ };
707
+ case "JIRA_DONE": return {
708
+ ...state,
709
+ jiraStatus: "done",
710
+ jiraResult: action.result
711
+ };
712
+ case "JIRA_ERROR": return {
713
+ ...state,
714
+ jiraStatus: "error",
715
+ jiraError: action.error
716
+ };
717
+ case "JIRA_RESET": return {
718
+ ...state,
719
+ jiraStatus: "idle",
720
+ jiraResult: null,
721
+ jiraError: ""
722
+ };
723
+ case "SET_HISTORY": return {
724
+ ...state,
725
+ history: action.history,
726
+ historyLoading: false
727
+ };
728
+ case "QUICK_EXEC_START": return {
729
+ ...state,
730
+ quickExecuting: action.id
731
+ };
732
+ case "QUICK_EXEC_SUCCESS": return {
733
+ ...state,
734
+ quickExecuting: null,
735
+ quickResults: {
736
+ ...state.quickResults,
737
+ [action.id]: action.result
738
+ }
739
+ };
740
+ case "QUICK_EXEC_FAIL": return {
741
+ ...state,
742
+ quickExecuting: null,
743
+ quickErrors: {
744
+ ...state.quickErrors,
745
+ [action.id]: action.error
746
+ }
747
+ };
748
+ case "SHOW_NEW_MODAL": return {
749
+ ...state,
750
+ showNewModal: true
751
+ };
752
+ case "HIDE_NEW_MODAL": return {
753
+ ...state,
754
+ showNewModal: false
755
+ };
756
+ case "CLEAR_CONFIRM_TOGGLE": return {
757
+ ...state,
758
+ clearConfirm: !state.clearConfirm
759
+ };
760
+ case "CLEAR_HISTORY_DONE": return {
761
+ ...state,
762
+ history: [],
763
+ clearConfirm: false,
764
+ quickResults: {},
765
+ quickErrors: {}
766
+ };
767
+ case "TOGGLE_CREATE_MR": return {
768
+ ...state,
769
+ createMrChecked: {
770
+ ...state.createMrChecked,
771
+ [action.id]: !state.createMrChecked[action.id]
772
+ }
773
+ };
774
+ case "MR_SELECTING": return {
775
+ ...state,
776
+ mrStatus: "selecting",
777
+ mrBranches: action.branches,
778
+ mrSourceBranch: "",
779
+ mrTargetBranch: "",
780
+ mrError: ""
781
+ };
782
+ case "MR_SOURCE_SELECTED": return {
783
+ ...state,
784
+ mrSourceBranch: action.branch,
785
+ mrBranchOpen: false,
786
+ mrBranchSearch: "",
787
+ mrBranchIndex: -1
788
+ };
789
+ case "SET_MR_BRANCH_OPEN": return {
790
+ ...state,
791
+ mrBranchOpen: action.open,
792
+ ...action.open ? {} : {
793
+ mrBranchSearch: "",
794
+ mrBranchIndex: -1
795
+ }
796
+ };
797
+ case "SET_MR_BRANCH_SEARCH": return {
798
+ ...state,
799
+ mrBranchSearch: action.search,
800
+ mrBranchIndex: -1
801
+ };
802
+ case "SET_MR_BRANCH_INDEX": return {
803
+ ...state,
804
+ mrBranchIndex: action.index
805
+ };
806
+ case "MR_LOADING": return {
807
+ ...state,
808
+ mrStatus: "loading",
809
+ mrBranches: [],
810
+ mrSourceBranch: "",
811
+ mrTargetBranch: "",
812
+ mrError: ""
813
+ };
814
+ case "MR_CREATING": return {
815
+ ...state,
816
+ mrStatus: "creating",
817
+ mrUrl: "",
818
+ mrTargetBranch: "",
819
+ mrError: ""
820
+ };
821
+ case "MR_DONE": return {
822
+ ...state,
823
+ mrStatus: "done",
824
+ mrUrl: action.mrUrl,
825
+ mrSourceBranch: action.mrSourceBranch,
826
+ mrTargetBranch: action.mrTargetBranch,
827
+ history: state.history.map((e) => e.projectId === state.selected?.id && e.branch === state.selectedBranch ? {
828
+ ...e,
829
+ mrUrl: action.mrUrl,
830
+ mrSourceBranch: action.mrSourceBranch,
831
+ mrTargetBranch: action.mrTargetBranch
832
+ } : e)
833
+ };
834
+ case "MR_ERROR": return {
835
+ ...state,
836
+ mrStatus: "error",
837
+ mrError: action.error
838
+ };
839
+ }
840
+ };
841
+ const cleanVersion = (v) => (v ?? "").split("-")[0];
842
+ const selKeyDown = (e, open, len, idx, onSelect, onClose) => {
843
+ if (!open || len === 0) return void 0;
844
+ switch (e.key) {
845
+ case "ArrowDown":
846
+ e.preventDefault();
847
+ return Math.min(idx + 1, len - 1);
848
+ case "ArrowUp":
849
+ e.preventDefault();
850
+ return Math.max(idx - 1, -1);
851
+ case "Enter":
852
+ e.preventDefault();
853
+ if (idx >= 0) onSelect(idx);
854
+ return;
855
+ case "Escape":
856
+ onClose();
857
+ return;
858
+ }
859
+ };
860
+ const pipelineStepClass = (done, active) => done ? "pipeline-step done" : active ? "pipeline-step active" : "pipeline-step";
861
+ const pipelineLineClass = (done) => done ? "pipeline-line done" : "pipeline-line";
862
+ const HistoryList = ({ s, d }) => {
863
+ const handleQuickExecute = async (id) => {
864
+ d({
865
+ type: "QUICK_EXEC_START",
866
+ id
867
+ });
868
+ try {
869
+ const data = await (await fetch(`/release/api/history/${id}/execute`, {
870
+ method: "POST",
871
+ headers: { "Content-Type": "application/json" },
872
+ body: JSON.stringify({ createMr: s.createMrChecked[id] ?? false })
873
+ })).json();
874
+ if (data.error) d({
875
+ type: "QUICK_EXEC_FAIL",
876
+ id,
877
+ error: data.error
878
+ });
879
+ else {
880
+ d({
881
+ type: "QUICK_EXEC_SUCCESS",
882
+ id,
883
+ result: data
884
+ });
885
+ d({
886
+ type: "SET_HISTORY",
887
+ history: await (await fetch("/release/api/history")).json()
888
+ });
889
+ }
890
+ } catch (e) {
891
+ d({
892
+ type: "QUICK_EXEC_FAIL",
893
+ id,
894
+ error: e instanceof Error ? e.message : String(e)
895
+ });
896
+ }
897
+ };
898
+ const handleClearHistory = async () => {
899
+ await fetch("/release/api/history", { method: "DELETE" });
900
+ d({ type: "CLEAR_HISTORY_DONE" });
901
+ };
902
+ return /* @__PURE__ */ jsxDEV("div", {
903
+ class: "history-section",
904
+ children: [
905
+ /* @__PURE__ */ jsxDEV("div", {
906
+ class: "history-title",
907
+ children: t("web.historyTitle")
908
+ }),
909
+ s.history.length > 0 ? /* @__PURE__ */ jsxDEV("div", {
910
+ class: "history-list",
911
+ children: s.history.map((entry) => /* @__PURE__ */ jsxDEV("div", {
912
+ class: "history-item",
913
+ children: [
914
+ /* @__PURE__ */ jsxDEV("div", {
915
+ class: "history-item-row",
916
+ children: [/* @__PURE__ */ jsxDEV("div", {
917
+ class: "history-info",
918
+ children: [
919
+ /* @__PURE__ */ jsxDEV("span", {
920
+ class: "history-project",
921
+ children: entry.projectName
922
+ }),
923
+ /* @__PURE__ */ jsxDEV("span", {
924
+ class: "history-detail",
925
+ children: [
926
+ entry.branch,
927
+ " / ",
928
+ entry.jiraProjectKey
929
+ ]
930
+ }),
931
+ entry.mrUrl && /* @__PURE__ */ jsxDEV("span", {
932
+ style: "font-size:12px;color:var(--text-3);margin-left:6px",
933
+ children: t("release.mrFromTo", {
934
+ source: entry.mrSourceBranch ?? "",
935
+ target: entry.mrTargetBranch ?? entry.branch
936
+ })
937
+ })
938
+ ]
939
+ }), /* @__PURE__ */ jsxDEV("div", {
940
+ class: "history-actions",
941
+ children: [entry.mrUrl && /* @__PURE__ */ jsxDEV("label", {
942
+ style: "display:flex;align-items:center;gap:4px;font-size:12px;color:var(--text-3);cursor:pointer",
943
+ children: [/* @__PURE__ */ jsxDEV("input", {
944
+ type: "checkbox",
945
+ checked: s.createMrChecked[entry.id] ?? false,
946
+ onChange: () => d({
947
+ type: "TOGGLE_CREATE_MR",
948
+ id: entry.id
949
+ })
950
+ }), t("web.createMrCheckbox")]
951
+ }), /* @__PURE__ */ jsxDEV("button", {
952
+ class: `history-quick-btn${s.quickExecuting === entry.id ? " executing" : ""}`,
953
+ type: "button",
954
+ disabled: s.quickExecuting !== null,
955
+ onClick: () => handleQuickExecute(entry.id),
956
+ children: s.quickExecuting === entry.id ? t("web.executing") : t("web.quickExecute")
957
+ })]
958
+ })]
959
+ }),
960
+ s.quickResults[entry.id] && /* @__PURE__ */ jsxDEV("div", {
961
+ class: "history-result",
962
+ children: [
963
+ /* @__PURE__ */ jsxDEV("a", {
964
+ class: "history-result-key",
965
+ href: s.quickResults[entry.id].issueUrl,
966
+ target: "_blank",
967
+ rel: "noreferrer",
968
+ children: s.quickResults[entry.id].issueKey
969
+ }),
970
+ /* @__PURE__ */ jsxDEV("span", {
971
+ class: `jira-result-badge ${s.quickResults[entry.id].issueCreated ? "created" : "exists"}`,
972
+ children: s.quickResults[entry.id].issueCreated ? t("web.createdBadge") : t("web.existsBadge")
973
+ }),
974
+ /* @__PURE__ */ jsxDEV("span", {
975
+ style: "font-size:12px;color:var(--text-3);margin-left:8px",
976
+ children: ["v", s.quickResults[entry.id].version]
977
+ }),
978
+ s.quickResults[entry.id].versionCreated && /* @__PURE__ */ jsxDEV("span", {
979
+ style: "font-size:10px;color:var(--neon);margin-left:4px",
980
+ children: t("web.createdBadge")
981
+ }),
982
+ s.quickResults[entry.id].mrUrl && /* @__PURE__ */ jsxDEV("span", {
983
+ style: "font-size:12px;margin-left:12px",
984
+ children: /* @__PURE__ */ jsxDEV("a", {
985
+ href: s.quickResults[entry.id].mrUrl,
986
+ target: "_blank",
987
+ rel: "noreferrer",
988
+ style: "color:var(--cyan);text-decoration:none;border-bottom:1px dashed var(--cyan)",
989
+ children: t("release.mrFromTo", {
990
+ source: s.quickResults[entry.id].mrSourceBranch ?? "",
991
+ target: s.quickResults[entry.id].mrTargetBranch ?? entry.branch
992
+ })
993
+ })
994
+ })
995
+ ]
996
+ }),
997
+ s.quickErrors[entry.id] && /* @__PURE__ */ jsxDEV("div", {
998
+ class: "history-result-error",
999
+ children: s.quickErrors[entry.id]
1000
+ })
1001
+ ]
1002
+ }))
1003
+ }) : /* @__PURE__ */ jsxDEV("div", {
1004
+ class: "empty-hint",
1005
+ children: t("web.noHistory")
1006
+ }),
1007
+ /* @__PURE__ */ jsxDEV("div", {
1008
+ class: "history-footer",
1009
+ children: [/* @__PURE__ */ jsxDEV("button", {
1010
+ class: "history-new-btn",
1011
+ type: "button",
1012
+ onClick: () => d({ type: "SHOW_NEW_MODAL" }),
1013
+ children: t("web.createNew")
1014
+ }), s.history.length > 0 && (s.clearConfirm ? /* @__PURE__ */ jsxDEV("div", {
1015
+ style: "display:flex;align-items:center;gap:8px",
1016
+ children: [
1017
+ /* @__PURE__ */ jsxDEV("span", {
1018
+ style: "font-size:12px;color:var(--text-3)",
1019
+ children: t("web.clearConfirm")
1020
+ }),
1021
+ /* @__PURE__ */ jsxDEV("button", {
1022
+ class: "history-clear-btn",
1023
+ type: "button",
1024
+ style: "border-color:var(--error);color:var(--error)",
1025
+ onClick: handleClearHistory,
1026
+ children: t("web.clearHistory")
1027
+ }),
1028
+ /* @__PURE__ */ jsxDEV("button", {
1029
+ class: "history-clear-btn",
1030
+ type: "button",
1031
+ onClick: () => d({ type: "CLEAR_CONFIRM_TOGGLE" }),
1032
+ children: t("web.cancel")
1033
+ })
1034
+ ]
1035
+ }) : /* @__PURE__ */ jsxDEV("button", {
1036
+ class: "history-clear-btn",
1037
+ type: "button",
1038
+ onClick: () => d({ type: "CLEAR_CONFIRM_TOGGLE" }),
1039
+ children: t("web.clearHistory")
1040
+ }))]
1041
+ })
1042
+ ]
1043
+ });
1044
+ };
1045
+ const ReleaseFlow = ({ s, d }) => {
1046
+ const projectSearchRef = useRef(null);
1047
+ const branchSearchRef = useRef(null);
1048
+ const jiraSearchRef = useRef(null);
1049
+ const mrBranchSearchRef = useRef(null);
1050
+ useEffect(() => {
1051
+ fetch("/release/api/config").then((r) => r.json()).then((data) => {
1052
+ if (data.jiraHost) d({
1053
+ type: "SET_JIRA_HOST",
1054
+ host: data.jiraHost
1055
+ });
1056
+ }).catch(() => {});
1057
+ }, []);
1058
+ useEffect(() => {
1059
+ fetch("/release/api/projects").then((r) => r.json()).then((data) => {
1060
+ if (data.error) d({
1061
+ type: "PROJECTS_ERROR",
1062
+ error: data.error
1063
+ });
1064
+ else d({
1065
+ type: "PROJECTS_LOADED",
1066
+ projects: data
1067
+ });
1068
+ }).catch((e) => d({
1069
+ type: "PROJECTS_ERROR",
1070
+ error: e.message
1071
+ }));
1072
+ }, []);
1073
+ useEffect(() => {
1074
+ if (!s.projectOpen && !s.branchOpen && !s.jiraProjectOpen && !s.mrBranchOpen) return;
1075
+ const handler = (e) => {
1076
+ const target = e.target;
1077
+ if (!target.closest(".sel") && !target.closest(".mr-branch-sel")) {
1078
+ d({
1079
+ type: "SET_PROJECT_OPEN",
1080
+ open: false
1081
+ });
1082
+ d({
1083
+ type: "SET_BRANCH_OPEN",
1084
+ open: false
1085
+ });
1086
+ d({
1087
+ type: "SET_MR_BRANCH_OPEN",
1088
+ open: false
1089
+ });
1090
+ d({
1091
+ type: "SET_JIRA_PROJECT_OPEN",
1092
+ open: false
1093
+ });
1094
+ }
1095
+ };
1096
+ document.addEventListener("click", handler);
1097
+ return () => document.removeEventListener("click", handler);
1098
+ }, [
1099
+ s.projectOpen,
1100
+ s.branchOpen,
1101
+ s.jiraProjectOpen
1102
+ ]);
1103
+ useEffect(() => {
1104
+ if (s.projectOpen) setTimeout(() => projectSearchRef.current?.focus(), 50);
1105
+ if (s.branchOpen) setTimeout(() => branchSearchRef.current?.focus(), 50);
1106
+ if (s.jiraProjectOpen) setTimeout(() => jiraSearchRef.current?.focus(), 50);
1107
+ if (s.mrBranchOpen) setTimeout(() => mrBranchSearchRef.current?.focus(), 50);
1108
+ }, [
1109
+ s.projectOpen,
1110
+ s.branchOpen,
1111
+ s.jiraProjectOpen,
1112
+ s.mrBranchOpen
1113
+ ]);
1114
+ useEffect(() => {
1115
+ if (s.mrStatus !== "creating" || !s.mrSourceBranch || !s.selected) return;
1116
+ const jiraUrl2 = s.jiraResult && s.jiraHost ? `${s.jiraHost}/browse/${s.jiraResult.key}` : "";
1117
+ fetch("/release/api/create-mr", {
1118
+ method: "POST",
1119
+ headers: { "Content-Type": "application/json" },
1120
+ body: JSON.stringify({
1121
+ projectId: s.selected.id,
1122
+ targetBranch: s.selectedBranch,
1123
+ sourceBranch: s.mrSourceBranch,
1124
+ jiraUrl: jiraUrl2
1125
+ })
1126
+ }).then((r) => r.json()).then((data) => {
1127
+ if (data.mrUrl) {
1128
+ d({
1129
+ type: "MR_DONE",
1130
+ mrUrl: data.mrUrl,
1131
+ mrSourceBranch: data.sourceBranch,
1132
+ mrTargetBranch: data.targetBranch
1133
+ });
1134
+ fetch("/release/api/history").then((r) => r.json()).then((h) => d({
1135
+ type: "HISTORY_LOADED",
1136
+ history: h
1137
+ }));
1138
+ } else d({
1139
+ type: "MR_ERROR",
1140
+ error: data.error ?? "Failed"
1141
+ });
1142
+ }).catch((e) => d({
1143
+ type: "MR_ERROR",
1144
+ error: e instanceof Error ? e.message : "Failed"
1145
+ }));
1146
+ }, [s.mrStatus, s.mrSourceBranch]);
1147
+ useEffect(() => {
1148
+ if (!s.pomInfo?.version || s.jiraProjects.length > 0 || s.jiraProjectsLoading) return;
1149
+ d({ type: "JIRA_PROJECTS_LOADING" });
1150
+ fetch("/release/api/jira/projects").then((r) => r.json()).then((data) => {
1151
+ if (Array.isArray(data)) d({
1152
+ type: "JIRA_PROJECTS_LOADED",
1153
+ projects: data
1154
+ });
1155
+ else d({
1156
+ type: "JIRA_PROJECTS_ERROR",
1157
+ error: data.error ?? "Failed"
1158
+ });
1159
+ }).catch(() => d({
1160
+ type: "JIRA_PROJECTS_ERROR",
1161
+ error: "Failed"
1162
+ }));
1163
+ }, [s.pomInfo?.version]);
1164
+ const fetchPom = (projectId, ref) => {
1165
+ d({ type: "POM_LOADING" });
1166
+ fetch(`/release/api/projects/${projectId}/pom-version?ref=${encodeURIComponent(ref)}`).then((r) => r.json()).then((data) => {
1167
+ if (data.error) d({
1168
+ type: "POM_ERROR",
1169
+ error: data.error
1170
+ });
1171
+ else d({
1172
+ type: "POM_LOADED",
1173
+ info: data
1174
+ });
1175
+ }).catch(() => d({
1176
+ type: "POM_ERROR",
1177
+ error: "Failed to fetch version"
1178
+ }));
1179
+ };
1180
+ const handleSelectProject = (project) => {
1181
+ d({
1182
+ type: "SELECT_PROJECT",
1183
+ project
1184
+ });
1185
+ d({ type: "BRANCHES_LOADING" });
1186
+ fetch(`/release/api/projects/${project.id}/branches`).then((r) => r.json()).then((data) => {
1187
+ d({
1188
+ type: "BRANCHES_LOADED",
1189
+ branches: "error" in data ? [] : data
1190
+ });
1191
+ }).catch(() => d({
1192
+ type: "BRANCHES_LOADED",
1193
+ branches: []
1194
+ }));
1195
+ };
1196
+ const handleSelectBranch = (name) => {
1197
+ d({
1198
+ type: "SELECT_BRANCH",
1199
+ branch: name
1200
+ });
1201
+ if (s.selected) fetchPom(s.selected.id, name);
1202
+ };
1203
+ const handleCreateIssue = async () => {
1204
+ if (!s.selected || !s.pomInfo?.version || !s.selectedJiraProject) return;
1205
+ const artifactId = s.pomInfo.artifactId ?? s.selected.name;
1206
+ const projectVersion = cleanVersion(s.pomInfo.version);
1207
+ const versionName = `${artifactId}-${projectVersion}`;
1208
+ const summary = `${artifactId}-${projectVersion} ${t("web.releaseSuffix") ?? t("release.releaseSuffix")}`;
1209
+ d({ type: "JIRA_CHECKING" });
1210
+ try {
1211
+ const searchData = await (await fetch("/release/api/jira/search", {
1212
+ method: "POST",
1213
+ headers: { "Content-Type": "application/json" },
1214
+ body: JSON.stringify({
1215
+ jql: `summary ~ "${summary}" AND project = ${s.selectedJiraProject.key}`,
1216
+ maxResults: 1
1217
+ })
1218
+ })).json();
1219
+ if (searchData.error) {
1220
+ d({
1221
+ type: "JIRA_ERROR",
1222
+ error: searchData.error
1223
+ });
1224
+ return;
1225
+ }
1226
+ if (searchData.total > 0 && searchData.issues?.[0]) {
1227
+ d({
1228
+ type: "JIRA_DONE",
1229
+ result: {
1230
+ key: searchData.issues[0].key,
1231
+ exists: true,
1232
+ versionName
1233
+ }
1234
+ });
1235
+ await fetch("/release/api/history", {
1236
+ method: "POST",
1237
+ headers: { "Content-Type": "application/json" },
1238
+ body: JSON.stringify({
1239
+ id: Date.now().toString(36),
1240
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1241
+ projectId: s.selected.id,
1242
+ projectName: s.selected.name,
1243
+ projectPath: s.selected.pathWithNamespace ?? "",
1244
+ branch: s.selectedBranch,
1245
+ jiraProjectKey: s.selectedJiraProject.key
1246
+ })
1247
+ });
1248
+ return;
1249
+ }
1250
+ d({ type: "JIRA_CREATING" });
1251
+ const verData = await (await fetch("/release/api/jira/ensure-version", {
1252
+ method: "POST",
1253
+ headers: { "Content-Type": "application/json" },
1254
+ body: JSON.stringify({
1255
+ projectKey: s.selectedJiraProject.key,
1256
+ versionName
1257
+ })
1258
+ })).json();
1259
+ if (verData.error) {
1260
+ d({
1261
+ type: "JIRA_ERROR",
1262
+ error: verData.error
1263
+ });
1264
+ return;
1265
+ }
1266
+ const issueData = await (await fetch("/release/api/jira/create-issue", {
1267
+ method: "POST",
1268
+ headers: { "Content-Type": "application/json" },
1269
+ body: JSON.stringify({
1270
+ projectKey: s.selectedJiraProject.key,
1271
+ summary,
1272
+ issuetypeId: "10000",
1273
+ customfield_15800: "无",
1274
+ customfield_13410: [{ id: verData.id }],
1275
+ customfield_13341: [{ name: "licheng.li" }]
1276
+ })
1277
+ })).json();
1278
+ if (issueData.error) {
1279
+ d({
1280
+ type: "JIRA_ERROR",
1281
+ error: issueData.error
1282
+ });
1283
+ return;
1284
+ }
1285
+ d({
1286
+ type: "JIRA_DONE",
1287
+ result: {
1288
+ key: issueData.key,
1289
+ exists: false,
1290
+ versionName: verData.name
1291
+ }
1292
+ });
1293
+ await fetch("/release/api/history", {
1294
+ method: "POST",
1295
+ headers: { "Content-Type": "application/json" },
1296
+ body: JSON.stringify({
1297
+ id: Date.now().toString(36),
1298
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1299
+ projectId: s.selected.id,
1300
+ projectName: s.selected.name,
1301
+ projectPath: s.selected.pathWithNamespace ?? "",
1302
+ branch: s.selectedBranch,
1303
+ jiraProjectKey: s.selectedJiraProject.key
1304
+ })
1305
+ });
1306
+ } catch (e) {
1307
+ d({
1308
+ type: "JIRA_ERROR",
1309
+ error: e instanceof Error ? e.message : String(e)
1310
+ });
1311
+ }
1312
+ };
1313
+ const fp = filterByRelevance(s.projects.map((p) => ({
1314
+ ...p,
1315
+ name: p.name,
1316
+ path: p.pathWithNamespace ?? ""
1317
+ })), s.projectSearch);
1318
+ const fb = filterByRelevance(s.branches.map((b) => ({
1319
+ ...b,
1320
+ name: b.name
1321
+ })), s.branchSearch);
1322
+ const fj = filterByRelevance(s.jiraProjects.map((p) => ({
1323
+ ...p,
1324
+ name: `${p.key} ${p.name ?? ""}`
1325
+ })), s.jiraProjectSearch);
1326
+ const jiraUrl = s.jiraResult && s.jiraHost ? `${s.jiraHost}/browse/${s.jiraResult.key}` : "";
1327
+ const step1Done = !!s.selected;
1328
+ const step1Active = !s.projectsLoading && !step1Done;
1329
+ const step2Done = !!s.selectedBranch;
1330
+ const step2Active = !!s.selected && !step2Done;
1331
+ const step3Done = !!s.pomInfo?.version;
1332
+ const step3Active = !!s.selectedBranch && !step3Done;
1333
+ const step4Done = !!s.selectedJiraProject;
1334
+ const step4Active = !!s.pomInfo?.version && !step4Done;
1335
+ const step5Done = !!s.jiraResult;
1336
+ const step5Active = !!s.selectedJiraProject && !step5Done;
1337
+ if (s.projectsLoading) return /* @__PURE__ */ jsxDEV("div", {
1338
+ class: "loading-row",
1339
+ children: [/* @__PURE__ */ jsxDEV("span", { class: "spinner" }), t("web.loadingProjects")]
1340
+ });
1341
+ if (s.projectsError) return /* @__PURE__ */ jsxDEV("div", {
1342
+ class: "state-error",
1343
+ children: s.projectsError
1344
+ });
1345
+ return /* @__PURE__ */ jsxDEV("div", { children: [
1346
+ /* @__PURE__ */ jsxDEV("div", {
1347
+ class: "pipeline",
1348
+ children: [
1349
+ /* @__PURE__ */ jsxDEV("div", {
1350
+ class: pipelineStepClass(step1Done, step1Active),
1351
+ children: [/* @__PURE__ */ jsxDEV("span", { class: "pipeline-node" }), t("web.projectLabel")]
1352
+ }),
1353
+ /* @__PURE__ */ jsxDEV("div", { class: pipelineLineClass(step1Done) }),
1354
+ /* @__PURE__ */ jsxDEV("div", {
1355
+ class: pipelineStepClass(step2Done, step2Active),
1356
+ children: [/* @__PURE__ */ jsxDEV("span", { class: "pipeline-node" }), t("web.branchLabel")]
1357
+ }),
1358
+ /* @__PURE__ */ jsxDEV("div", { class: pipelineLineClass(step2Done) }),
1359
+ /* @__PURE__ */ jsxDEV("div", {
1360
+ class: pipelineStepClass(step3Done, step3Active),
1361
+ children: [/* @__PURE__ */ jsxDEV("span", { class: "pipeline-node" }), t("web.versionTag")]
1362
+ }),
1363
+ /* @__PURE__ */ jsxDEV("div", { class: pipelineLineClass(step3Done) }),
1364
+ /* @__PURE__ */ jsxDEV("div", {
1365
+ class: pipelineStepClass(step4Done, step4Active),
1366
+ children: [/* @__PURE__ */ jsxDEV("span", { class: "pipeline-node" }), t("web.jiraProjectLabel")]
1367
+ }),
1368
+ /* @__PURE__ */ jsxDEV("div", { class: pipelineLineClass(step4Done) }),
1369
+ /* @__PURE__ */ jsxDEV("div", {
1370
+ class: pipelineStepClass(step5Done, step5Active),
1371
+ children: [/* @__PURE__ */ jsxDEV("span", { class: "pipeline-node" }), t("web.createBtn")]
1372
+ })
1373
+ ]
1374
+ }),
1375
+ /* @__PURE__ */ jsxDEV("div", {
1376
+ class: "sel",
1377
+ "data-sel": "project",
1378
+ style: `z-index:${s.projectOpen ? 100 : 1}`,
1379
+ children: [/* @__PURE__ */ jsxDEV("button", {
1380
+ class: `sel-trigger${s.projectOpen ? " open" : ""}`,
1381
+ type: "button",
1382
+ role: "combobox",
1383
+ "aria-expanded": s.projectOpen,
1384
+ "aria-haspopup": "listbox",
1385
+ onClick: () => {
1386
+ d({
1387
+ type: "SET_BRANCH_OPEN",
1388
+ open: false
1389
+ });
1390
+ d({
1391
+ type: "SET_JIRA_PROJECT_OPEN",
1392
+ open: false
1393
+ });
1394
+ d({
1395
+ type: "SET_MR_BRANCH_OPEN",
1396
+ open: false
1397
+ });
1398
+ d({
1399
+ type: "SET_PROJECT_OPEN",
1400
+ open: !s.projectOpen
1401
+ });
1402
+ },
1403
+ children: [
1404
+ /* @__PURE__ */ jsxDEV("span", {
1405
+ class: "sel-trigger-label",
1406
+ children: t("web.projectLabel")
1407
+ }),
1408
+ /* @__PURE__ */ jsxDEV("span", {
1409
+ class: `sel-trigger-value${s.selected ? "" : " empty"}`,
1410
+ children: s.selected ? s.selected.name : t("web.selectProject")
1411
+ }),
1412
+ /* @__PURE__ */ jsxDEV("span", {
1413
+ class: "sel-trigger-arrow",
1414
+ children: "▼"
1415
+ })
1416
+ ]
1417
+ }), s.projectOpen && /* @__PURE__ */ jsxDEV("div", {
1418
+ class: "sel-dropdown",
1419
+ role: "listbox",
1420
+ "aria-label": t("web.selectProject"),
1421
+ children: [/* @__PURE__ */ jsxDEV("div", {
1422
+ class: "sel-search",
1423
+ children: /* @__PURE__ */ jsxDEV("input", {
1424
+ ref: projectSearchRef,
1425
+ class: "sel-search-input",
1426
+ type: "text",
1427
+ placeholder: t("web.searchProjects"),
1428
+ value: s.projectSearch,
1429
+ onChange: (e) => d({
1430
+ type: "SET_PROJECT_SEARCH",
1431
+ search: e.target.value
1432
+ }),
1433
+ onKeyDown: (e) => {
1434
+ const n = selKeyDown(e, s.projectOpen, fp.length, s.projectIndex, (i) => {
1435
+ const p = fp[i];
1436
+ if (p) handleSelectProject(p);
1437
+ }, () => d({
1438
+ type: "SET_PROJECT_OPEN",
1439
+ open: false
1440
+ }));
1441
+ if (n !== void 0) d({
1442
+ type: "SET_PROJECT_INDEX",
1443
+ index: n
1444
+ });
1445
+ }
1446
+ })
1447
+ }), fp.length > 0 ? fp.map((p, i) => /* @__PURE__ */ jsxDEV("div", {
1448
+ class: `sel-item${s.selected?.id === p.id ? " active" : ""}${i === s.projectIndex ? " highlighted" : ""}`,
1449
+ onMouseEnter: () => d({
1450
+ type: "SET_PROJECT_INDEX",
1451
+ index: i
1452
+ }),
1453
+ onClick: () => handleSelectProject(p),
1454
+ children: [/* @__PURE__ */ jsxDEV("div", {
1455
+ class: "sel-item-name",
1456
+ children: p.name
1457
+ }), /* @__PURE__ */ jsxDEV("div", {
1458
+ class: "sel-item-sub",
1459
+ children: p.pathWithNamespace
1460
+ })]
1461
+ })) : /* @__PURE__ */ jsxDEV("div", {
1462
+ class: "sel-empty",
1463
+ children: t("web.noProjects")
1464
+ })]
1465
+ })]
1466
+ }),
1467
+ s.selected && (s.branchesLoading ? /* @__PURE__ */ jsxDEV("div", {
1468
+ class: "loading-row",
1469
+ children: [/* @__PURE__ */ jsxDEV("span", { class: "spinner" }), t("web.loadingBranches")]
1470
+ }) : s.branches.length > 0 && /* @__PURE__ */ jsxDEV("div", {
1471
+ class: "sel",
1472
+ "data-sel": "branch",
1473
+ style: `z-index:${s.branchOpen ? 100 : 1}`,
1474
+ children: [/* @__PURE__ */ jsxDEV("button", {
1475
+ class: `sel-trigger${s.branchOpen ? " open" : ""}`,
1476
+ type: "button",
1477
+ role: "combobox",
1478
+ "aria-expanded": s.branchOpen,
1479
+ "aria-haspopup": "listbox",
1480
+ onClick: () => {
1481
+ d({
1482
+ type: "SET_PROJECT_OPEN",
1483
+ open: false
1484
+ });
1485
+ d({
1486
+ type: "SET_JIRA_PROJECT_OPEN",
1487
+ open: false
1488
+ });
1489
+ d({
1490
+ type: "SET_MR_BRANCH_OPEN",
1491
+ open: false
1492
+ });
1493
+ d({
1494
+ type: "SET_BRANCH_OPEN",
1495
+ open: !s.branchOpen
1496
+ });
1497
+ },
1498
+ children: [
1499
+ /* @__PURE__ */ jsxDEV("span", {
1500
+ class: "sel-trigger-label",
1501
+ children: t("web.branchLabel")
1502
+ }),
1503
+ /* @__PURE__ */ jsxDEV("span", {
1504
+ class: `sel-trigger-value${s.selectedBranch ? "" : " empty"}`,
1505
+ children: s.selectedBranch || t("web.selectBranch")
1506
+ }),
1507
+ /* @__PURE__ */ jsxDEV("span", {
1508
+ class: "sel-trigger-arrow",
1509
+ children: "▼"
1510
+ })
1511
+ ]
1512
+ }), s.branchOpen && /* @__PURE__ */ jsxDEV("div", {
1513
+ class: "sel-dropdown",
1514
+ role: "listbox",
1515
+ "aria-label": t("web.selectBranch"),
1516
+ children: [/* @__PURE__ */ jsxDEV("div", {
1517
+ class: "sel-search",
1518
+ children: /* @__PURE__ */ jsxDEV("input", {
1519
+ ref: branchSearchRef,
1520
+ class: "sel-search-input",
1521
+ type: "text",
1522
+ placeholder: t("web.filterBranches"),
1523
+ value: s.branchSearch,
1524
+ onChange: (e) => d({
1525
+ type: "SET_BRANCH_SEARCH",
1526
+ search: e.target.value
1527
+ }),
1528
+ onKeyDown: (e) => {
1529
+ const n = selKeyDown(e, s.branchOpen, fb.length, s.branchIndex, (i) => {
1530
+ const b = fb[i];
1531
+ if (b) handleSelectBranch(b.name);
1532
+ }, () => d({
1533
+ type: "SET_BRANCH_OPEN",
1534
+ open: false
1535
+ }));
1536
+ if (n !== void 0) d({
1537
+ type: "SET_BRANCH_INDEX",
1538
+ index: n
1539
+ });
1540
+ }
1541
+ })
1542
+ }), fb.length > 0 ? fb.map((b, i) => /* @__PURE__ */ jsxDEV("div", {
1543
+ class: `sel-item${b.name === s.selectedBranch ? " active" : ""}${i === s.branchIndex ? " highlighted" : ""}`,
1544
+ onMouseEnter: () => d({
1545
+ type: "SET_BRANCH_INDEX",
1546
+ index: i
1547
+ }),
1548
+ onClick: () => handleSelectBranch(b.name),
1549
+ children: [/* @__PURE__ */ jsxDEV("span", {
1550
+ class: "sel-item-name",
1551
+ children: b.name
1552
+ }), b.default && /* @__PURE__ */ jsxDEV("span", {
1553
+ style: "font-size:10px;color:var(--neon);margin-left:6px",
1554
+ children: t("web.defaultBranch")
1555
+ })]
1556
+ })) : /* @__PURE__ */ jsxDEV("div", {
1557
+ class: "sel-empty",
1558
+ children: t("web.noBranches")
1559
+ })]
1560
+ })]
1561
+ })),
1562
+ s.selected && s.selectedBranch && !s.branchesLoading && (s.pomLoading ? /* @__PURE__ */ jsxDEV("div", {
1563
+ class: "loading-row",
1564
+ children: [/* @__PURE__ */ jsxDEV("span", { class: "spinner" }), t("web.loadingVersion")]
1565
+ }) : s.pomError ? /* @__PURE__ */ jsxDEV("div", {
1566
+ class: "version-error",
1567
+ role: "alert",
1568
+ children: s.pomError.includes("404") ? t("web.noPom") : s.pomError
1569
+ }) : s.pomInfo && /* @__PURE__ */ jsxDEV("div", {
1570
+ class: "version-display",
1571
+ children: [/* @__PURE__ */ jsxDEV("span", {
1572
+ class: "version-tag",
1573
+ children: t("web.versionTag")
1574
+ }), /* @__PURE__ */ jsxDEV("span", {
1575
+ class: "version-number",
1576
+ children: cleanVersion(s.pomInfo.version)
1577
+ })]
1578
+ })),
1579
+ s.selected && s.pomInfo?.version && !s.pomLoading && /* @__PURE__ */ jsxDEV("div", {
1580
+ class: "jira-section",
1581
+ children: [
1582
+ s.jiraProjectsLoading ? /* @__PURE__ */ jsxDEV("div", {
1583
+ class: "loading-row",
1584
+ children: [/* @__PURE__ */ jsxDEV("span", { class: "spinner" }), t("web.loadingJiraProjects")]
1585
+ }) : /* @__PURE__ */ jsxDEV("div", {
1586
+ class: "sel",
1587
+ "data-sel": "jira",
1588
+ style: `z-index:${s.jiraProjectOpen ? 100 : 1}`,
1589
+ children: [/* @__PURE__ */ jsxDEV("button", {
1590
+ class: `sel-trigger${s.jiraProjectOpen ? " open" : ""}`,
1591
+ type: "button",
1592
+ role: "combobox",
1593
+ "aria-expanded": s.jiraProjectOpen,
1594
+ "aria-haspopup": "listbox",
1595
+ onClick: () => {
1596
+ d({
1597
+ type: "SET_PROJECT_OPEN",
1598
+ open: false
1599
+ });
1600
+ d({
1601
+ type: "SET_BRANCH_OPEN",
1602
+ open: false
1603
+ });
1604
+ d({
1605
+ type: "SET_JIRA_PROJECT_OPEN",
1606
+ open: !s.jiraProjectOpen
1607
+ });
1608
+ },
1609
+ children: [
1610
+ /* @__PURE__ */ jsxDEV("span", {
1611
+ class: "sel-trigger-label",
1612
+ children: t("web.jiraProjectLabel")
1613
+ }),
1614
+ /* @__PURE__ */ jsxDEV("span", {
1615
+ class: `sel-trigger-value${s.selectedJiraProject ? "" : " empty"}`,
1616
+ children: s.selectedJiraProject ? `${s.selectedJiraProject.key} - ${s.selectedJiraProject.name ?? ""}` : t("web.selectJiraProject")
1617
+ }),
1618
+ /* @__PURE__ */ jsxDEV("span", {
1619
+ class: "sel-trigger-arrow",
1620
+ children: "▼"
1621
+ })
1622
+ ]
1623
+ }), s.jiraProjectOpen && /* @__PURE__ */ jsxDEV("div", {
1624
+ class: "sel-dropdown",
1625
+ role: "listbox",
1626
+ "aria-label": t("web.selectJiraProject"),
1627
+ children: [/* @__PURE__ */ jsxDEV("div", {
1628
+ class: "sel-search",
1629
+ children: /* @__PURE__ */ jsxDEV("input", {
1630
+ ref: jiraSearchRef,
1631
+ class: "sel-search-input",
1632
+ type: "text",
1633
+ placeholder: t("web.searchJiraProject"),
1634
+ value: s.jiraProjectSearch,
1635
+ onChange: (e) => d({
1636
+ type: "SET_JIRA_PROJECT_SEARCH",
1637
+ search: e.target.value
1638
+ }),
1639
+ onKeyDown: (e) => {
1640
+ const n = selKeyDown(e, s.jiraProjectOpen, fj.length, s.jiraProjectIndex, (i) => {
1641
+ const p = fj[i];
1642
+ if (p) d({
1643
+ type: "SELECT_JIRA_PROJECT",
1644
+ project: p
1645
+ });
1646
+ }, () => d({
1647
+ type: "SET_JIRA_PROJECT_OPEN",
1648
+ open: false
1649
+ }));
1650
+ if (n !== void 0) d({
1651
+ type: "SET_JIRA_PROJECT_INDEX",
1652
+ index: n
1653
+ });
1654
+ }
1655
+ })
1656
+ }), fj.length > 0 ? fj.map((p, i) => /* @__PURE__ */ jsxDEV("div", {
1657
+ class: `sel-item${s.selectedJiraProject?.key === p.key ? " active" : ""}${i === s.jiraProjectIndex ? " highlighted" : ""}`,
1658
+ onMouseEnter: () => d({
1659
+ type: "SET_JIRA_PROJECT_INDEX",
1660
+ index: i
1661
+ }),
1662
+ onClick: () => d({
1663
+ type: "SELECT_JIRA_PROJECT",
1664
+ project: p
1665
+ }),
1666
+ children: [/* @__PURE__ */ jsxDEV("span", {
1667
+ class: "sel-item-name",
1668
+ children: p.key
1669
+ }), p.name && /* @__PURE__ */ jsxDEV("div", {
1670
+ class: "sel-item-sub",
1671
+ children: p.name
1672
+ })]
1673
+ })) : /* @__PURE__ */ jsxDEV("div", {
1674
+ class: "sel-empty",
1675
+ children: t("web.noJiraProjects")
1676
+ })]
1677
+ })]
1678
+ }),
1679
+ /* @__PURE__ */ jsxDEV("button", {
1680
+ class: "jira-btn",
1681
+ type: "button",
1682
+ disabled: !s.selectedJiraProject || s.jiraStatus === "checking" || s.jiraStatus === "creating",
1683
+ onClick: handleCreateIssue,
1684
+ children: s.jiraStatus === "checking" ? t("web.checkingBtn") : s.jiraStatus === "creating" ? t("web.creatingBtn") : t("web.createBtn")
1685
+ }),
1686
+ (s.jiraStatus === "checking" || s.jiraStatus === "creating") && /* @__PURE__ */ jsxDEV("div", {
1687
+ class: "loading-row",
1688
+ style: "margin-top:12px",
1689
+ children: [/* @__PURE__ */ jsxDEV("span", { class: "spinner" }), s.jiraStatus === "checking" ? t("web.checkingIssues") : t("web.creatingIssue")]
1690
+ }),
1691
+ s.jiraResult && /* @__PURE__ */ jsxDEV("div", {
1692
+ class: "jira-result",
1693
+ children: [
1694
+ /* @__PURE__ */ jsxDEV("div", {
1695
+ class: "jira-result-label",
1696
+ children: s.jiraResult.exists ? t("web.versionExistsResult", { version: s.jiraResult.versionName }) : t("web.versionCreatedResult", { version: s.jiraResult.versionName })
1697
+ }),
1698
+ /* @__PURE__ */ jsxDEV("a", {
1699
+ class: "jira-result-key",
1700
+ href: jiraUrl,
1701
+ target: "_blank",
1702
+ rel: "noreferrer",
1703
+ children: s.jiraResult.key
1704
+ }),
1705
+ /* @__PURE__ */ jsxDEV("span", {
1706
+ class: `jira-result-badge ${s.jiraResult.exists ? "exists" : "created"}`,
1707
+ children: s.jiraResult.exists ? t("web.existsBadge") : t("web.createdBadge")
1708
+ })
1709
+ ]
1710
+ }),
1711
+ s.jiraError && /* @__PURE__ */ jsxDEV("div", {
1712
+ class: "jira-error",
1713
+ role: "alert",
1714
+ children: s.jiraError
1715
+ }),
1716
+ s.jiraResult && (s.mrStatus === "idle" || s.mrStatus === "loading") && /* @__PURE__ */ jsxDEV("button", {
1717
+ class: "jira-btn",
1718
+ type: "button",
1719
+ disabled: s.mrStatus === "loading",
1720
+ style: "background:var(--cyan);margin-top:12px",
1721
+ onClick: async () => {
1722
+ if (s.mrStatus === "loading") return;
1723
+ d({ type: "MR_LOADING" });
1724
+ try {
1725
+ const data = await (await fetch(`/release/api/projects/${s.selected.id}/branches`)).json();
1726
+ const branches = (Array.isArray(data) ? data : []).filter((b) => b.name !== s.selectedBranch);
1727
+ if (branches.length === 0) {
1728
+ d({
1729
+ type: "MR_ERROR",
1730
+ error: t("release.noSourceBranches")
1731
+ });
1732
+ return;
1733
+ }
1734
+ d({
1735
+ type: "MR_SELECTING",
1736
+ branches
1737
+ });
1738
+ } catch (e) {
1739
+ d({
1740
+ type: "MR_ERROR",
1741
+ error: e instanceof Error ? e.message : "Failed"
1742
+ });
1743
+ }
1744
+ },
1745
+ children: s.mrStatus === "loading" ? /* @__PURE__ */ jsxDEV(Fragment, { children: [/* @__PURE__ */ jsxDEV("span", {
1746
+ class: "spinner",
1747
+ style: "width:12px;height:12px;border-width:1px;margin-right:6px;vertical-align:middle"
1748
+ }), t("web.loadingMr")] }) : t("web.createMrBtn")
1749
+ }),
1750
+ s.mrStatus === "selecting" && (() => {
1751
+ const mrb = s.mrBranches.filter((b) => b.name.toLowerCase().includes(s.mrBranchSearch.toLowerCase()));
1752
+ return /* @__PURE__ */ jsxDEV("div", {
1753
+ class: "mr-branch-sel",
1754
+ style: "margin-top:12px",
1755
+ children: [/* @__PURE__ */ jsxDEV("div", {
1756
+ style: "font-size:13px;color:var(--text-2);margin-bottom:4px",
1757
+ children: t("release.selectMrBranch")
1758
+ }), /* @__PURE__ */ jsxDEV("div", {
1759
+ class: "sel",
1760
+ style: "position:relative;z-index:100",
1761
+ children: [/* @__PURE__ */ jsxDEV("button", {
1762
+ type: "button",
1763
+ class: "sel-trigger",
1764
+ onClick: () => d({
1765
+ type: "SET_MR_BRANCH_OPEN",
1766
+ open: !s.mrBranchOpen
1767
+ }),
1768
+ children: [
1769
+ /* @__PURE__ */ jsxDEV("span", {
1770
+ class: "sel-trigger-label",
1771
+ children: t("web.branchLabel")
1772
+ }),
1773
+ /* @__PURE__ */ jsxDEV("span", {
1774
+ class: `sel-trigger-value${s.mrSourceBranch ? "" : " empty"}`,
1775
+ children: s.mrSourceBranch || t("web.selectBranch")
1776
+ }),
1777
+ /* @__PURE__ */ jsxDEV("span", {
1778
+ class: "sel-trigger-arrow",
1779
+ children: "▼"
1780
+ })
1781
+ ]
1782
+ }), s.mrBranchOpen && /* @__PURE__ */ jsxDEV("div", {
1783
+ class: "sel-dropdown",
1784
+ role: "listbox",
1785
+ "aria-label": t("release.selectMrBranch"),
1786
+ children: [/* @__PURE__ */ jsxDEV("div", {
1787
+ class: "sel-search",
1788
+ children: /* @__PURE__ */ jsxDEV("input", {
1789
+ ref: mrBranchSearchRef,
1790
+ class: "sel-search-input",
1791
+ type: "text",
1792
+ placeholder: t("web.filterBranches"),
1793
+ value: s.mrBranchSearch,
1794
+ onChange: (e) => d({
1795
+ type: "SET_MR_BRANCH_SEARCH",
1796
+ search: e.target.value
1797
+ }),
1798
+ onKeyDown: (e) => {
1799
+ const n = selKeyDown(e, s.mrBranchOpen, mrb.length, s.mrBranchIndex, (i) => {
1800
+ if (mrb[i]) d({
1801
+ type: "MR_SOURCE_SELECTED",
1802
+ branch: mrb[i].name
1803
+ });
1804
+ }, () => d({
1805
+ type: "SET_MR_BRANCH_OPEN",
1806
+ open: false
1807
+ }));
1808
+ if (n !== void 0) d({
1809
+ type: "SET_MR_BRANCH_INDEX",
1810
+ index: n
1811
+ });
1812
+ }
1813
+ })
1814
+ }), mrb.length > 0 ? mrb.map((b, i) => /* @__PURE__ */ jsxDEV("div", {
1815
+ class: `sel-item${b.name === s.mrSourceBranch ? " active" : ""}${i === s.mrBranchIndex ? " highlighted" : ""}`,
1816
+ onMouseEnter: () => d({
1817
+ type: "SET_MR_BRANCH_INDEX",
1818
+ index: i
1819
+ }),
1820
+ onClick: () => d({
1821
+ type: "MR_SOURCE_SELECTED",
1822
+ branch: b.name
1823
+ }),
1824
+ children: [/* @__PURE__ */ jsxDEV("span", {
1825
+ class: "sel-item-name",
1826
+ children: b.name
1827
+ }), b.default && /* @__PURE__ */ jsxDEV("span", {
1828
+ style: "font-size:10px;color:var(--neon);margin-left:6px",
1829
+ children: t("web.defaultBranch")
1830
+ })]
1831
+ })) : /* @__PURE__ */ jsxDEV("div", {
1832
+ class: "sel-empty",
1833
+ children: t("web.noBranches")
1834
+ })]
1835
+ })]
1836
+ })]
1837
+ });
1838
+ })(),
1839
+ s.mrStatus === "selecting" && s.mrSourceBranch && /* @__PURE__ */ jsxDEV("div", {
1840
+ style: "margin-top:8px",
1841
+ children: [/* @__PURE__ */ jsxDEV("div", {
1842
+ style: "font-size:13px;color:var(--text-2);margin-bottom:6px",
1843
+ children: t("release.mrFromTo", {
1844
+ source: s.mrSourceBranch,
1845
+ target: s.selectedBranch
1846
+ })
1847
+ }), /* @__PURE__ */ jsxDEV("button", {
1848
+ class: "jira-btn",
1849
+ type: "button",
1850
+ style: "background:var(--cyan);font-size:13px;padding:4px 12px",
1851
+ onClick: () => d({ type: "MR_CREATING" }),
1852
+ children: t("release.confirmCreateMr")
1853
+ })]
1854
+ }),
1855
+ s.mrStatus === "creating" && /* @__PURE__ */ jsxDEV("div", {
1856
+ class: "loading-row",
1857
+ style: "margin-top:12px",
1858
+ children: [/* @__PURE__ */ jsxDEV("span", { class: "spinner" }), t("release.creatingMrBtn")]
1859
+ }),
1860
+ s.mrStatus === "done" && s.mrUrl && /* @__PURE__ */ jsxDEV("div", {
1861
+ class: "jira-result",
1862
+ style: "margin-top:12px",
1863
+ children: [/* @__PURE__ */ jsxDEV("div", {
1864
+ class: "jira-result-label",
1865
+ children: "MR"
1866
+ }), /* @__PURE__ */ jsxDEV("a", {
1867
+ class: "jira-result-key",
1868
+ href: s.mrUrl,
1869
+ target: "_blank",
1870
+ rel: "noreferrer",
1871
+ children: t("release.mrFromTo", {
1872
+ source: s.mrSourceBranch,
1873
+ target: s.selectedBranch
1874
+ })
1875
+ })]
1876
+ }),
1877
+ s.mrStatus === "error" && s.mrError && /* @__PURE__ */ jsxDEV("div", {
1878
+ class: "jira-error",
1879
+ role: "alert",
1880
+ style: "margin-top:12px",
1881
+ children: s.mrError
1882
+ })
1883
+ ]
1884
+ }),
1885
+ !s.selected && /* @__PURE__ */ jsxDEV("div", {
1886
+ class: "empty-hint",
1887
+ children: t("web.emptyHint")
1888
+ })
1889
+ ] });
1890
+ };
1891
+ const ReleaseClient = () => {
1892
+ const [s, d] = useReducer(reducer, initial);
1893
+ useEffect(() => {
1894
+ fetch("/release/api/history").then((r) => r.json()).then((data) => d({
1895
+ type: "SET_HISTORY",
1896
+ history: Array.isArray(data) ? data : []
1897
+ })).catch(() => d({
1898
+ type: "SET_HISTORY",
1899
+ history: []
1900
+ }));
1901
+ }, []);
1902
+ return /* @__PURE__ */ jsxDEV("div", { children: [
1903
+ /* @__PURE__ */ jsxDEV("style", { children: releaseStyle }),
1904
+ /* @__PURE__ */ jsxDEV("div", {
1905
+ class: "page-header",
1906
+ children: [/* @__PURE__ */ jsxDEV("h2", { children: t("web.releaseTitle") }), /* @__PURE__ */ jsxDEV("p", { children: t("web.releaseDesc") })]
1907
+ }),
1908
+ s.historyLoading ? /* @__PURE__ */ jsxDEV("div", {
1909
+ class: "loading-row",
1910
+ children: [/* @__PURE__ */ jsxDEV("span", { class: "spinner" }), t("web.loading")]
1911
+ }) : s.showNewModal ? /* @__PURE__ */ jsxDEV("div", {
1912
+ class: "modal-overlay",
1913
+ onClick: (e) => {
1914
+ if (e.target.classList.contains("modal-overlay")) fetch("/release/api/history").then((r) => r.json()).then((data) => {
1915
+ d({
1916
+ type: "SET_HISTORY",
1917
+ history: Array.isArray(data) ? data : []
1918
+ });
1919
+ d({ type: "HIDE_NEW_MODAL" });
1920
+ }).catch(() => d({ type: "HIDE_NEW_MODAL" }));
1921
+ },
1922
+ children: /* @__PURE__ */ jsxDEV("div", {
1923
+ class: "modal-content",
1924
+ children: [/* @__PURE__ */ jsxDEV("div", {
1925
+ class: "modal-header",
1926
+ children: [/* @__PURE__ */ jsxDEV("span", {
1927
+ class: "modal-title",
1928
+ children: t("web.newModalTitle")
1929
+ }), /* @__PURE__ */ jsxDEV("button", {
1930
+ class: "modal-close",
1931
+ type: "button",
1932
+ onClick: () => {
1933
+ fetch("/release/api/history").then((r) => r.json()).then((data) => {
1934
+ d({
1935
+ type: "SET_HISTORY",
1936
+ history: Array.isArray(data) ? data : []
1937
+ });
1938
+ d({ type: "HIDE_NEW_MODAL" });
1939
+ }).catch(() => d({ type: "HIDE_NEW_MODAL" }));
1940
+ },
1941
+ children: "✕"
1942
+ })]
1943
+ }), /* @__PURE__ */ jsxDEV(ReleaseFlow, {
1944
+ s,
1945
+ d
1946
+ })]
1947
+ })
1948
+ }) : s.history.length > 0 ? /* @__PURE__ */ jsxDEV(HistoryList, {
1949
+ s,
1950
+ d
1951
+ }) : /* @__PURE__ */ jsxDEV(ReleaseFlow, {
1952
+ s,
1953
+ d
1954
+ })
1955
+ ] });
1956
+ };
1957
+ const mount = async (el) => {
1958
+ await initPromise;
1959
+ render(/* @__PURE__ */ jsxDEV(ReleaseClient, {}), el);
1960
+ };
1961
+ //#endregion
1962
+ export { mount };