From e8b990999f89535269d20983079a40a0a9488eff Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Wed, 23 Aug 2023 17:36:57 +0800 Subject: [PATCH] Make "link-action" backend code respond correct JSON content (#26680) Otherwise the `link-action` JS code couldn't parse the response. Co-authored-by: Giteabot --- routers/web/admin/users.go | 2 +- routers/web/org/setting.go | 2 +- routers/web/repo/setting/avatar.go | 2 +- routers/web/user/setting/profile.go | 2 +- templates/admin/user/edit.tmpl | 2 +- templates/org/settings/options.tmpl | 2 +- templates/repo/settings/options.tmpl | 2 +- templates/user/settings/profile.tmpl | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/routers/web/admin/users.go b/routers/web/admin/users.go index 03c89bdab19..e560a88b4cf 100644 --- a/routers/web/admin/users.go +++ b/routers/web/admin/users.go @@ -480,5 +480,5 @@ func DeleteAvatar(ctx *context.Context) { ctx.Flash.Error(err.Error()) } - ctx.Redirect(setting.AppSubURL + "/admin/users/" + strconv.FormatInt(u.ID, 10)) + ctx.JSONRedirect(setting.AppSubURL + "/admin/users/" + strconv.FormatInt(u.ID, 10)) } diff --git a/routers/web/org/setting.go b/routers/web/org/setting.go index 5ae61c79bef..957daab6466 100644 --- a/routers/web/org/setting.go +++ b/routers/web/org/setting.go @@ -156,7 +156,7 @@ func SettingsDeleteAvatar(ctx *context.Context) { ctx.Flash.Error(err.Error()) } - ctx.Redirect(ctx.Org.OrgLink + "/settings") + ctx.JSONRedirect(ctx.Org.OrgLink + "/settings") } // SettingsDelete response for deleting an organization diff --git a/routers/web/repo/setting/avatar.go b/routers/web/repo/setting/avatar.go index ec673ca2886..ae80f1db01a 100644 --- a/routers/web/repo/setting/avatar.go +++ b/routers/web/repo/setting/avatar.go @@ -72,5 +72,5 @@ func SettingsDeleteAvatar(ctx *context.Context) { if err := repo_service.DeleteAvatar(ctx, ctx.Repo.Repository); err != nil { ctx.Flash.Error(fmt.Sprintf("DeleteAvatar: %v", err)) } - ctx.Redirect(ctx.Repo.RepoLink + "/settings") + ctx.JSONRedirect(ctx.Repo.RepoLink + "/settings") } diff --git a/routers/web/user/setting/profile.go b/routers/web/user/setting/profile.go index ab7d2e58b39..61089d0947b 100644 --- a/routers/web/user/setting/profile.go +++ b/routers/web/user/setting/profile.go @@ -194,7 +194,7 @@ func DeleteAvatar(ctx *context.Context) { ctx.Flash.Error(err.Error()) } - ctx.Redirect(setting.AppSubURL + "/user/settings") + ctx.JSONRedirect(setting.AppSubURL + "/user/settings") } // Organization render all the organization of the user diff --git a/templates/admin/user/edit.tmpl b/templates/admin/user/edit.tmpl index 4fea418e6f9..e99a4532d3b 100644 --- a/templates/admin/user/edit.tmpl +++ b/templates/admin/user/edit.tmpl @@ -186,7 +186,7 @@
- +
diff --git a/templates/org/settings/options.tmpl b/templates/org/settings/options.tmpl index 683b8864677..03827e4c3f9 100644 --- a/templates/org/settings/options.tmpl +++ b/templates/org/settings/options.tmpl @@ -94,7 +94,7 @@
- +
diff --git a/templates/repo/settings/options.tmpl b/templates/repo/settings/options.tmpl index cc7f4315356..c157f637cff 100644 --- a/templates/repo/settings/options.tmpl +++ b/templates/repo/settings/options.tmpl @@ -58,7 +58,7 @@
- +
diff --git a/templates/user/settings/profile.tmpl b/templates/user/settings/profile.tmpl index 96193a42efb..6db58fe4db6 100644 --- a/templates/user/settings/profile.tmpl +++ b/templates/user/settings/profile.tmpl @@ -126,7 +126,7 @@
- +