Files
gitea/templates/user/settings/security/webauthn.tmpl
T
silverwindandwxiaoguang e645afbb3f refactor: replace Fomantic modal with native dialog (#39846)
Replace Fomantic's hard-forked jQuery modal with native `<dialog>`
elements, advancing https://github.com/go-gitea/gitea/issues/29849. The
UI is visually unchanged. Dialogs open with `show()` over an `inert`
page, so tooltips, popups and toasts mounted on `<body>` stay usable
above them, unlike with `showModal()`
(https://github.com/whatwg/html/issues/9936).

- Remove the Fomantic modal and dimmer, add `showModal` and `hideModal`
- Declare modals as `<dialog class="modal-dialog">`, shown inside a
`.modal-backdrop`, instead of `ui modal` with its unused size classes
- Remove two modals that could never be opened
- Block the page while a modal is open, close the topmost one on Escape
and restore focus to its opener
- Allow stacked modals, use a confirm modal instead of `window.confirm`
for deleting content history
- Hide popups and toasts when a modal opens or closes
- Keep the release notes modal open when generating notes fails

Fixes: https://github.com/go-gitea/gitea/issues/39643
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2026-10-20 12:32:27 +02:00

63 lines
2.5 KiB
Handlebars

<h4 class="ui top attached header">{{ctx.Locale.Tr "settings.webauthn"}}</h4>
<div class="ui attached segment">
<p>{{ctx.Locale.Tr "settings.webauthn_desc" "https://w3c.github.io/webauthn/#webauthn-authenticator"}}</p>
<p>{{ctx.Locale.Tr "settings.webauthn_key_loss_warning"}} {{ctx.Locale.Tr "settings.webauthn_alternative_tip"}}</p>
{{template "user/auth/webauthn_error" .}}
<div class="flex-divided-list items-with-main">
{{range .WebAuthnCredentials}}
<div class="item">
<div class="item-leading">
{{svg "octicon-key" 32}}
</div>
<div class="item-main">
<div class="item-title">{{.Name}}</div>
<div class="item-body">
<i>{{ctx.Locale.Tr "settings.added_on" (DateUtils.AbsoluteShort .CreatedUnix)}}</i>
</div>
</div>
<div class="item-trailing">
<button type="button" class="ui tiny button show-modal" data-modal="#rename-webauthn-nickname" data-modal-id="{{.ID}}" data-modal-name="{{.Name}}">
{{ctx.Locale.Tr "rename"}}
</button>
<button type="button" class="ui red tiny button link-action" data-modal-confirm="#delete-registration" data-url="{{$.Link}}/webauthn/delete?id={{.ID}}">
{{ctx.Locale.Tr "remove"}}
</button>
</div>
</div>
{{end}}
</div>
</div>
<div class="ui attached segment">
<div class="ui form">
<div class="required field">
<label for="nickname">{{ctx.Locale.Tr "settings.webauthn_nickname"}}</label>
<input id="nickname" name="nickname" type="text" required>
</div>
<button type="button" id="register-webauthn" class="ui primary button">{{svg "octicon-key"}} {{ctx.Locale.Tr "settings.webauthn_register_key"}}</button>
</div>
<dialog class="modal-dialog" id="rename-webauthn-nickname">
<div class="header">
{{svg "octicon-pencil"}}
{{ctx.Locale.Tr "rename"}}
</div>
<form class="content ui form form-fetch-action" action="{{$.Link}}/webauthn/rename" method="post">
<input type="hidden" name="id">
<div class="required field">
<label>{{ctx.Locale.Tr "settings.webauthn_nickname"}}</label>
<input name="name" type="text" maxlength="255" required>
</div>
{{template "base/modal_actions_confirm" (dict "ModalButtonTypes" "confirm")}}
</form>
</dialog>
<dialog class="modal-dialog" id="delete-registration">
<div class="header">
{{svg "octicon-trash"}}
{{ctx.Locale.Tr "settings.webauthn_delete_key"}}
</div>
<div class="content">
<p>{{ctx.Locale.Tr "settings.webauthn_delete_key_desc"}}</p>
</div>
{{template "base/modal_actions_confirm" .}}
</dialog>
</div>