mirror of
https://tangled.org/evan.jarrett.net/at-container-registry
synced 2026-08-29 04:06:58 +00:00
fix tag deletion in UI
This commit is contained in:
@@ -109,7 +109,7 @@
|
||||
{{ if .Tags }}
|
||||
<div class="tags-list">
|
||||
{{ range .Tags }}
|
||||
<div class="tag-item" id="tag-{{ .Tag.Tag }}">
|
||||
<div class="tag-item" id="tag-{{ sanitizeID .Tag.Tag }}">
|
||||
<div class="tag-item-header">
|
||||
<div>
|
||||
<span class="tag-name-large">{{ .Tag.Tag }}</span>
|
||||
@@ -125,7 +125,7 @@
|
||||
<button class="delete-btn"
|
||||
hx-delete="/api/images/{{ $.Repository.Name }}/tags/{{ .Tag.Tag }}"
|
||||
hx-confirm="Delete tag {{ .Tag.Tag }}?"
|
||||
hx-target="#tag-{{ .Tag.Tag }}"
|
||||
hx-target="#tag-{{ sanitizeID .Tag.Tag }}"
|
||||
hx-swap="outerHTML">
|
||||
<i data-lucide="trash-2"></i>
|
||||
</button>
|
||||
|
||||
+5
-2
@@ -85,9 +85,12 @@ func Templates() (*template.Template, error) {
|
||||
},
|
||||
|
||||
"sanitizeID": func(s string) string {
|
||||
// Replace colons with dashes to make valid CSS selectors
|
||||
// Replace special CSS selector characters with dashes
|
||||
// e.g., "sha256:abc123" becomes "sha256-abc123"
|
||||
return strings.ReplaceAll(s, ":", "-")
|
||||
// e.g., "v0.0.2" becomes "v0-0-2"
|
||||
s = strings.ReplaceAll(s, ":", "-")
|
||||
s = strings.ReplaceAll(s, ".", "-")
|
||||
return s
|
||||
},
|
||||
|
||||
"parseLicenses": func(licensesStr string) []licenses.LicenseInfo {
|
||||
|
||||
@@ -483,6 +483,21 @@ func TestSanitizeID(t *testing.T) {
|
||||
input: "abc:",
|
||||
expected: "abc-",
|
||||
},
|
||||
{
|
||||
name: "version tag with periods",
|
||||
input: "v0.0.2",
|
||||
expected: "v0-0-2",
|
||||
},
|
||||
{
|
||||
name: "colons and periods",
|
||||
input: "sha256:abc.def",
|
||||
expected: "sha256-abc-def",
|
||||
},
|
||||
{
|
||||
name: "only period",
|
||||
input: ".",
|
||||
expected: "-",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
|
||||
Reference in New Issue
Block a user