-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPanel.qml
More file actions
1132 lines (1052 loc) · 42.3 KB
/
Copy pathPanel.qml
File metadata and controls
1132 lines (1052 loc) · 42.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import Quickshell
import Quickshell.Io
import qs.Commons
import qs.Ui
Panel {
id: root
moduleName: "syntaxboybe.gitlab"
ipcTarget: "syntaxboybe.gitlab"
manageIpc: false
readonly property color foreground: bar ? bar.foreground : Color.foreground
readonly property color urgent: bar ? bar.urgent : Color.urgent
readonly property color dim: Qt.darker(foreground, 1.55)
readonly property string fontFamily: bar ? bar.fontFamily : Style.font.family
property string query: ""
property string metricFilter: "all"
property string sortMode: "updated"
property bool cursorActive: false
property int cursorIndex: 0
property bool notificationsExpanded: false
property bool reviewsExpanded: false
property bool myPullsExpanded: false
property bool issuesExpanded: false
property bool actionsExpanded: false
property bool failuresExpanded: false
property bool settingsOpen: false
property bool pendingSettingsOpen: false
readonly property var linkBehaviorOptions: [
{ value: "Web app window", label: "Web app window" },
{ value: "Browser tab", label: "Browser tab" }
]
readonly property var repositoryScopeOptions: [
{ value: "Owned", label: "Owned projects" },
{ value: "Owned and groups", label: "Owned and groups" }
]
readonly property var refreshIntervalOptions: [
{ value: "300", label: "Every 5 minutes" },
{ value: "600", label: "Every 10 minutes" },
{ value: "900", label: "Every 15 minutes" },
{ value: "1800", label: "Every 30 minutes" },
{ value: "3600", label: "Every hour" }
]
readonly property int activityPreviewCount: 5
readonly property int activityExpandedCount: 25
readonly property var metricFilters: [
{ id: "all", label: "All" }, { id: "issues", label: "Issues" },
{ id: "prs", label: "MRs" }, { id: "stars", label: "Stars" },
{ id: "actions", label: "Pipelines" }
]
readonly property var sortModes: [
{ id: "updated", label: "Updated" }, { id: "name", label: "Name" },
{ id: "stars", label: "Stars" }, { id: "issues", label: "Issues" },
{ id: "prs", label: "MRs" }, { id: "actions", label: "Pipelines" }
]
readonly property var displayedRepositories: filteredRepositories()
readonly property var cursorTargets: buildCursorTargets()
readonly property var selectedTarget: cursorTargets.length > 0 ? cursorTargets[Math.max(0, Math.min(cursorIndex, cursorTargets.length - 1))] : null
function sectionRows(rows, expanded) {
return rows.slice(0, expanded ? activityExpandedCount : activityPreviewCount)
}
function buildCursorTargets() {
var targets = []
function add(kind, rows) {
for (var i = 0; i < rows.length; i++) targets.push({ key: kind + ":" + String(rows[i].id || rows[i].url || i), kind: kind, row: rows[i] })
}
add("notification", sectionRows(gitlab.notifications, notificationsExpanded))
add("review", sectionRows(gitlab.reviewRequests, reviewsExpanded))
add("mypull", sectionRows(gitlab.myPullRequests, myPullsExpanded))
add("issue", sectionRows(gitlab.assignedIssues, issuesExpanded))
add("action", sectionRows(gitlab.actions, actionsExpanded))
add("failure", sectionRows(gitlab.failedActions, failuresExpanded))
add("repository", displayedRepositories)
return targets
}
function targetKey(kind, row, index) { return kind + ":" + String((row && (row.id || row.url)) || index) }
function selectedKey() { return selectedTarget ? selectedTarget.key : "" }
function selectKey(key) {
for (var i = 0; i < cursorTargets.length; i++) if (cursorTargets[i].key === key) { cursorActive = true; cursorIndex = i; return }
}
function ensureCursor() {
if (cursorTargets.length === 0) { cursorIndex = 0; return }
cursorIndex = Math.max(0, Math.min(cursorIndex, cursorTargets.length - 1))
}
function moveCursor(delta) {
cursorActive = true
if (cursorTargets.length === 0) return
cursorIndex = Math.max(0, Math.min(cursorTargets.length - 1, cursorIndex + delta))
}
function activateCursor() {
if (!selectedTarget) return
openUrl(selectedTarget.row.url)
}
function markSelectedRead() {
if (gitlab.loading || gitlab.marking) return
if (selectedTarget && selectedTarget.kind === "notification") gitlab.markNotificationRead(String(selectedTarget.row.id || ""))
}
function scrollItemIntoView(item) {
if (!panelFlick || !item) return
Qt.callLater(function() {
var point = item.mapToItem(panelFlick.contentItem, 0, 0)
var margin = Style.space(8)
var top = point.y
var bottom = top + item.height
var maxY = Math.max(0, panelFlick.contentHeight - panelFlick.height)
if (top < panelFlick.contentY + margin) panelFlick.contentY = Math.max(0, top - margin)
else if (bottom > panelFlick.contentY + panelFlick.height - margin) panelFlick.contentY = Math.min(maxY, bottom + margin - panelFlick.height)
})
}
function setting(name, fallback) {
var value = settings ? settings[name] : undefined
return value === undefined || value === null ? fallback : value
}
function gitlabUrl(path) {
var base = String(gitlab.webBaseUrl || "https://gitlab.com").replace(/\/+$/, "")
var suffix = String(path || "").replace(/^\/+/, "")
return base + "/" + suffix
}
function instanceMeta() {
var host = String(gitlab.instanceHostname || "gitlab.com")
return host === "gitlab.com" ? "" : " · " + host
}
function checkLabel(checks) {
if (checks === "SUCCESS") return "checks passing"
if (checks === "ERROR") return "checks errored"
if (gitlab.isBrokenCheck(checks)) return "checks failing"
if (gitlab.isRunningCheck(checks)) return "checks running"
return "no checks"
}
function openUrl(url) {
var value = String(url || "")
if (value === "") return
if (gitlab.linkBehavior === "Browser tab") Quickshell.execDetached(["omarchy-launch-browser", value])
else Quickshell.execDetached(["omarchy-launch-webapp", value])
close()
}
// Settings live on this widget's entry in shell.json. Merge into the
// existing entry so hostname and advanced scan settings survive changes.
function persistSettings(values) {
var entry = { id: root.moduleName }
for (var existing in root.settings) if (existing !== "id") entry[existing] = root.settings[existing]
for (var key in values) {
if (values[key] === undefined) delete entry[key]
else entry[key] = values[key]
}
root.settings = entry
if (root.bar && root.bar.shell && typeof root.bar.shell.updateEntryInline === "function")
root.bar.shell.updateEntryInline(root.moduleName, entry)
}
function showSettings(open) {
settingsOpen = open === true
pendingSettingsOpen = settingsOpen
if (settingsOpen && settingsFlick) settingsFlick.contentY = 0
Qt.callLater(function() {
if (settingsOpen) linkBehaviorDropdown.forceActiveFocus()
else keyCatcher.forceActiveFocus()
})
}
function filteredRepositories() {
var needle = String(query || "").trim().toLowerCase()
var rows = []
for (var i = 0; i < gitlab.repositories.length; i++) {
var repo = gitlab.repositories[i]
if (needle !== "" && String(repo.nameWithOwner || repo.name || "").toLowerCase().indexOf(needle) === -1) continue
if (metricFilter === "issues" && Number(repo.issues || 0) <= 0) continue
if (metricFilter === "prs" && Number(repo.prs || 0) <= 0) continue
if (metricFilter === "stars" && Number(repo.stars || 0) <= 0) continue
if (metricFilter === "actions" && Number(repo.activeActions || 0) <= 0) continue
rows.push(repo)
}
rows.sort(function(a, b) {
if (sortMode === "name") return String(a.nameWithOwner).localeCompare(String(b.nameWithOwner))
if (sortMode === "updated") return String(b.updatedAt).localeCompare(String(a.updatedAt))
var av = Number(a[sortMode] || (sortMode === "actions" ? a.activeActions : 0) || 0)
var bv = Number(b[sortMode] || (sortMode === "actions" ? b.activeActions : 0) || 0)
if (av !== bv) return bv - av
return String(a.nameWithOwner).localeCompare(String(b.nameWithOwner))
})
return rows.slice(0, Math.max(10, Number(setting("maxDisplayedRepos", 25))))
}
function relativeTime(value) {
var then = new Date(String(value || "")).getTime()
if (!isFinite(then)) return ""
var seconds = Math.max(0, Math.floor((Date.now() - then) / 1000))
if (seconds < 60) return "just now"
if (seconds < 3600) return Math.floor(seconds / 60) + "m ago"
if (seconds < 86400) return Math.floor(seconds / 3600) + "h ago"
if (seconds < 2592000) return Math.floor(seconds / 86400) + "d ago"
return Math.floor(seconds / 2592000) + "mo ago"
}
implicitWidth: button.implicitWidth
implicitHeight: button.implicitHeight
onOpenedChanged: {
// A pending confirmation must never survive the panel closing, or the next
// open would run a destructive action on a single click.
if (notificationsSection) notificationsSection.disarmAction()
if (opened) {
settingsOpen = false
pendingSettingsOpen = false
cursorActive = false
cursorIndex = 0
if (panelFlick) panelFlick.contentY = 0
gitlab.refresh()
Qt.callLater(function() { keyCatcher.forceActiveFocus() })
}
}
onCursorTargetsChanged: ensureCursor()
Service { id: gitlab; settings: root.settings }
IpcHandler {
target: root.ipcTarget
function open(): void { root.open() }
function close(): void { root.close() }
function show(): void { root.open() }
function hide(): void { root.close() }
function toggle(): void { root.toggle() }
function refresh(): string { gitlab.refresh(); return "ok" }
function status(): string { return gitlab.state }
}
BarIconButton {
id: button
anchors.fill: parent
bar: root.bar
text: ""
active: gitlab.alarming
onPressed: function(buttonCode) {
if (buttonCode === Qt.RightButton || buttonCode === Qt.MiddleButton) gitlab.refresh()
else root.toggle()
}
}
KeyboardPanel {
id: panel
anchorItem: button
owner: root
bar: root.bar
open: root.opened
focusTarget: keyCatcher
contentWidth: panel.fittedContentWidth(Style.space(430))
contentHeight: panel.fittedContentHeight(settingsOpen ? settingsHeader.implicitHeight + settingsContent.implicitHeight + Style.space(24) : content.implicitHeight, Style.space(680))
PanelKeyCatcher {
id: keyCatcher
anchors.fill: parent
blocked: settingsOpen || search.activeFocus || sortPicker.popup.visible
onMoveRequested: function(dx, dy) { if (dy !== 0) root.moveCursor(dy) }
onActivateRequested: if (!settingsOpen) root.activateCursor()
onCloseRequested: if (settingsOpen) root.showSettings(false); else root.close()
// Tab enters the native control chain so search, filters, sorting, and
// section controls remain keyboard-accessible.
onTabRequested: function(direction) {
if (direction < 0) sortPicker.forceActiveFocus()
else search.forceActiveFocus()
}
onTextKey: function(text) {
if (settingsOpen) return
if (text === "r" || text === "R") gitlab.refresh()
else if (text === "/") Qt.callLater(function() { search.forceActiveFocus() })
else if (text === "m" || text === "M") root.markSelectedRead()
}
Flickable {
id: panelFlick
anchors.fill: parent
visible: !settingsOpen
contentWidth: width
contentHeight: content.implicitHeight
clip: true
boundsBehavior: Flickable.StopAtBounds
flickableDirection: Flickable.VerticalFlick
interactive: contentHeight > height
ScrollBar.vertical: ScrollBar { policy: ScrollBar.AsNeeded }
Column {
id: content
width: panelFlick.width
spacing: Style.space(12)
PanelHero {
width: parent.width
title: gitlab.login !== "" ? "GitLab · " + gitlab.login : "GitLab"
// Mirrors every term of the alarming state, so the summary always
// explains why the bar icon is lit.
meta: gitlab.loading ? "Refreshing dashboard…" : (gitlab.state === "ready" ?
gitlab.unreadCount + " unread · " + gitlab.reviewRequests.length + " reviews · " + gitlab.actionCount + " active pipelines"
+ (gitlab.failingPullRequestCount > 0 ? " · " + gitlab.failingPullRequestCount + " failing" : "") + root.instanceMeta() : gitlab.message + root.instanceMeta())
foreground: root.foreground
fontFamily: root.fontFamily
trailingControl: Component {
PanelActionButton {
iconText: ""
tooltipText: "GitLab settings"
foreground: root.foreground
fontFamily: root.fontFamily
onClicked: root.showSettings(true)
}
}
iconComponent: Component {
Text {
text: ""
color: root.foreground
font.family: root.fontFamily
font.pixelSize: Style.font.display
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
}
}
Text {
visible: gitlab.notificationActionStatus !== ""
width: parent.width
text: gitlab.notificationActionStatus
textFormat: Text.PlainText
color: root.dim
font.family: root.fontFamily
font.pixelSize: Style.font.bodySmall
horizontalAlignment: Text.AlignHCenter
wrapMode: Text.WordWrap
}
BorderSurface {
visible: gitlab.state !== "ready" || gitlab.warnings.length > 0
width: parent.width
implicitHeight: statusText.implicitHeight + Style.space(20)
color: Qt.rgba(root.urgent.r, root.urgent.g, root.urgent.b, 0.10)
borderSpec: Border.flat(Qt.rgba(root.urgent.r, root.urgent.g, root.urgent.b, 0.35), 1)
radius: Style.cornerRadius
Text {
id: statusText
anchors.left: parent.left
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
anchors.margins: Style.space(10)
text: {
if (gitlab.state !== "ready") return gitlab.message
var summary = "Partial results · " + String(gitlab.warnings[0] || "A GitLab request failed.")
if (gitlab.warnings.length > 1) summary += " · " + (gitlab.warnings.length - 1) + " more"
return summary
}
textFormat: Text.PlainText
color: gitlab.state === "ready" ? root.dim : root.urgent
font.family: root.fontFamily
font.pixelSize: Style.font.bodySmall
wrapMode: Text.WordWrap
}
}
DashboardSection {
id: notificationsSection
title: "UNREAD NOTIFICATIONS"
count: gitlab.notifications.length
emptyText: gitlab.state === "ready" ? "You're all caught up." : "No notifications loaded."
model: root.sectionRows(gitlab.notifications, root.notificationsExpanded)
expanded: root.notificationsExpanded
openUrl: root.gitlabUrl("dashboard/todos")
onToggleExpanded: root.notificationsExpanded = !root.notificationsExpanded
delegateComponent: notificationDelegate
actionText: "Mark all read"
actionBusyText: "Marking…"
actionEnabled: gitlab.state === "ready" && !gitlab.loading
actionBusy: gitlab.marking
actionRevision: gitlab.notificationsRevision
actionPrepare: function() { return gitlab.prepareMarkAllNotificationsRead(root.notificationsExpanded ? root.activityExpandedCount : root.activityPreviewCount) }
onActionTriggered: function(prepared) { gitlab.markAllNotificationsRead(prepared) }
}
DashboardSection {
visible: count > 0
title: "REVIEW REQUESTS"
count: gitlab.reviewRequests.length
model: root.sectionRows(gitlab.reviewRequests, root.reviewsExpanded)
expanded: root.reviewsExpanded
openUrl: root.gitlabUrl("dashboard/merge_requests")
onToggleExpanded: root.reviewsExpanded = !root.reviewsExpanded
delegateComponent: reviewDelegate
}
DashboardSection {
visible: count > 0
title: "MY MERGE REQUESTS"
// The search is capped at one page, so the fetched list can be
// shorter than the real total. Show the total rather than implying
// the section is complete.
count: Math.max(gitlab.myPullRequestsTotal, gitlab.myPullRequests.length)
model: root.sectionRows(gitlab.myPullRequests, root.myPullsExpanded)
expanded: root.myPullsExpanded
openUrl: root.gitlabUrl("dashboard/merge_requests")
onToggleExpanded: root.myPullsExpanded = !root.myPullsExpanded
delegateComponent: myPullRequestDelegate
}
DashboardSection {
visible: count > 0
title: "ASSIGNED ISSUES"
count: gitlab.assignedIssues.length
model: root.sectionRows(gitlab.assignedIssues, root.issuesExpanded)
expanded: root.issuesExpanded
openUrl: root.gitlabUrl("dashboard/issues")
onToggleExpanded: root.issuesExpanded = !root.issuesExpanded
delegateComponent: issueDelegate
}
DashboardSection {
visible: count > 0
title: "RUNNING PIPELINES"
count: gitlab.actions.length
model: root.sectionRows(gitlab.actions, root.actionsExpanded)
expanded: root.actionsExpanded
onToggleExpanded: root.actionsExpanded = !root.actionsExpanded
delegateComponent: actionDelegate
}
DashboardSection {
visible: count > 0
title: "RECENT FAILED PIPELINES"
count: gitlab.failedActions.length
model: root.sectionRows(gitlab.failedActions, root.failuresExpanded)
expanded: root.failuresExpanded
onToggleExpanded: root.failuresExpanded = !root.failuresExpanded
delegateComponent: failedActionDelegate
}
PanelSeparator { foreground: root.foreground }
PanelSectionHeader {
width: parent.width
// Driven by the fetched scope, not the setting, so it cannot claim
// to list organization repositories before a refresh brings them in.
text: (gitlab.fetchedRepositoryScope === "owned" ? "OWNED PROJECTS " : "MEMBER PROJECTS ") + root.displayedRepositories.length + "/" + gitlab.repositories.length
foreground: root.foreground
fontFamily: root.fontFamily
}
TextField {
id: search
width: parent.width
foreground: root.foreground
placeholderText: "Filter repositories /"
text: root.query
onTextChanged: root.query = text
Keys.onEscapePressed: function(event) {
root.query = ""
keyCatcher.forceActiveFocus()
event.accepted = true
}
}
Flickable {
width: parent.width
height: filterRow.implicitHeight
contentWidth: filterRow.implicitWidth
contentHeight: height
clip: true
flickableDirection: Flickable.HorizontalFlick
Row {
id: filterRow
spacing: Style.space(6)
Repeater {
model: root.metricFilters
Button {
required property var modelData
text: modelData.label
selected: root.metricFilter === modelData.id
bordered: true
foreground: root.foreground
fontFamily: root.fontFamily
fontSize: Style.font.caption
verticalPadding: Style.spacing.controlPaddingY
onClicked: root.metricFilter = modelData.id
}
}
}
}
RowLayout {
width: parent.width
spacing: Style.space(8)
Text {
text: "Sort"
color: root.dim
font.family: root.fontFamily
font.pixelSize: Style.font.caption
}
ComboBox {
id: sortPicker
Layout.fillWidth: true
model: root.sortModes
textRole: "label"
currentIndex: {
for (var i = 0; i < root.sortModes.length; i++) if (root.sortModes[i].id === root.sortMode) return i
return 0
}
onActivated: function(index) { root.sortMode = root.sortModes[index].id }
}
}
Text {
visible: root.displayedRepositories.length === 0
width: parent.width
text: gitlab.repositories.length === 0 ? "No repositories loaded." : "No repositories match these filters."
color: root.dim
font.family: root.fontFamily
font.pixelSize: Style.font.body
horizontalAlignment: Text.AlignHCenter
}
Column {
width: parent.width
spacing: Style.space(4)
Repeater {
model: root.displayedRepositories
RepoRow {
required property var modelData
required property int index
width: parent.width
repo: modelData
rowIndex: index
}
}
}
Text {
visible: gitlab.rateLimit && gitlab.rateLimit.remaining !== undefined
width: parent.width
text: "API requests remaining: " + (gitlab.rateLimit ? gitlab.rateLimit.remaining : "") +
(gitlab.fetchedAt !== "" ? " · updated " + root.relativeTime(gitlab.fetchedAt) : "")
color: root.dim
font.family: root.fontFamily
font.pixelSize: Style.font.caption
horizontalAlignment: Text.AlignHCenter
}
}
}
ColumnLayout {
id: settingsPage
anchors.fill: parent
visible: root.settingsOpen
spacing: Style.space(12)
Keys.priority: Keys.AfterItem
Keys.onEscapePressed: function(event) {
root.showSettings(false)
event.accepted = true
}
Column {
id: settingsHeader
Layout.fillWidth: true
spacing: Style.space(12)
Item {
width: parent.width
implicitHeight: Math.max(settingsBackButton.implicitHeight, settingsLabels.implicitHeight)
PanelActionButton {
id: settingsBackButton
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
iconText: ""
tooltipText: "Back to the dashboard"
foreground: root.foreground
focusable: true
fontFamily: root.fontFamily
onClicked: root.showSettings(false)
}
Column {
id: settingsLabels
anchors.left: settingsBackButton.right
anchors.leftMargin: Style.space(10)
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
spacing: Style.space(3)
Text {
text: "GITLAB SETTINGS"
color: root.foreground
font.family: root.fontFamily
font.pixelSize: Style.font.title
font.bold: true
}
}
}
PanelSeparator { foreground: root.foreground }
}
Flickable {
id: settingsFlick
Layout.fillWidth: true
Layout.fillHeight: true
contentWidth: width
contentHeight: settingsContent.implicitHeight
clip: true
boundsBehavior: Flickable.StopAtBounds
flickableDirection: Flickable.VerticalFlick
interactive: contentHeight > height
ScrollBar.vertical: ScrollBar { policy: ScrollBar.AsNeeded }
Column {
id: settingsContent
width: settingsFlick.width
spacing: Style.space(20)
Column {
width: parent.width
spacing: Style.space(6)
Text {
text: "OPEN LINKS"
color: root.dim
font.family: root.fontFamily
font.pixelSize: Style.font.caption
font.bold: true
}
Dropdown {
id: linkBehaviorDropdown
width: parent.width
showLabel: false
options: root.linkBehaviorOptions
foreground: root.foreground
background: Color.popups.background
accent: Color.accent
fontFamily: root.fontFamily
onChanged: function(value) { root.persistSettings({ linkBehavior: value }) }
Binding on value { value: gitlab.linkBehavior }
}
}
Column {
width: parent.width
spacing: Style.space(6)
Text {
text: "REPOSITORY SCOPE"
color: root.dim
font.family: root.fontFamily
font.pixelSize: Style.font.caption
font.bold: true
}
Dropdown {
id: repositoryScopeDropdown
width: parent.width
showLabel: false
options: root.repositoryScopeOptions
foreground: root.foreground
background: Color.popups.background
accent: Color.accent
fontFamily: root.fontFamily
onChanged: function(value) { root.persistSettings({ repositoryScope: value }) }
Binding on value { value: String(root.setting("repositoryScope", "Owned")) }
}
}
Column {
width: parent.width
spacing: Style.space(6)
Text {
text: "REFRESH INTERVAL"
color: root.dim
font.family: root.fontFamily
font.pixelSize: Style.font.caption
font.bold: true
}
Dropdown {
id: refreshIntervalDropdown
width: parent.width
showLabel: false
options: root.refreshIntervalOptions
foreground: root.foreground
background: Color.popups.background
accent: Color.accent
fontFamily: root.fontFamily
onChanged: function(value) { root.persistSettings({ refreshIntervalSec: parseInt(value, 10) }) }
Binding on value { value: String(root.setting("refreshIntervalSec", 900)) }
}
}
PanelSeparator { width: parent.width; foreground: root.foreground }
Toggle {
width: parent.width
label: "Keep the bar icon unlit"
description: "Leave the GitLab icon dim even when notifications, reviews, or pipelines are waiting."
checked: gitlab.iconAlwaysUnlit
foreground: root.foreground
accent: Color.accent
fontFamily: root.fontFamily
onClicked: root.persistSettings({ iconAlwaysUnlit: !gitlab.iconAlwaysUnlit })
}
Toggle {
width: parent.width
label: "Include archived projects"
description: "Show projects that have been archived on GitLab."
checked: root.setting("includeArchived", false) === true
foreground: root.foreground
accent: Color.accent
fontFamily: root.fontFamily
onClicked: root.persistSettings({ includeArchived: !(root.setting("includeArchived", false) === true) })
}
Toggle {
width: parent.width
label: "Include forked projects"
description: "Show projects forked from another project."
checked: root.setting("includeForks", false) === true
foreground: root.foreground
accent: Color.accent
fontFamily: root.fontFamily
onClicked: root.persistSettings({ includeForks: !(root.setting("includeForks", false) === true) })
}
Text {
width: parent.width
text: "The remaining options — Pipelines scanning, review filters, and display limits — stay in Omarchy's bar widget settings."
color: root.dim
font.family: root.fontFamily
font.pixelSize: Style.font.caption
wrapMode: Text.WordWrap
}
}
}
}
}
}
Component {
id: notificationDelegate
LinkRow {
required property var modelData
required property int index
width: parent ? parent.width : 0
rowKind: "notification"
rowIndex: index
rowId: String(modelData.id || modelData.url || index)
glyph: modelData.type === "MergeRequest" ? "" : ""
title: modelData.title
detail: modelData.repository + " · " + modelData.reason + " · " + root.relativeTime(modelData.updatedAt)
url: modelData.url
showReadAction: true
notificationId: String(modelData.id || "")
}
}
Component {
id: reviewDelegate
LinkRow {
required property var modelData
required property int index
width: parent ? parent.width : 0
rowKind: "review"
rowIndex: index
rowId: String(modelData.id || modelData.url || index)
glyph: ""
title: modelData.title
// Drafts only appear here when the setting is on, and the reason to turn
// it on is knowing which requests are early feedback rather than a real
// review, so the row has to say which it is.
detail: modelData.repository + (modelData.draft ? " · draft" : "") + " · review requested · " + root.relativeTime(modelData.updatedAt)
url: modelData.url
}
}
Component {
id: myPullRequestDelegate
LinkRow {
required property var modelData
required property int index
readonly property string checks: String(modelData.checks || "NONE")
readonly property bool broken: gitlab.isBrokenCheck(checks)
readonly property bool running: gitlab.isRunningCheck(checks)
width: parent ? parent.width : 0
rowKind: "mypull"
rowIndex: index
rowId: String(modelData.id || modelData.url || index)
// A repository with no pipelines reports no rollup at all, which the
// plain merge request glyph conveys without implying a pending run.
glyph: broken ? "" : (running ? "" : (checks === "SUCCESS" ? "" : ""))
title: modelData.title
detail: modelData.repository + " !" + modelData.number + (modelData.draft ? " · draft" : "") + " · " + root.checkLabel(checks) + " · " + root.relativeTime(modelData.updatedAt)
url: modelData.url
danger: broken
pulse: running
}
}
Component {
id: issueDelegate
LinkRow {
required property var modelData
required property int index
width: parent ? parent.width : 0
rowKind: "issue"
rowIndex: index
rowId: String(modelData.id || modelData.url || index)
glyph: ""
title: modelData.title
detail: modelData.repository + " · assigned to you · " + root.relativeTime(modelData.updatedAt)
url: modelData.url
}
}
Component {
id: actionDelegate
LinkRow {
required property var modelData
required property int index
width: parent ? parent.width : 0
rowKind: "action"
rowIndex: index
rowId: String(modelData.id || modelData.url || index)
glyph: ""
title: modelData.name
detail: modelData.repository + " · " + modelData.status + (modelData.branch ? " · " + modelData.branch : "")
url: modelData.url
pulse: true
}
}
Component {
id: failedActionDelegate
LinkRow {
required property var modelData
required property int index
width: parent ? parent.width : 0
rowKind: "failure"
rowIndex: index
rowId: String(modelData.id || modelData.url || index)
glyph: ""
title: modelData.name
detail: modelData.repository + " · " + modelData.conclusion + " · " + root.relativeTime(modelData.updatedAt)
url: modelData.url
danger: true
}
}
component DashboardSection: Column {
id: section
property string title: ""
property int count: 0
property string emptyText: ""
property var model: []
property Component delegateComponent: null
property bool expanded: false
property string openUrl: ""
// Optional destructive action. It arms on the first click and only runs on
// the second, so a stray click cannot clear the section.
property string actionText: ""
property string actionConfirmText: "Confirm?"
property string actionBusyText: ""
property bool actionEnabled: false
property bool actionBusy: false
property bool actionArmed: false
property int actionRevision: 0
property var actionPrepare: null
property string preparedAction: ""
signal toggleExpanded()
signal actionTriggered(string prepared)
function disarmAction() {
section.actionArmed = false
section.preparedAction = ""
actionArmTimer.stop()
}
// An armed confirmation must not outlive the button being clickable, or it
// would fire on the first click once the button comes back.
onActionBusyChanged: if (section.actionBusy) section.disarmAction()
onActionEnabledChanged: if (!section.actionEnabled) section.disarmAction()
onActionRevisionChanged: if (section.actionArmed) section.disarmAction()
width: parent ? parent.width : 0
spacing: Style.space(8)
PanelSeparator { foreground: root.foreground }
PanelSectionHeader {
width: parent.width
text: section.title + " " + section.count
foreground: root.foreground
fontFamily: root.fontFamily
}
Text {
visible: section.count === 0
width: parent.width
text: section.emptyText
color: root.dim
font.family: root.fontFamily
font.pixelSize: Style.font.bodySmall
horizontalAlignment: Text.AlignHCenter
}
Column {
width: parent.width
spacing: Style.space(4)
Repeater { model: section.model; delegate: section.delegateComponent }
}
Timer {
id: actionArmTimer
interval: 4000
repeat: false
onTriggered: section.actionArmed = false
}
Row {
id: sectionFooter
// Expanding is only offered once the section is truncated; below that
// threshold the remaining controls render unbordered on their own line.
readonly property bool expandable: section.count > root.activityPreviewCount
readonly property bool showOpen: section.count > 0 && section.openUrl !== ""
readonly property bool showAction: section.count > 0 && section.actionEnabled && section.actionText !== ""
visible: expandable || showOpen || showAction
anchors.horizontalCenter: parent.horizontalCenter
spacing: Style.space(12)
Button {
visible: sectionFooter.expandable
text: section.expanded ? "Show less" : (section.count > root.activityExpandedCount ? "Show 25" : "Show all " + section.count)
bordered: true
foreground: root.foreground
fontFamily: root.fontFamily
fontSize: Style.font.caption
verticalPadding: Style.spacing.controlPaddingY
onClicked: section.toggleExpanded()
}
Button {
id: actionButton
// The confirm and busy labels are shorter than the idle one. Letting the
// button shrink would slide its neighbours under a pointer that is about
// to click again, so the widest label seen so far sets the width.
property real reservedWidth: 0
onImplicitWidthChanged: reservedWidth = Math.max(reservedWidth, implicitWidth)
width: Math.max(reservedWidth, implicitWidth)
visible: sectionFooter.showAction
enabled: !section.actionBusy
text: section.actionBusy ? section.actionBusyText : (section.actionArmed ? section.actionConfirmText : section.actionText)
bordered: sectionFooter.expandable
foreground: section.actionArmed ? root.urgent : root.foreground
fontFamily: root.fontFamily
fontSize: Style.font.caption
verticalPadding: Style.spacing.controlPaddingY
onClicked: {
if (section.actionBusy) return
if (!section.actionArmed) {
var prepared = section.actionPrepare ? String(section.actionPrepare() || "") : "confirmed"
if (prepared === "") return
section.preparedAction = prepared
section.actionArmed = true
actionArmTimer.restart()
return
}
var confirmed = section.preparedAction
section.disarmAction()
section.actionTriggered(confirmed)
}
}
Button {
visible: sectionFooter.showOpen
text: "Open in GitLab "
bordered: sectionFooter.expandable
foreground: root.foreground
fontFamily: root.fontFamily
fontSize: Style.font.caption
verticalPadding: Style.spacing.controlPaddingY
onClicked: root.openUrl(section.openUrl)
}
}
}
component LinkRow: CursorSurface {
id: linkRow
property string glyph: ""
property string title: ""
property string detail: ""
property string url: ""
property bool pulse: false
property bool danger: false
property bool showReadAction: false