-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig_page.go.html
More file actions
395 lines (386 loc) · 18.5 KB
/
Copy pathconfig_page.go.html
File metadata and controls
395 lines (386 loc) · 18.5 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
{{/* Copyright (c) ClaceIO, LLC */}}
{{/* SPDX-License-Identifier: Apache-2.0 */}}
{{/* Generic config sub page (/config/auth, /config/git, /config/secrets,
/config/system, /config/builder): settings fields with effective
values, entry section tables (oauth/saml/git_auth/...) and the
app_config key/value table. Driven by the CONFIG_PAGES descriptors in
handler.star; all changes take effect immediately (no staging).
HTMX partial: block page_content */}}
<!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 max-w-6xl">
<div id="page-content" class="space-y-4">
{{ block "page_content" . }}
{{ $actionPath := printf "%s/config/%s/action" .AppPath .Data.Page }}
{{ $canEdit := index .Data.Perms "config:update" }}
<!-- Header -->
<div class="page-header flex items-center gap-2 flex-wrap mb-2 md:mb-6">
{{ template "hamburger" . }}
<div>
{{ template "page_title" "OpenRun Configuration" }}
<nav aria-label="Breadcrumb" class="breadcrumbs text-xs text-base-content/70 p-0">
<ul>
<li>
<a href="{{ .AppPath }}/config">Configuration</a>
</li>
<li>{{ .Data.PageTitle }}</li>
</ul></nav>
<h2 class="text-xl font-semibold">{{ .Data.PageTitle }}</h2>
<p class="page-desc text-sm text-base-content/70">
{{ .Data.PageDesc }} - changes take effect immediately
</p>
</div>
</div>
{{ template "page_progress" }}
{{ if .Data.Error }}
{{ template "error_alert" .Data.Error }}
{{ else }}
{{ template "flash_alerts" .Data }}
{{ if .Data.Settings }}
<!-- Settings fields -->
<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">
<h2 class="text-sm font-medium">Settings</h2>
<span class="text-xs text-base-content/70"
>dynamic values override the static
<span class="font-mono">openrun.toml</span> value; clear
a field and save to reset</span
>
</div>
<div class="card-body p-4 gap-4">
{{ range .Data.Settings }}
{{ template "config_setting_row" (dict "Row" . "ActionPath" $actionPath "VersionId" $.Data.VersionId "CanEdit" $canEdit) }}
{{ end }}
{{ if .Data.AdvancedSettings }}
<details class="group">
<summary
class="cursor-pointer text-sm font-medium text-base-content/70 hover:text-base-content list-none flex items-center gap-1">
<span aria-hidden="true" class="inline-block transition-transform duration-200 group-open:rotate-90">›</span>
Additional settings
</summary>
<div class="flex flex-col gap-4 mt-4 pl-3 border-l border-base-300">
{{ range .Data.AdvancedSettings }}
{{ template "config_setting_row" (dict "Row" . "ActionPath" $actionPath "VersionId" $.Data.VersionId "CanEdit" $canEdit) }}
{{ end }}
</div>
</details>
{{ end }}
</div>
</div>
{{ end }}
<!-- Entry sections (oauth, saml, git auth) -->
{{ range .Data.Sections }}
<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">{{ .title }}</h2>
<span class="text-xs text-base-content/70">{{ .desc }}</span>
<a
class="btn btn-xs btn-outline ml-auto {{ if not $canEdit }}btn-disabled tooltip tooltip-left{{ end }}"
{{ if $canEdit }}
href="{{ $.AppPath }}/config/entry?section={{ .section }}"
{{ else }}
data-tip="requires config:update" aria-disabled="true" tabindex="-1"
{{ end }}
>+ Add entry</a
>
</div>
{{ $section := .section }}
{{ if .entries }}
<div class="overflow-x-auto">
<table class="table table-sm">
<tbody>
{{ range .entries }}
<tr class="group hover:bg-base-200/60">
<td
class="font-mono text-xs font-medium w-48 align-top">
{{ .name }}
</td>
<td class="w-40">
{{ if eq .source "static" }}
<span
class="badge badge-ghost badge-xs tooltip tooltip-left"
data-tip="from openrun.toml, read only - override creates a dynamic entry with the same name"
>static</span
>
{{ else if .overrides }}
<span
class="badge badge-soft badge-warning badge-xs tooltip tooltip-left"
data-tip="dynamic entry shadowing the static openrun.toml entry"
>overrides static</span
>
{{ else }}
<span class="badge badge-soft badge-primary badge-xs"
>dynamic</span
>
{{ end }}
</td>
<td class="text-xs text-base-content/70 break-all">
<span class="inline-block min-w-40">{{ .summary }}</span>
</td>
<td class="text-right whitespace-nowrap w-40">
<div class="inline-flex items-center gap-0.5">
<a
class="btn btn-xs btn-ghost {{ if not $canEdit }}btn-disabled tooltip tooltip-left{{ end }}"
{{ if $canEdit }}href="{{ $.AppPath }}/config/entry?section={{ $section }}&name={{ .name }}"{{ else }}data-tip="requires config:update" aria-disabled="true" tabindex="-1"{{ end }}
aria-label="{{ if eq .source "static" }}Override{{ else }}Edit{{ end }} {{ $section }} entry {{ .name }}"
>{{ if eq .source "static" }}override{{ else }}edit{{ end }}</a
>
{{ if ne .source "static" }}
<button
class="btn btn-xs btn-ghost text-error"
{{ if $canEdit }}
hx-post="{{ $actionPath }}"
aria-label="Delete {{ $section }} entry {{ .name }}"
hx-vals='{"action": "delete_entry", "section": "{{ $section }}", "name": "{{ .name }}", "version_id": "{{ $.Data.VersionId }}"}'
hx-confirm="Delete the dynamic entry {{ .name }}? The change is live immediately{{ if .overrides }} and the static entry from openrun.toml becomes active again{{ end }}."
hx-target="#page-content"
hx-swap="innerHTML transition:true"
hx-disabled-elt="this"
hx-indicator="#page-progress"
{{ else }}
disabled data-tip="requires config:update"
{{ end }}>
delete
</button>
{{ end }}
</div>
</td>
</tr>
{{ end }}
</tbody>
</table>
</div>
{{ else }}
<p class="text-xs text-base-content/70 px-4 py-3">
No entries configured
</p>
{{ end }}
</div>
{{ end }}
<!-- Free-form key/value overrides (app_config, node_config) -->
{{ range .Data.KVs }}
<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">
<h2 class="text-sm font-medium">{{ .title }}</h2>
<span class="text-xs text-base-content/70"
>{{ .help }}</span
>
</div>
<div class="card-body p-4 gap-3">
{{ $kv := . }}
{{ if .rows }}
<div class="overflow-x-auto">
<table class="table table-sm">
<thead>
<tr>
<th scope="col">Key</th>
<th scope="col">Value</th>
<th scope="col" class="text-right">Actions</th>
</tr>
</thead>
<tbody>
{{ range .rows }}
<tr class="group hover:bg-base-200/60">
<td class="font-mono text-xs font-medium">
{{ .key }}
</td>
<td class="font-mono text-xs">{{ .value }}</td>
<td class="text-right whitespace-nowrap w-24">
<button
class="btn btn-xs btn-ghost text-error"
{{ if $canEdit }}
hx-post="{{ $actionPath }}"
aria-label="Remove {{ $kv.section }} key {{ .key }}"
hx-vals='{"action": "kv_delete", "kv_section": "{{ $kv.section }}", "key": "{{ .key }}", "version_id": "{{ $.Data.VersionId }}"}'
hx-confirm="Remove the {{ $kv.section }} override {{ .key }}? Apps revert to the openrun.toml value on their next reload."
hx-target="#page-content"
hx-swap="innerHTML transition:true"
hx-disabled-elt="this"
hx-indicator="#page-progress"
{{ else }}
disabled data-tip="requires config:update"
{{ end }}>
delete
</button>
</td>
</tr>
{{ end }}
</tbody>
</table>
</div>
{{ else }}
<p class="text-xs text-base-content/70">
No overrides configured
</p>
{{ end }}
<form
hx-post="{{ $actionPath }}"
hx-target="#page-content"
hx-swap="innerHTML transition:true"
hx-indicator="#page-progress"
class="flex items-center gap-2 flex-wrap">
<input type="hidden" name="action" value="kv_set" />
<input type="hidden" name="kv_section" value="{{ .section }}" />
<input type="hidden" name="version_id" value="{{ $.Data.VersionId }}" />
<input
name="key"
type="text"
required
placeholder="{{ .placeholder }}"
aria-label="{{ .section }} key"
class="input input-sm w-64 font-mono text-xs" />
<div class="flex-1 min-w-40">
{{ template "secret_input" (dict "Name" "value"
"AppPath" $.AppPath
"Prefix" .section
"CanCreate" (index $.Data.Perms "secret:create")
"CanDelete" (index $.Data.Perms "secret:delete")
"Small" true
"Placeholder" "value") }}
</div>
<button
type="submit"
class="btn btn-xs btn-outline {{ if not $canEdit }}tooltip tooltip-left{{ end }}"
{{ if not $canEdit }}disabled data-tip="requires config:update"{{ end }}>
+ Set key
</button>
</form>
</div>
</div>
{{ end }}
{{ end }}
{{ end }}
<!-- End of "page_content" block -->
</div>
</main>
</div>
{{ template "sidebar" . }}
</div>
</body>
</html>
{{/* config_setting_row: one settings field form. Page-local define (used
only by this file's page_content block). Context dict: Row (the setting
row), ActionPath, VersionId, CanEdit */}}
{{ define "config_setting_row" }}
{{ $row := .Row }}
{{ $canEdit := .CanEdit }}
<form
hx-post="{{ .ActionPath }}"
hx-target="#page-content"
hx-swap="innerHTML transition:true"
hx-indicator="#page-progress"
class="flex items-start gap-3 flex-wrap">
<input type="hidden" name="action" value="set_value" />
<input type="hidden" name="section" value="{{ $row.section }}" />
<input type="hidden" name="key" value="{{ $row.key }}" />
<input type="hidden" name="kind" value="{{ $row.kind }}" />
<input type="hidden" name="version_id" value="{{ .VersionId }}" />
<input type="hidden" name="is_dynamic" value="{{ if $row.is_dynamic }}true{{ else }}false{{ end }}" />
<div class="w-56 pt-1.5">
<label class="text-sm font-medium" for="setting-{{ $row.section }}-{{ $row.key }}"
>{{ $row.label }}</label
>
<div class="text-[11px] text-base-content/70 font-mono">
{{ $row.section }}.{{ $row.key }}
</div>
</div>
<div class="flex-1 min-w-52">
{{ if eq $row.kind "bool" }}
<input
id="setting-{{ $row.section }}-{{ $row.key }}"
type="checkbox"
name="value"
class="toggle toggle-sm toggle-primary mt-1.5"
{{ if $row.value }}checked{{ end }}
{{ if not $canEdit }}disabled{{ end }} />
{{ else if eq $row.kind "select" }}
<select
id="setting-{{ $row.section }}-{{ $row.key }}"
name="value"
class="select select-sm w-full font-mono text-xs min-w-0"
{{ if not $canEdit }}disabled{{ end }}>
<option value="" {{ if not $row.value }}selected{{ end }}>
(not set)
</option>
{{ $current := $row.value }}
{{ range $row.option_list }}
<option
value="{{ . }}"
{{ if eq . $current }}selected{{ end }}>
{{ . }}
</option>
{{ end }}
{{ if $current }}
{{ $found := false }}
{{ range $row.option_list }}
{{ if eq . $current }}{{ $found = true }}{{ end }}
{{ end }}
{{ if not $found }}
<option value="{{ $current }}" selected>{{ $current }} (not found)</option>
{{ end }}
{{ end }}
</select>
{{ else if eq $row.kind "textarea" }}
<textarea
id="setting-{{ $row.section }}-{{ $row.key }}"
name="value"
rows="4"
class="textarea w-full font-mono text-xs leading-relaxed"
{{ if not $canEdit }}disabled{{ end }}>{{ $row.value }}</textarea>
{{ else }}
<input
id="setting-{{ $row.section }}-{{ $row.key }}"
name="value"
type="text"
value="{{ $row.value }}"
class="input input-sm w-full font-mono text-xs"
{{ if not $canEdit }}disabled{{ end }} />
{{ end }}
{{ if $row.help }}
<p class="text-xs text-base-content/70 mt-1">
{{ $row.help }}
</p>
{{ end }}
</div>
<div class="flex items-center gap-1 pt-0.5">
{{ if $row.is_dynamic }}
<span
class="badge badge-soft badge-primary badge-xs tooltip tooltip-left"
data-tip="dynamic value, overrides openrun.toml{{ if $row.static_value }} ({{ $row.static_value }}){{ end }}"
>dynamic</span
>
{{ end }}
<button
type="submit"
class="btn btn-xs btn-outline {{ if not $canEdit }}tooltip tooltip-left{{ end }}"
{{ if not $canEdit }}disabled data-tip="requires config:update"{{ end }}>
Save
</button>
{{ if $row.is_dynamic }}
<button
type="button"
class="btn btn-xs btn-ghost tooltip tooltip-left"
data-tip="remove the dynamic value, revert to openrun.toml"
{{ if $canEdit }}
hx-post="{{ .ActionPath }}"
hx-vals='{"action": "delete_value", "section": "{{ $row.section }}", "key": "{{ $row.key }}", "version_id": "{{ .VersionId }}"}'
hx-target="#page-content"
hx-swap="innerHTML transition:true"
hx-indicator="#page-progress"
{{ else }}
disabled
{{ end }}>
reset
</button>
{{ end }}
</div>
</form>
{{ end }}