Repository navigation
Expand file tree
/
Copy pathconfig_page.go.html
More file actions
249 lines (244 loc) · 13.9 KB
/
Copy pathconfig_page.go.html
File metadata and controls
249 lines (244 loc) · 13.9 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
{{/* Copyright (c) ClaceIO, LLC */}}
{{/* SPDX-License-Identifier: Apache-2.0 */}}
{{/* Generic config sub page (/config/auth, /config/git, /config/secrets,
/config/system, /config/builder; /config/api and /config/mcp have
their own files around the same defines): settings fields with
effective values, grouped settings cards,
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 */}}
{{ template "page_open" (dict "Ctx" . "Main" "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" (dict "Title" "Configuration" "Help" .Data.HelpUrl) }}
<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 }}
</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-x-2 gap-y-1 flex-wrap sm:flex-nowrap">
<h2 class="text-sm font-medium shrink-0">Settings</h2>
<span class="text-xs text-base-content/70 basis-full sm:basis-auto"
>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 }}
{{ template "config_advanced_rows" (dict "Rows" .Data.AdvancedSettings "ActionPath" $actionPath "VersionId" $.Data.VersionId "CanEdit" $canEdit) }}
</div>
</div>
{{ end }}
<!-- Settings groups (one card per remote API surface) -->
{{ template "config_setting_groups" (dict "Groups" .Data.SettingGroups "ActionPath" $actionPath "VersionId" .Data.VersionId "CanEdit" $canEdit) }}
<!-- 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-start gap-x-2 gap-y-1 flex-wrap sm:flex-nowrap">
{{/* Phone: title and button on the first line, the
description full width below. From sm: one line, the
description wrapping inside its own box */}}
<h2 class="text-sm font-medium shrink-0">{{ .title }}</h2>
<span class="text-xs text-base-content/70 order-last basis-full sm:order-none sm:basis-0 sm:flex-1 min-w-0 sm:pt-0.5">{{ .desc }}</span>
{{ template "perm_link" (dict "Allowed" $canEdit "Href" (print $.AppPath "/config/entry") "QueryKey" "section" "QueryValue" .section "Label" "+ Add entry" "Class" "btn-xs btn-outline ml-auto shrink-0" "DeniedTip" "requires config:update" "Pos" "tooltip-left") }}
</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 sm:w-48 break-all">
{{ .name }}
</td>
<td class="sm:w-40">
{{ if eq .source "static" }}
<span
class="badge badge-ghost badge-xs tooltip tooltip-right"
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-right"
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>
{{/* The summary is detail: from sm up only, a phone keeps
the name, the source badge and the row actions */}}
<td class="text-xs text-base-content/70 break-all hidden sm:table-cell">
<span class="inline-block min-w-40">{{ .summary }}</span>
</td>
<td class="text-right whitespace-nowrap sm: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 not ($canEdit) }}tooltip tooltip-left{{ end }}"
{{ 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"
hx-disable="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-x-2 gap-y-1 flex-wrap sm:flex-nowrap">
<h2 class="text-sm font-medium shrink-0">{{ .title }}</h2>
<span class="text-xs text-base-content/70 basis-full sm:basis-auto"
>{{ .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 not ($canEdit) }}tooltip tooltip-left{{ end }}"
{{ 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"
hx-disable="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"
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>
{{ template "page_close" . }}