fix tag deletion in UI

This commit is contained in:
Evan Jarrett
2025-11-24 13:51:00 -06:00
parent fb7ddd0d53
commit 88df0c4ae5
3 changed files with 22 additions and 4 deletions
+2 -2
View File
@@ -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
View File
@@ -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 {
+15
View File
@@ -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 {