forked from forgejo/forgejo
Don't do a full page load when clicking Watch
or Star
(#29001)
- The watch/unwatch button and star/unstar get their own template - The backend returns HTML instead of redirect --------- Signed-off-by: Yarden Shoham <git@yardenshoham.com> Co-authored-by: John Olheiser <john.olheiser@gmail.com>
This commit is contained in:
parent
0d136df3f0
commit
6992ef98fc
4 changed files with 61 additions and 30 deletions
|
@ -58,37 +58,9 @@
|
|||
{{svg "octicon-rss" 16}}
|
||||
</a>
|
||||
{{end}}
|
||||
<form method="post" action="{{$.RepoLink}}/action/{{if $.IsWatchingRepo}}un{{end}}watch?redirect_to={{$.Link}}">
|
||||
{{$.CsrfTokenHtml}}
|
||||
<div class="ui labeled button" {{if not $.IsSigned}}data-tooltip-content="{{ctx.Locale.Tr "repo.watch_guest_user"}}"{{end}}>
|
||||
<button type="submit" class="ui compact small basic button"{{if not $.IsSigned}} disabled{{end}}>
|
||||
{{if $.IsWatchingRepo}}
|
||||
{{svg "octicon-eye-closed" 16}}<span class="text">{{ctx.Locale.Tr "repo.unwatch"}}</span>
|
||||
{{else}}
|
||||
{{svg "octicon-eye"}}<span class="text">{{ctx.Locale.Tr "repo.watch"}}</span>
|
||||
{{end}}
|
||||
</button>
|
||||
<a class="ui basic label" href="{{.Link}}/watchers">
|
||||
{{CountFmt .NumWatches}}
|
||||
</a>
|
||||
</div>
|
||||
</form>
|
||||
{{template "repo/watch_unwatch" $}}
|
||||
{{if not $.DisableStars}}
|
||||
<form method="post" action="{{$.RepoLink}}/action/{{if $.IsStaringRepo}}un{{end}}star?redirect_to={{$.Link}}">
|
||||
{{$.CsrfTokenHtml}}
|
||||
<div class="ui labeled button" {{if not $.IsSigned}}data-tooltip-content="{{ctx.Locale.Tr "repo.star_guest_user"}}"{{end}}>
|
||||
<button type="submit" class="ui compact small basic button"{{if not $.IsSigned}} disabled{{end}}>
|
||||
{{if $.IsStaringRepo}}
|
||||
{{svg "octicon-star-fill"}}<span class="text">{{ctx.Locale.Tr "repo.unstar"}}</span>
|
||||
{{else}}
|
||||
{{svg "octicon-star"}}<span class="text">{{ctx.Locale.Tr "repo.star"}}</span>
|
||||
{{end}}
|
||||
</button>
|
||||
<a class="ui basic label" href="{{.Link}}/stars">
|
||||
{{CountFmt .NumStars}}
|
||||
</a>
|
||||
</div>
|
||||
</form>
|
||||
{{template "repo/star_unstar" $}}
|
||||
{{end}}
|
||||
{{if and (not .IsEmpty) ($.Permission.CanRead $.UnitTypeCode)}}
|
||||
<div class="ui labeled button
|
||||
|
|
14
templates/repo/star_unstar.tmpl
Normal file
14
templates/repo/star_unstar.tmpl
Normal file
|
@ -0,0 +1,14 @@
|
|||
<form hx-boost="true" hx-target="this" method="post" action="{{$.RepoLink}}/action/{{if $.IsStaringRepo}}un{{end}}star">
|
||||
<div class="ui labeled button" {{if not $.IsSigned}}data-tooltip-content="{{ctx.Locale.Tr "repo.star_guest_user"}}"{{end}}>
|
||||
<button type="submit" class="ui compact small basic button"{{if not $.IsSigned}} disabled{{end}}>
|
||||
{{if $.IsStaringRepo}}
|
||||
{{svg "octicon-star-fill"}}<span class="text">{{ctx.Locale.Tr "repo.unstar"}}</span>
|
||||
{{else}}
|
||||
{{svg "octicon-star"}}<span class="text">{{ctx.Locale.Tr "repo.star"}}</span>
|
||||
{{end}}
|
||||
</button>
|
||||
<a hx-boost="false" class="ui basic label" href="{{$.RepoLink}}/stars">
|
||||
{{CountFmt .Repository.NumStars}}
|
||||
</a>
|
||||
</div>
|
||||
</form>
|
14
templates/repo/watch_unwatch.tmpl
Normal file
14
templates/repo/watch_unwatch.tmpl
Normal file
|
@ -0,0 +1,14 @@
|
|||
<form hx-boost="true" hx-target="this" method="post" action="{{$.RepoLink}}/action/{{if $.IsWatchingRepo}}un{{end}}watch">
|
||||
<div class="ui labeled button" {{if not $.IsSigned}}data-tooltip-content="{{ctx.Locale.Tr "repo.watch_guest_user"}}"{{end}}>
|
||||
<button type="submit" class="ui compact small basic button"{{if not $.IsSigned}} disabled{{end}}>
|
||||
{{if $.IsWatchingRepo}}
|
||||
{{svg "octicon-eye-closed" 16}}<span class="text">{{ctx.Locale.Tr "repo.unwatch"}}</span>
|
||||
{{else}}
|
||||
{{svg "octicon-eye"}}<span class="text">{{ctx.Locale.Tr "repo.watch"}}</span>
|
||||
{{end}}
|
||||
</button>
|
||||
<a hx-boost="false" class="ui basic label" href="{{.RepoLink}}/watchers">
|
||||
{{CountFmt .Repository.NumWatches}}
|
||||
</a>
|
||||
</div>
|
||||
</form>
|
Loading…
Add table
Add a link
Reference in a new issue