diff options
author | Yarden Shoham <git@yardenshoham.com> | 2024-02-05 11:56:20 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-05 09:56:20 +0000 |
commit | 6992ef98fc227a60cf06e0a06b9ae2492b3d61be (patch) | |
tree | fb2d54808df8e6f0f5e16c46f43a13d716a25f73 /templates/repo | |
parent | 0d136df3f0b3920d34ce850499e1346fbff29e30 (diff) | |
download | gitea-6992ef98fc227a60cf06e0a06b9ae2492b3d61be.tar.gz gitea-6992ef98fc227a60cf06e0a06b9ae2492b3d61be.zip |
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>
Diffstat (limited to 'templates/repo')
-rw-r--r-- | templates/repo/header.tmpl | 32 | ||||
-rw-r--r-- | templates/repo/star_unstar.tmpl | 14 | ||||
-rw-r--r-- | templates/repo/watch_unwatch.tmpl | 14 |
3 files changed, 30 insertions, 30 deletions
diff --git a/templates/repo/header.tmpl b/templates/repo/header.tmpl index dac30af600..93102467cc 100644 --- a/templates/repo/header.tmpl +++ b/templates/repo/header.tmpl @@ -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 diff --git a/templates/repo/star_unstar.tmpl b/templates/repo/star_unstar.tmpl new file mode 100644 index 0000000000..9c342f4065 --- /dev/null +++ b/templates/repo/star_unstar.tmpl @@ -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> diff --git a/templates/repo/watch_unwatch.tmpl b/templates/repo/watch_unwatch.tmpl new file mode 100644 index 0000000000..c42bc5a9e7 --- /dev/null +++ b/templates/repo/watch_unwatch.tmpl @@ -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> |