From c1331d1f7ab60249ed2f080b24f3e32093fa708d Mon Sep 17 00:00:00 2001 From: Yarden Shoham Date: Thu, 7 Mar 2024 09:28:33 +0200 Subject: Remove jQuery AJAX from the repo editor (#29636) # Preview Tab - Removed the jQuery AJAX call and replaced with our fetch wrapper - Tested the preview tab functionality and it works as before # Diff Tab - Removed the jQuery AJAX call and replaced with htmx - Tested the diff tab functionality and it works as before ## htmx Attributes - `hx-post="{{.RepoLink}}..."`: make a POST request to the endpoint - `hx-indicator=".tab[data-tab='diff']"`: attach the loading indicator to the tab body - `hx-target=".tab[data-tab='diff']"`: target the tab body for swapping with the response - `hx-swap="innerHTML"`: swap the target's inner HTML - `hx-include="#edit_area"`: include the value of the textarea (content) in the request body - `hx-vals='{"context":"{{.BranchLink}}"}'`: include the context in the request body - `hx-params="context,content"`: include only these keys in the request body # Demo using `fetch` and `htmx` instead of jQuery AJAX ![demo](https://github.com/go-gitea/gitea/assets/20454870/585cd6e8-f329-4c9e-ab53-a540acbd7988) --------- Signed-off-by: Yarden Shoham Co-authored-by: silverwind --- templates/repo/editor/edit.tmpl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'templates/repo') diff --git a/templates/repo/editor/edit.tmpl b/templates/repo/editor/edit.tmpl index a6dce81c08..05a8d96681 100644 --- a/templates/repo/editor/edit.tmpl +++ b/templates/repo/editor/edit.tmpl @@ -30,7 +30,7 @@ {{svg "octicon-code"}} {{if .IsNewFile}}{{ctx.Locale.Tr "repo.editor.new_file"}}{{else}}{{ctx.Locale.Tr "repo.editor.edit_file"}}{{end}} {{svg "octicon-eye"}} {{ctx.Locale.Tr "preview"}} {{if not .IsNewFile}} - {{svg "octicon-diff"}} {{ctx.Locale.Tr "repo.editor.preview_changes"}} + {{svg "octicon-diff"}} {{ctx.Locale.Tr "repo.editor.preview_changes"}} {{end}}
@@ -45,7 +45,7 @@ {{ctx.Locale.Tr "loading"}}
- {{ctx.Locale.Tr "loading"}} +
{{template "repo/editor/commit_form" .}} -- cgit v1.2.3