feat(licenses): double confirmation modals for permanent deletion (#391)

Replace link-action delete buttons with show-modal pattern that opens
a Fomantic UI modal with a form. Package deletion requires typing
the package name in a required field before the submit button works.
Key deletion shows a warning modal with confirmation.

Uses Gitea's existing form-fetch-action + modal_actions_confirm
pattern, matching how repo deletion works in settings.

Both repo and org templates updated with matching modals.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jonathan Miller
2026-06-01 05:23:56 -05:00
parent 3e8124a2b7
commit 93d18ab25f
3 changed files with 69 additions and 6 deletions
+3
View File
@@ -2707,6 +2707,9 @@
"repo.licenses.repo_scope": "Repository Scope",
"repo.licenses.repo_scope_all": "All repositories in this organization",
"repo.licenses.repo_scope_help": "Which repositories this package's keys can access. Select a specific repo or allow all.",
"repo.licenses.confirm_delete_package_typed": "This will permanently delete the package and may orphan associated keys. This action cannot be undone.",
"repo.licenses.confirm_delete_key_typed": "This will permanently remove the license key record. The licensee will immediately lose access.",
"repo.licenses.type_name_to_confirm": "Type the package name to confirm:",
"repo.settings.download_gating": "Download Gating",
"repo.settings.support_url": "Support / Product Page URL",
"repo.settings.support_url_help": "Shown when downloads are gated. Can point to your wiki, product page, or external support site.",
+32 -3
View File
@@ -131,7 +131,7 @@
{{svg "octicon-archive" 14}}
</button>
{{if $.CanDelete}}
<button class="ui tiny red button link-action" data-url="{{$.Org.HomeLink}}/-/licenses/packages/{{.ID}}/delete" data-modal-confirm="{{ctx.Locale.Tr "repo.licenses.confirm_delete_package"}}" title="{{ctx.Locale.Tr "repo.licenses.delete_package"}}">
<button class="ui tiny red button show-modal" data-modal="#license-delete-package-modal" data-modal-form.action="{{$.Org.HomeLink}}/-/licenses/packages/{{.ID}}/delete" title="{{ctx.Locale.Tr "repo.licenses.delete_package"}}">
{{svg "octicon-trash" 14}}
</button>
{{end}}
@@ -206,7 +206,7 @@
{{svg "octicon-x" 14}}
</button>
{{if $.CanDelete}}
<button class="ui tiny red button link-action" data-url="{{$.Org.HomeLink}}/-/licenses/keys/{{.ID}}/delete" data-modal-confirm="{{ctx.Locale.Tr "repo.licenses.confirm_delete_key"}}" title="{{ctx.Locale.Tr "repo.licenses.delete_key"}}">
<button class="ui tiny red button show-modal" data-modal="#license-delete-key-modal" data-modal-form.action="{{$.Org.HomeLink}}/-/licenses/keys/{{.ID}}/delete" title="{{ctx.Locale.Tr "repo.licenses.delete_key"}}">
{{svg "octicon-trash" 14}}
</button>
{{end}}
@@ -246,7 +246,7 @@
{{svg "octicon-reply" 14}}
</button>
{{if $.CanDelete}}
<button class="ui tiny red button link-action" data-url="{{$.Org.HomeLink}}/-/licenses/packages/{{.ID}}/delete" data-modal-confirm="{{ctx.Locale.Tr "repo.licenses.confirm_delete_package"}}" title="{{ctx.Locale.Tr "repo.licenses.delete_package"}}">
<button class="ui tiny red button show-modal" data-modal="#license-delete-package-modal" data-modal-form.action="{{$.Org.HomeLink}}/-/licenses/packages/{{.ID}}/delete" title="{{ctx.Locale.Tr "repo.licenses.delete_package"}}">
{{svg "octicon-trash" 14}}
</button>
{{end}}
@@ -261,4 +261,33 @@
{{end}}
</div>
</div>
<div class="ui small modal" id="license-delete-package-modal">
<div class="header">{{svg "octicon-trash"}} {{ctx.Locale.Tr "repo.licenses.delete_package"}}</div>
<div class="content">
<div class="ui warning message">
<p>{{ctx.Locale.Tr "repo.licenses.confirm_delete_package_typed"}}</p>
</div>
<form class="ui form form-fetch-action" method="post">
<div class="required field">
<label>{{ctx.Locale.Tr "repo.licenses.type_name_to_confirm"}}</label>
<input name="confirm_name" required>
</div>
{{template "base/modal_actions_confirm" (dict "ModalButtonDangerText" (ctx.Locale.Tr "repo.licenses.delete_package"))}}
</form>
</div>
</div>
<div class="ui small modal" id="license-delete-key-modal">
<div class="header">{{svg "octicon-trash"}} {{ctx.Locale.Tr "repo.licenses.delete_key"}}</div>
<div class="content">
<div class="ui warning message">
<p>{{ctx.Locale.Tr "repo.licenses.confirm_delete_key_typed"}}</p>
</div>
<form class="ui form form-fetch-action" method="post">
{{template "base/modal_actions_confirm" (dict "ModalButtonDangerText" (ctx.Locale.Tr "repo.licenses.delete_key"))}}
</form>
</div>
</div>
{{template "base/footer" .}}
+34 -3
View File
@@ -70,7 +70,7 @@
{{svg "octicon-archive" 14}}
</button>
{{if $.CanDelete}}
<button class="ui tiny red button link-action" data-url="{{$.RepoLink}}/licenses/packages/{{.ID}}/delete" data-modal-confirm="{{ctx.Locale.Tr "repo.licenses.confirm_delete_package"}}" title="{{ctx.Locale.Tr "repo.licenses.delete_package"}}">
<button class="ui tiny red button show-modal" data-modal="#license-delete-package-modal" data-modal-form.action="{{$.RepoLink}}/licenses/packages/{{.ID}}/delete" title="{{ctx.Locale.Tr "repo.licenses.delete_package"}}">
{{svg "octicon-trash" 14}}
</button>
{{end}}
@@ -212,7 +212,7 @@
{{svg "octicon-x" 14}}
</button>
{{if $.CanDelete}}
<button class="ui tiny red button link-action" data-url="{{$.RepoLink}}/licenses/keys/{{.ID}}/delete" data-modal-confirm="{{ctx.Locale.Tr "repo.licenses.confirm_delete_key"}}" title="{{ctx.Locale.Tr "repo.licenses.delete_key"}}">
<button class="ui tiny red button show-modal" data-modal="#license-delete-key-modal" data-modal-form.action="{{$.RepoLink}}/licenses/keys/{{.ID}}/delete" title="{{ctx.Locale.Tr "repo.licenses.delete_key"}}">
{{svg "octicon-trash" 14}}
</button>
{{end}}
@@ -252,7 +252,7 @@
{{svg "octicon-reply" 14}}
</button>
{{if $.CanDelete}}
<button class="ui tiny red button link-action" data-url="{{$.RepoLink}}/licenses/packages/{{.ID}}/delete" data-modal-confirm="{{ctx.Locale.Tr "repo.licenses.confirm_delete_package"}}" title="{{ctx.Locale.Tr "repo.licenses.delete_package"}}">
<button class="ui tiny red button show-modal" data-modal="#license-delete-package-modal" data-modal-form.action="{{$.RepoLink}}/licenses/packages/{{.ID}}/delete" title="{{ctx.Locale.Tr "repo.licenses.delete_package"}}">
{{svg "octicon-trash" 14}}
</button>
{{end}}
@@ -301,4 +301,35 @@
{{end}}
</div>
</div>
{{/* Delete Package Confirmation Modal */}}
<div class="ui small modal" id="license-delete-package-modal">
<div class="header">{{svg "octicon-trash"}} {{ctx.Locale.Tr "repo.licenses.delete_package"}}</div>
<div class="content">
<div class="ui warning message">
<p>{{ctx.Locale.Tr "repo.licenses.confirm_delete_package_typed"}}</p>
</div>
<form class="ui form form-fetch-action" method="post">
<div class="required field">
<label>{{ctx.Locale.Tr "repo.licenses.type_name_to_confirm"}}</label>
<input name="confirm_name" required>
</div>
{{template "base/modal_actions_confirm" (dict "ModalButtonDangerText" (ctx.Locale.Tr "repo.licenses.delete_package"))}}
</form>
</div>
</div>
{{/* Delete Key Confirmation Modal */}}
<div class="ui small modal" id="license-delete-key-modal">
<div class="header">{{svg "octicon-trash"}} {{ctx.Locale.Tr "repo.licenses.delete_key"}}</div>
<div class="content">
<div class="ui warning message">
<p>{{ctx.Locale.Tr "repo.licenses.confirm_delete_key_typed"}}</p>
</div>
<form class="ui form form-fetch-action" method="post">
{{template "base/modal_actions_confirm" (dict "ModalButtonDangerText" (ctx.Locale.Tr "repo.licenses.delete_key"))}}
</form>
</div>
</div>
{{template "base/footer" .}}