-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsyncs.go.html
More file actions
286 lines (277 loc) · 13.6 KB
/
Copy pathsyncs.go.html
File metadata and controls
286 lines (277 loc) · 13.6 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
{{/* Copyright (c) ClaceIO, LLC */}}
{{/* SPDX-License-Identifier: Apache-2.0 */}}
{{/* Syncs page (/syncs): sync entries table with run/delete actions.
HTMX partial: block sync_rows
*/}}
<!DOCTYPE html>
<html lang="en">
{{ template "head" . }}
<body class="min-h-screen bg-base-200">
<div class="drawer lg:drawer-open">
{{ template "drawer_toggle" }}
<div class="drawer-content">
<main class="p-4 lg:p-6 space-y-4 max-w-6xl">
<!-- Header -->
<div
class="page-header flex items-center gap-2 flex-wrap mb-2 md:mb-6">
{{ template "hamburger" . }}
<div>
{{ template "page_title" "OpenRun Syncs" }}
<p class="page-desc text-sm text-base-content/70">
Declaratively managed apps
</p>
</div>
<div class="page-actions ml-auto flex items-center gap-2">
<label
class="input input-sm flex-1 min-w-0 sm:flex-none sm:w-48 sm:focus-within:w-60 transition-[width] duration-300 flex">
<kbd class="kbd kbd-xs hidden sm:inline-flex" aria-hidden="true"
>⌘K</kbd
>
<input
id="page-search"
type="search"
name="query"
aria-label="Filter syncs"
value="{{ .Data.Query }}"
placeholder="Filter syncs…"
hx-get="{{ .AppPath }}/syncs"
hx-trigger="input changed delay:300ms, search"
hx-push-url="true"
hx-target="#sync-rows"
hx-swap="innerHTML transition:true"
hx-indicator="#page-progress" />
</label>
<a
class="btn btn-sm btn-primary transition-transform duration-150 active:scale-95 {{ if not (index .Data.Perms "sync:create") }}
btn-disabled tooltip tooltip-bottom
{{ end }}"
{{ if index .Data.Perms "sync:create" }}
href="{{ .AppPath }}/syncs/create"
{{ else }}
data-tip="requires sync:create" aria-disabled="true"
tabindex="-1"
{{ end }}>
+ Add sync source
</a>
</div>
</div>
{{ template "page_progress" }}
<!-- Sync source rows -->
<div id="sync-rows" class="space-y-4">
{{ block "sync_rows" . }}
{{ template "flash_alerts" .Data }}
{{ if .Data.SyncResult }}
{{ template "sync_result" .Data.SyncResult }}
{{ end }}
{{ if .Data.Syncs }}
<div class="card bg-base-100 border border-base-300">
<div class="overflow-x-auto">
<table class="table table-sm">
<thead>
<tr>
<th scope="col" class="w-8">
<span class="sr-only">Details</span>
</th>
<th scope="col">State</th>
<th scope="col">Source</th>
<th scope="col" class="hidden md:table-cell">
Trigger
</th>
<th scope="col" class="hidden lg:table-cell">
Flags
</th>
<th scope="col" class="hidden lg:table-cell">By</th>
<th scope="col" class="hidden sm:table-cell">
Last sync
</th>
<th scope="col" class="text-right">Actions</th>
</tr>
</thead>
<tbody>
{{ range .Data.Syncs }}
<tr class="group hover:bg-base-200/60">
<td class="w-8">
<a
href="{{ $.AppPath }}/syncs/detail?id={{ .id }}"
class="btn btn-xs btn-ghost btn-square tooltip tooltip-right"
data-tip="Expand: sync details and last run results"
aria-label="View details for sync {{ .repo }}">
{{ template "drilldown_icon" }}
</a>
</td>
<td class="whitespace-nowrap">
{{ if eq .state "Failing" }}
<span class="status status-error"></span>
<span class="text-xs text-error">failing</span>
{{ else if eq .state "Disabled" }}
<span class="status status-warning"></span>
<span class="text-xs">disabled</span>
{{ else }}
<span class="status status-success"></span>
<span class="text-xs">healthy</span>
{{ end }}
</td>
<td>
{{/* break-all needs a min-width floor: table
auto-layout otherwise squeezes the column to
one-character slivers on mobile
*/}}
<span
class="font-mono text-xs font-medium break-all inline-block min-w-40 align-bottom"
>{{ .repo }}</span
>
{{ if .branch }}
<span class="badge badge-ghost badge-xs"
>{{ .branch }}</span
>
{{ end }}
</td>
<td
class="text-xs text-base-content/70 hidden md:table-cell whitespace-nowrap">
{{ if .is_scheduled }}
every {{ .schedule_frequency }}m
{{ else }}
webhook
{{ end }}
</td>
<td class="hidden lg:table-cell">
{{ range .flags }}
{{ if eq . "clobber" }}
<span
class="badge badge-xs badge-soft badge-warning"
>{{ . }}</span
>
{{ else }}
<span
class="badge badge-xs badge-soft badge-primary"
>{{ . }}</span
>
{{ end }}
{{ else }}
<span
class="text-xs text-base-content/70 tooltip tooltip-right"
data-tip="staging only - no promote"
>staging only</span
>
{{ end }}
</td>
<td
class="text-xs text-base-content/70 hidden lg:table-cell whitespace-nowrap max-w-32 truncate tooltip tooltip-left"
data-tip="{{ .user }}">
{{ if .user }}
{{ .user }}
{{ else }}
-
{{ end }}
</td>
<td
class="text-xs text-base-content/70 hidden sm:table-cell whitespace-nowrap">
{{ if .last_exec }}
{{ template "time_ago" .last_exec }}
{{ else }}
never
{{ end }}
{{ if .commit }}
<span class="font-mono">{{ .commit }}</span>
{{ end }}
{{ if .failure_count }}
<span
class="badge badge-error badge-xs badge-soft"
>{{ .failure_count }} fails</span
>
{{ end }}
</td>
<td class="text-right whitespace-nowrap">
<div class="inline-flex items-center gap-0.5">
<button
class="btn btn-xs btn-ghost text-primary tooltip tooltip-left"
aria-label="Run sync {{ .repo }} now"
{{ if index $.Data.Perms "sync:run" }}
data-tip="Fetch from the source and apply
now" hx-post="{{ $.AppPath }}/syncs/run"
hx-vals='{"sync_id": "{{ .id }}"}'
hx-target="#sync-rows" hx-swap="innerHTML
transition:true" hx-include="#page-search"
hx-disabled-elt="this"
hx-indicator="#page-progress"
{{ else }}
disabled data-tip="requires sync:run"
{{ end }}>
sync now
</button>
<button
class="btn btn-xs btn-ghost text-error tooltip tooltip-left"
aria-label="Delete sync {{ .repo }}"
{{ if index $.Data.Perms "sync:delete" }}
data-tip="Remove this sync source (apps are
not deleted)"
hx-post="{{ $.AppPath }}/syncs/delete"
hx-vals='{"sync_id": "{{ .id }}"}'
hx-confirm="Remove sync source {{ .repo }}?
Apps applied by it are not deleted."
hx-target="#sync-rows" hx-swap="innerHTML
transition:true" hx-include="#page-search"
hx-disabled-elt="this"
hx-indicator="#page-progress"
{{ else }}
disabled data-tip="requires sync:delete"
{{ end }}>
delete
</button>
</div>
</td>
</tr>
{{ end }}
</tbody>
</table>
</div>
</div>
{{ else if not .Data.FlashError }}
<div class="card bg-base-100 border border-base-300 py-10">
<div
class="flex flex-col items-center gap-2 text-center text-sm text-base-content/70">
{{ if .Data.Query }}
<span class="text-xl" aria-hidden="true">🔍</span>
<p>No syncs match "{{ .Data.Query }}"</p>
<button
class="btn btn-xs btn-outline transition-transform duration-150 active:scale-95"
onclick="const s = document.getElementById('page-search'); if (s) s.value = ''"
hx-get="{{ .AppPath }}/syncs"
hx-vals='{"query": ""}'
hx-target="#sync-rows"
hx-swap="innerHTML transition:true"
hx-push-url="true"
hx-indicator="#page-progress">
Clear search
</button>
{{ else }}
<span class="text-xl" aria-hidden="true">🔄</span>
<p>No sync sources configured yet</p>
<p class="text-xs text-base-content/70">
Manage apps declaratively - point OpenRun at a git repo
with app declarations
</p>
<a
class="btn btn-xs btn-primary transition-transform duration-150 active:scale-95 {{ if not (index .Data.Perms "sync:create") }}
btn-disabled tooltip tooltip-top
{{ end }}"
{{ if index .Data.Perms "sync:create" }}
href="{{ .AppPath }}/syncs/create"
{{ else }}
data-tip="requires sync:create"
{{ end }}
>+ Add sync source</a
>
{{ end }}
</div>
</div>
{{ end }}
{{ end }}
<!-- End of "sync_rows" block -->
</div>
</main>
</div>
{{ template "sidebar" . }}
</div>
</body>
</html>