-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapps.go.html
More file actions
449 lines (435 loc) · 20.1 KB
/
Copy pathapps.go.html
File metadata and controls
449 lines (435 loc) · 20.1 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
{{/* Copyright (c) ClaceIO, LLC */}}
{{/* SPDX-License-Identifier: Apache-2.0 */}}
{{/* Apps list page (/apps): apps grouped by their managing sync plus an
unmanaged section, count stats double as declarative/imperative filters.
HTMX partial: block app_groups
*/}}
<!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 Apps" }}
<p class="page-desc text-sm text-base-content/70">
Deployed apps, grouped by the sync source
</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 apps"
title="Substring search; a leading /, a :, or "all" switches to app path globs like /utils/** or example.com:/**"
value="{{ .Data.Query }}"
placeholder="Filter apps…"
hx-get="{{ .AppPath }}/apps"
hx-trigger="input changed delay:300ms, search"
hx-push-url="true"
hx-target="#app-groups"
hx-swap="innerHTML"
hx-include="#app-filter-value, #app-tab-value"
hx-indicator="#page-progress" />
</label>
<a
class="btn btn-sm btn-primary transition-transform duration-150 active:scale-95 {{ if not (index .Data.Perms "app:create") }}
btn-disabled tooltip tooltip-bottom
{{ end }}"
{{ if index .Data.Perms "app:create" }}
href="{{ .AppPath }}/apps/create"
{{ else }}
data-tip="requires app:create" aria-disabled="true"
tabindex="-1"
{{ end }}>
+ New app
</a>
</div>
</div>
{{ template "page_progress" }}
<!-- Apps grouped by the sync entry which last applied them -->
<div id="app-groups" class="space-y-4">
{{ block "app_groups" . }}
<!-- Filter chips -->
<div class="flex items-center gap-2 flex-wrap">
<input
type="hidden"
id="app-filter-value"
name="filter"
value="{{ .Data.Filter }}" />
<!-- Count stats double as the source filter -->
<div
role="group"
aria-label="Filter apps by source"
class="stats stats-horizontal bg-base-100 border border-base-300 overflow-x-auto">
<button
class="stat py-2 px-5 place-items-start cursor-pointer transition-colors duration-150 hover:bg-base-200/60 tooltip tooltip-bottom {{ if eq .Data.Filter "" }}
bg-primary/5
{{ end }}"
data-filter=""
hx-get="{{ .AppPath }}/apps"
hx-vals='{"filter": ""}'
hx-include="#page-search, #app-tab-value"
hx-target="#app-groups"
hx-swap="innerHTML"
hx-push-url="true"
hx-indicator="#page-progress"
aria-pressed="{{ if eq .Data.Filter "" -}}
true
{{- else -}}
false
{{- end }}"
data-tip="Show all apps">
<div class="stat-title text-xs">All apps</div>
<div
class="stat-value text-xl tabular-nums {{ if eq .Data.Filter "" }}
text-primary
{{ end }}">
{{ .Data.Total }}
</div>
</button>
<button
class="stat py-2 px-5 place-items-start cursor-pointer transition-colors duration-150 hover:bg-base-200/60 tooltip tooltip-bottom {{ if eq .Data.Filter "declarative" }}
bg-primary/5
{{ end }}"
data-filter="declarative"
hx-get="{{ .AppPath }}/apps"
hx-vals='{"filter": "declarative"}'
hx-include="#page-search, #app-tab-value"
hx-target="#app-groups"
hx-swap="innerHTML"
hx-push-url="true"
hx-indicator="#page-progress"
aria-pressed="{{ if eq .Data.Filter "declarative" -}}
true
{{- else -}}
false
{{- end }}"
data-tip="Apps managed by a sync source">
<div class="stat-title text-xs">Declarative</div>
<div
class="stat-value text-xl tabular-nums {{ if eq .Data.Filter "declarative" }}
text-primary
{{ end }}">
{{ .Data.DeclarativeCount }}
</div>
</button>
<button
class="stat py-2 px-5 place-items-start cursor-pointer transition-colors duration-150 hover:bg-base-200/60 tooltip tooltip-bottom {{ if eq .Data.Filter "imperative" }}
bg-primary/5
{{ end }}"
data-filter="imperative"
hx-get="{{ .AppPath }}/apps"
hx-vals='{"filter": "imperative"}'
hx-include="#page-search, #app-tab-value"
hx-target="#app-groups"
hx-swap="innerHTML"
hx-push-url="true"
hx-indicator="#page-progress"
aria-pressed="{{ if eq .Data.Filter "imperative" -}}
true
{{- else -}}
false
{{- end }}"
data-tip="Apps created via UI/CLI">
<div class="stat-title text-xs">Imperative</div>
<div
class="stat-value text-xl tabular-nums {{ if eq .Data.Filter "imperative" }}
text-primary
{{ end }}">
{{ .Data.ImperativeCount }}
</div>
</button>
</div>
</div>
<!-- Current tab, included by the search/filter/action requests
so partial refreshes stay on the active tab -->
<input
type="hidden"
id="app-tab-value"
name="tab"
value="{{ .Data.Tab }}" />
<!-- Tabs: the full list vs the apps waiting on promote/approve.
Inside the partial so the active state and counts refresh
with every swap -->
<div
role="group"
aria-label="App list views"
class="tabs tabs-border">
<button
class="tab transition-colors duration-150 {{ if eq .Data.Tab "" }}
tab-active
{{ end }}"
data-tab=""
aria-pressed="{{ if eq .Data.Tab "" -}}
true
{{- else -}}
false
{{- end }}"
hx-get="{{ .AppPath }}/apps"
hx-vals='{"tab": ""}'
hx-target="#app-groups"
hx-swap="innerHTML"
hx-include="#page-search, #app-filter-value"
hx-push-url="true"
hx-indicator="#page-progress">
All
</button>
<button
class="tab transition-colors duration-150 {{ if eq .Data.Tab "promote" }}
tab-active
{{ end }}"
data-tab="promote"
aria-pressed="{{ if eq .Data.Tab "promote" -}}
true
{{- else -}}
false
{{- end }}"
title="Apps where staging has changes not promoted to prod yet"
hx-get="{{ .AppPath }}/apps"
hx-vals='{"tab": "promote"}'
hx-target="#app-groups"
hx-swap="innerHTML"
hx-include="#page-search, #app-filter-value"
hx-push-url="true"
hx-indicator="#page-progress">
Pending promotion
<span
class="badge badge-xs tabular-nums ml-1 {{ if .Data.PromoteCount }}
badge-warning badge-soft
{{ else }}
badge-ghost
{{ end }}"
>{{ .Data.PromoteCount }}</span
>
</button>
<button
class="tab transition-colors duration-150 {{ if eq .Data.Tab "approval" }}
tab-active
{{ end }}"
data-tab="approval"
aria-pressed="{{ if eq .Data.Tab "approval" -}}
true
{{- else -}}
false
{{- end }}"
title="Apps requesting plugin permissions which are not approved yet"
hx-get="{{ .AppPath }}/apps"
hx-vals='{"tab": "approval"}'
hx-target="#app-groups"
hx-swap="innerHTML"
hx-include="#page-search, #app-filter-value"
hx-push-url="true"
hx-indicator="#page-progress">
Needs approval
<span
class="badge badge-xs tabular-nums ml-1 {{ if .Data.ApprovalCount }}
badge-error badge-soft
{{ else }}
badge-ghost
{{ end }}"
>{{ .Data.ApprovalCount }}</span
>
</button>
</div>
{{ template "flash_alerts" .Data }}
{{ if .Data.SyncResult }}
{{ template "sync_result" .Data.SyncResult }}
{{ end }}
{{ if eq .Data.Tab "promote" }}
<!-- Pending promotion tab: flat list, row action promotes -->
<div class="card bg-base-100 border border-base-300">
<div
class="px-4 py-2.5 border-b border-base-300 flex items-center gap-2 flex-wrap">
<h2 class="text-sm font-medium">Pending promotion</h2>
<span class="text-xs text-base-content/70"
>staging has changes which are not promoted to prod
yet</span
>
</div>
{{ if .Data.TabApps }}
{{ template "app_table" (dict "Apps" .Data.TabApps "AppPath" .AppPath "Perms" .Data.Perms "ShowActions" true "RowAction" "promote") }}
{{ else }}
<div
class="flex flex-col items-center gap-2 py-10 text-center text-sm text-base-content/70">
<span class="text-xl" aria-hidden="true">✅</span>
<p>
{{ if or .Data.Query .Data.Filter }}
No matching apps are pending promotion
{{ else }}
Nothing to promote - prod matches staging for all apps
{{ end }}
</p>
</div>
{{ end }}
</div>
{{ else if eq .Data.Tab "approval" }}
<!-- Needs approval tab: flat list, row action approves -->
<div class="card bg-base-100 border border-base-300">
<div
class="px-4 py-2.5 border-b border-base-300 flex items-center gap-2 flex-wrap">
<h2 class="text-sm font-medium">Needs approval</h2>
<span class="text-xs text-base-content/70"
>apps requesting plugin permissions which are not approved
yet</span
>
</div>
{{ if .Data.TabApps }}
{{ template "app_table" (dict "Apps" .Data.TabApps "AppPath" .AppPath "Perms" .Data.Perms "ShowActions" true "RowAction" "approve") }}
{{ else }}
<div
class="flex flex-col items-center gap-2 py-10 text-center text-sm text-base-content/70">
<span class="text-xl" aria-hidden="true">✅</span>
<p>
{{ if or .Data.Query .Data.Filter }}
No matching apps are waiting on permission approval
{{ else }}
No apps are waiting on permission approval
{{ end }}
</p>
</div>
{{ end }}
</div>
{{ else }}
{{ range .Data.Groups }}
<div class="card bg-base-100 border border-base-300">
<div
class="px-4 py-2.5 border-b border-base-300 flex items-center gap-2 flex-wrap">
{{ if eq .sync.state "Failing" }}
<span class="status status-error"></span>
{{ else if eq .sync.state "Disabled" }}
<span class="status status-warning"></span>
{{ else }}
<span class="status status-success"></span>
{{ end }}
<h2 class="font-mono text-sm font-medium break-all">
{{ .sync.repo }}
</h2>
{{ if .sync.branch }}
<span class="badge badge-ghost badge-xs"
>{{ .sync.branch }}</span
>
{{ end }}
<span class="text-xs text-base-content/70">
{{ len .apps }}
apps{{ if .sync.last_exec }}
· synced
{{ template "time_ago" .sync.last_exec }}
{{ end }}
</span>
<div class="ml-auto flex items-center gap-2">
<a
href="{{ $.AppPath }}/syncs/detail?id={{ .sync.id }}"
class="link link-hover text-xs text-primary"
aria-label="Sync detail for {{ .sync.repo }}"
>sync detail <span aria-hidden="true">→</span></a
>
<button
class="btn btn-xs btn-primary btn-soft transition-transform duration-150 active:scale-95 {{ if not (index $.Data.Perms "sync:run") }}
tooltip tooltip-top
{{ end }}"
{{ if index $.Data.Perms "sync:run" }}
hx-post="{{ $.AppPath }}/apps/sync"
hx-disabled-elt="this" hx-vals='{"sync_id":
"{{ .sync.id }}"}' hx-target="#app-groups"
hx-swap="innerHTML transition:true"
hx-include="#page-search, #app-filter-value,
#app-tab-value" hx-indicator="#page-progress"
{{ else }}
disabled data-tip="requires sync:run"
{{ end }}>
Sync now
</button>
</div>
</div>
{{ template "app_table" (dict "Apps" .apps "AppPath" $.AppPath "Perms" $.Data.Perms "ShowActions" true) }}
</div>
{{ end }}
{{ if .Data.Unmanaged }}
<div
class="card bg-base-100 border border-dashed border-base-300">
<div
class="px-4 py-2.5 border-b border-base-300 flex items-center gap-2 flex-wrap">
<h2 class="text-sm font-medium">Unmanaged apps</h2>
<span class="text-xs text-base-content/70"
>created via UI/CLI - not applied by any sync
source</span
>
</div>
{{ template "app_table" (dict "Apps" .Data.Unmanaged "AppPath" .AppPath "Perms" .Data.Perms "ShowActions" true) }}
</div>
{{ end }}
{{ if and (not .Data.Groups) (not .Data.Unmanaged) }}
<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 or .Data.Query .Data.Filter }}
<span class="text-xl" aria-hidden="true">🔍</span>
<p>
No apps match
{{ if .Data.Query }}
"{{ .Data.Query }}"
{{ else }}
the current filter
{{ end }}
</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 }}/apps"
hx-vals='{"query": "", "filter": ""}'
hx-include="#app-tab-value"
hx-target="#app-groups"
hx-swap="innerHTML"
hx-push-url="true"
hx-indicator="#page-progress">
Clear filters
</button>
{{ else }}
<span class="text-xl" aria-hidden="true">🌱</span>
<p>No apps installed yet</p>
<a
class="btn btn-xs btn-primary transition-transform duration-150 active:scale-95 {{ if not (index .Data.Perms "app:create") }}
btn-disabled tooltip tooltip-top
{{ end }}"
{{ if index .Data.Perms "app:create" }}
href="{{ .AppPath }}/apps/create"
{{ else }}
data-tip="requires app:create" aria-disabled="true"
tabindex="-1"
{{ end }}
>+ New app</a
>
{{ end }}
</div>
</div>
{{ end }}
{{ end }}
<!-- End of tab content branches -->
{{ end }}
<!-- End of "app_groups" block -->
</div>
{{ template "reload_dialog" (dict
"PostUrl" (print .AppPath "/apps/reload")
"Target" "#app-groups"
"Include" "#page-search, #app-filter-value, #app-tab-value"
"Perms" .Data.Perms)
}}
</main>
</div>
{{ template "sidebar" . }}
</div>
</body>
</html>