Files
gitea/templates/repo/header/fork.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

44 lines
1.6 KiB
Handlebars

{{$canNotForkOwn := and $.IsSigned (not $.CanSignedUserFork) (not $.UserAndOrgForks)}}
{{$forkHref := printf "%s/fork" $.RepoLink}}
{{if not $.IsSigned}}
{{$forkHref = printf "%s/user/login" AppSubUrl}}
{{else if $.ShowForkModal}}{{/* see backend comment for this logic */}}
{{$forkHref = "#"}}
{{else if eq (len $.UserAndOrgForks) 1}}
{{$forkHref = printf "%s/%s" AppSubUrl (index $.UserAndOrgForks 0).FullName}}
{{else if $canNotForkOwn}}
{{$forkHref = "#"}}
{{end}}
<a role="button" class="ui compact small basic button {{if $.ShowForkModal}}show-modal{{end}}" href="{{$forkHref}}"
{{if and $.IsSigned $.ShowForkModal}}data-modal="#fork-repo-modal"{{end}}
{{if not $.IsSigned}}
data-tooltip-content="{{ctx.Locale.Tr "repo.fork_guest_user"}}"
{{else if $canNotForkOwn}}
data-tooltip-content="{{ctx.Locale.Tr "repo.fork_from_self"}}"
{{end}}
>
{{svg "octicon-repo-forked"}}
<span class="not-mobile">{{ctx.Locale.Tr "repo.fork"}}</span>
<span class="ui small label">{{CountFmt $.Repository.NumForks}}</span>
</a>
{{if $.ShowForkModal}}
<dialog class="modal-dialog" id="fork-repo-modal">
<div class="header">
{{ctx.Locale.Tr "repo.already_forked" $.Repository.Name}}
</div>
<div class="content">
<div class="ui relaxed list">
{{range $.UserAndOrgForks}}
<div class="item">
<a class="flex-text-block" href="{{.Link}}">{{svg "octicon-repo-forked"}}{{.FullName}}</a>
</div>
{{end}}
</div>
{{if $.CanSignedUserFork}}
<div class="divider"></div>
<a href="{{$.RepoLink}}/fork">{{ctx.Locale.Tr "repo.fork_to_different_account"}}</a>
{{end}}
</div>
</dialog>
{{end}}