-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbinding_form.go.html
More file actions
253 lines (237 loc) · 10.4 KB
/
Copy pathbinding_form.go.html
File metadata and controls
253 lines (237 loc) · 10.4 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
{{/* Copyright (c) ClaceIO, LLC */}}
{{/* SPDX-License-Identifier: Apache-2.0 */}}
{{/* Binding create/update form (/bindings/create, /bindings/update).
Updates edit the staged grants as a textarea diff */}}
<!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-2xl">
<!-- Header -->
<div class="page-header flex items-center gap-2 flex-wrap mb-2 md:mb-6">
{{ template "hamburger" . }}
<div>
{{ template "page_title" "OpenRun Bindings" }}
<nav aria-label="Breadcrumb" class="breadcrumbs text-xs text-base-content/70 p-0"><ul><li><a href="{{ .AppPath }}/bindings">Bindings</a></li><li>{{ if eq .Data.Mode "create" }}new{{ else }}edit{{ end }}</li></ul></nav>
<h2 class="text-xl font-semibold">
{{ if eq .Data.Mode "create" }}
New binding
{{ else }}
Update
<span class="font-mono">{{ .Data.Values.path }}</span>
{{ end }}
</h2>
<p class="page-desc text-sm text-base-content/70">
{{ if eq .Data.Mode "create" }}
Bind apps to a service or a base binding
{{ else }}
Grant changes apply to staging and are promoted to prod
{{ end }}
</p>
</div>
</div>
{{ template "page_progress" }}
{{ block "op_form" . }}
<div id="op-form-wrap">
{{ template "error_alert" .Data.Error }}
{{ template "validation_alert" (dict
"Validated" .Data.Validated
"Value" .Data.Values.path
"Suffix" "is ready to be created") }}
{{ if and (eq .Data.Mode "update") (not .Data.Binding) }}
<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">
<span class="text-xl" aria-hidden="true">🔍</span>
<p>The binding could not be loaded</p>
<a class="btn btn-xs btn-outline" href="{{ .AppPath }}/bindings"
>Back to bindings</a
>
</div>
</div>
{{ else }}
{{ if eq .Data.Mode "update" }}
<!-- Current binding summary -->
<div class="card bg-base-100 border border-base-300">
<div
class="px-4 py-3 grid grid-cols-2 sm:grid-cols-3 gap-x-6 gap-y-1 text-sm">
<div>
<div class="text-xs text-base-content/70">Source</div>
<div
class="font-mono text-xs truncate"
title="{{ .Data.Binding.source }}">
{{ .Data.Binding.source }}
</div>
</div>
<div>
<div class="text-xs text-base-content/70">Base binding</div>
<div class="font-mono text-xs break-all">
{{ if .Data.Binding.derived_from }}
{{ .Data.Binding.derived_from }}
{{ else }}
-
{{ end }}
</div>
</div>
<div>
<div class="text-xs text-base-content/70">Service</div>
<div class="font-mono text-xs break-all">
{{ .Data.Binding.service_type }}{{ if .Data.Binding.service_name }}/{{ .Data.Binding.service_name }}{{ end }}
</div>
</div>
</div>
</div>
{{ end }}
<form
method="post"
action="{{ .AppPath }}/bindings/{{ .Data.Mode }}"
id="op-form"
hx-post="{{ .AppPath }}/bindings/{{ .Data.Mode }}"
hx-target="#op-form-wrap"
hx-swap="outerHTML"
hx-indicator="#page-progress, #op-form"
class="card bg-base-100 border border-base-300">
<div class="card-body p-5 gap-5">
{{ if eq .Data.Mode "create" }}
<div class="space-y-4">
<div>
<label
class="block text-sm font-medium mb-1"
for="binding-path"
>Binding path</label
>
<input
id="binding-path"
name="path"
type="text"
required
value="{{ .Data.Values.path }}"
placeholder="/db/main"
class="input w-full font-mono text-sm" />
<p class="text-xs text-base-content/70 mt-1">
Unique path apps use to reference this binding
</p>
</div>
<div>
<label
class="block text-sm font-medium mb-1"
for="binding-source"
>Source</label
>
<input
id="binding-source"
name="source"
type="text"
required
value="{{ .Data.Values.source }}"
placeholder="postgres/main or /base/binding"
class="input w-full font-mono text-sm" />
<p class="text-xs text-base-content/70 mt-1">
A service id (type/name) for a base binding, or an
existing binding path to derive from
</p>
</div>
</div>
<div class="divider my-0"></div>
{{ else }}
<input
type="hidden"
name="path"
value="{{ .Data.Values.path }}" />
{{ end }}
<div class="space-y-4">
<div>
<label
class="block text-sm font-medium mb-1"
for="binding-grants"
>Grants</label
>
<textarea
id="binding-grants"
name="grants_text"
rows="4"
spellcheck="false"
placeholder="read:* full:/tools/**"
class="textarea w-full font-mono text-sm leading-relaxed">{{ .Data.Values.grants_text }}</textarea>
<p class="text-xs text-base-content/70 mt-1">
One type:target grant per line, for derived bindings
only.
{{ if eq .Data.Mode "update" }}
Removing a line deletes the grant.
{{ end }}
</p>
</div>
{{ if eq .Data.Mode "create" }}
<div>
<span class="block text-sm font-medium mb-1">Config</span>
{{ template "kv_table" (dict "Field" "config"
"AppPath" .AppPath
"Prefix" "binding"
"CanCreate" (index .Data.Perms "secret:create")
"CanDelete" (index .Data.Perms "secret:delete")
"Rows" .Data.Values.config_rows
"KeyPlaceholder" "timeout"
"ValuePlaceholder" "30"
"AddLabel" "Add config entry") }}
<p class="text-xs text-base-content/70 mt-1">
Config overrides for this binding. The lock button
encrypts a value into the secrets store and uses the
secret reference instead
</p>
</div>
{{ end }}
</div>
<div class="card-actions justify-end pt-2">
<a
href="{{ .AppPath }}/bindings"
class="btn btn-ghost btn-sm"
>Cancel</a
>
{{ if eq .Data.Mode "create" }}
<button
type="submit"
name="action"
value="validate"
{{ if index .Data.Perms "binding:create" }}
data-tip="Dry run: check the binding without creating it"
{{ else }}
disabled data-tip="requires binding:create"
{{ end }}
class="btn btn-outline btn-sm transition-transform duration-150 active:scale-95 tooltip tooltip-top">
Validate
</button>
<button
type="submit"
name="action"
value="create"
{{ if not (index .Data.Perms "binding:create") }}
disabled data-tip="requires binding:create"
{{ end }}
class="btn btn-primary btn-sm transition-transform duration-150 active:scale-95 {{ if not (index .Data.Perms "binding:create") }}tooltip tooltip-top{{ end }}">
Create binding
</button>
{{ else }}
<button
type="submit"
{{ if not (index .Data.Perms "binding:update") }}
disabled data-tip="requires binding:update"
{{ end }}
class="btn btn-primary btn-sm transition-transform duration-150 active:scale-95 {{ if not (index .Data.Perms "binding:update") }}tooltip tooltip-top{{ end }}">
Save changes
</button>
{{ end }}
</div>
</div>
</form>
{{ end }}
</div>
{{ end }}
</main>
</div>
{{ template "sidebar" . }}
</div>
</body>
</html>