From 85fa954a3810b233cb299f455546c4b2314400b3 Mon Sep 17 00:00:00 2001 From: JakobDev Date: Fri, 26 May 2023 11:42:54 +0200 Subject: [PATCH] Improve some Forms (#24878) Don't really know a better name for this. I've gone through some Forms and added missing HTML attributes (mostly `maxlength`). I tried to fill the Forms with dummy Data and see if Gitea throws a Error (e.g. maximum length). If yes, I added the missing HTML attribute. While working on this, I discovered that the Form to add OAuth2 Apps just silently fails when filled with invalid data, so I fixed that too. --- routers/web/user/setting/oauth2_common.go | 1 + templates/admin/user/edit.tmpl | 12 ++++++------ templates/admin/user/new.tmpl | 2 +- templates/org/settings/options.tmpl | 2 +- templates/repo/create.tmpl | 4 ++-- templates/repo/issue/search.tmpl | 2 +- templates/repo/migrate/codebase.tmpl | 4 ++-- templates/repo/migrate/git.tmpl | 4 ++-- templates/repo/migrate/gitbucket.tmpl | 4 ++-- templates/repo/migrate/gitea.tmpl | 4 ++-- templates/repo/migrate/github.tmpl | 4 ++-- templates/repo/migrate/gitlab.tmpl | 4 ++-- templates/repo/migrate/gogs.tmpl | 4 ++-- templates/repo/migrate/onedev.tmpl | 4 ++-- templates/repo/settings/options.tmpl | 2 +- templates/user/settings/applications.tmpl | 2 +- .../user/settings/applications_oauth2_edit_form.tmpl | 4 ++-- .../user/settings/applications_oauth2_list.tmpl | 2 +- templates/user/settings/keys_ssh.tmpl | 2 +- templates/user/settings/profile.tmpl | 10 +++++----- 20 files changed, 39 insertions(+), 38 deletions(-) diff --git a/routers/web/user/setting/oauth2_common.go b/routers/web/user/setting/oauth2_common.go index f6ad1b2b38..5489b60260 100644 --- a/routers/web/user/setting/oauth2_common.go +++ b/routers/web/user/setting/oauth2_common.go @@ -31,6 +31,7 @@ func (oa *OAuth2CommonHandlers) renderEditPage(ctx *context.Context) { func (oa *OAuth2CommonHandlers) AddApp(ctx *context.Context) { form := web.GetForm(ctx).(*forms.EditOAuth2ApplicationForm) if ctx.HasError() { + ctx.Flash.Error(ctx.GetErrMsg()) // go to the application list page ctx.Redirect(oa.BasePathList) return diff --git a/templates/admin/user/edit.tmpl b/templates/admin/user/edit.tmpl index 30109cc923..00d21f24b0 100644 --- a/templates/admin/user/edit.tmpl +++ b/templates/admin/user/edit.tmpl @@ -9,7 +9,7 @@ {{.CsrfTokenHtml}}
- +
@@ -59,7 +59,7 @@
- +
@@ -72,18 +72,18 @@
- +
- +
- +

{{.locale.Tr "admin.users.max_repo_creation_desc"}}

@@ -181,7 +181,7 @@
- +
diff --git a/templates/admin/user/new.tmpl b/templates/admin/user/new.tmpl index dbf01fb43e..691d63aead 100644 --- a/templates/admin/user/new.tmpl +++ b/templates/admin/user/new.tmpl @@ -53,7 +53,7 @@
- +
diff --git a/templates/org/settings/options.tmpl b/templates/org/settings/options.tmpl index 6f9f076548..21b14200ff 100644 --- a/templates/org/settings/options.tmpl +++ b/templates/org/settings/options.tmpl @@ -69,7 +69,7 @@
- +

{{.locale.Tr "admin.users.max_repo_creation_desc"}}

{{end}} diff --git a/templates/repo/create.tmpl b/templates/repo/create.tmpl index 85b02f394d..05e7052ff4 100644 --- a/templates/repo/create.tmpl +++ b/templates/repo/create.tmpl @@ -43,7 +43,7 @@
- + {{.locale.Tr "repo.repo_name_helper"}}
@@ -61,7 +61,7 @@
- +
diff --git a/templates/repo/issue/search.tmpl b/templates/repo/issue/search.tmpl index f24c2dbb7e..97b22d3699 100644 --- a/templates/repo/issue/search.tmpl +++ b/templates/repo/issue/search.tmpl @@ -7,7 +7,7 @@ - + {{if .PageIsIssueList}} {{end}} diff --git a/templates/repo/migrate/codebase.tmpl b/templates/repo/migrate/codebase.tmpl index 5bfd3adc2d..41e9c273bc 100644 --- a/templates/repo/migrate/codebase.tmpl +++ b/templates/repo/migrate/codebase.tmpl @@ -83,7 +83,7 @@
- +
@@ -99,7 +99,7 @@
- +
diff --git a/templates/repo/migrate/git.tmpl b/templates/repo/migrate/git.tmpl index fb6775e38c..ba092a32a0 100644 --- a/templates/repo/migrate/git.tmpl +++ b/templates/repo/migrate/git.tmpl @@ -57,7 +57,7 @@
- +
@@ -73,7 +73,7 @@
- +
diff --git a/templates/repo/migrate/gitbucket.tmpl b/templates/repo/migrate/gitbucket.tmpl index e9515beeb2..da14d569a8 100644 --- a/templates/repo/migrate/gitbucket.tmpl +++ b/templates/repo/migrate/gitbucket.tmpl @@ -99,7 +99,7 @@
- +
@@ -115,7 +115,7 @@
- +
diff --git a/templates/repo/migrate/gitea.tmpl b/templates/repo/migrate/gitea.tmpl index f1d4e4f06b..daa1205557 100644 --- a/templates/repo/migrate/gitea.tmpl +++ b/templates/repo/migrate/gitea.tmpl @@ -95,7 +95,7 @@
- +
@@ -111,7 +111,7 @@
- +
diff --git a/templates/repo/migrate/github.tmpl b/templates/repo/migrate/github.tmpl index c591f2a465..e9f2b11e75 100644 --- a/templates/repo/migrate/github.tmpl +++ b/templates/repo/migrate/github.tmpl @@ -97,7 +97,7 @@
- +
@@ -113,7 +113,7 @@
- +
diff --git a/templates/repo/migrate/gitlab.tmpl b/templates/repo/migrate/gitlab.tmpl index 65559da152..656b5c50ee 100644 --- a/templates/repo/migrate/gitlab.tmpl +++ b/templates/repo/migrate/gitlab.tmpl @@ -94,7 +94,7 @@
- +
@@ -110,7 +110,7 @@
- +
diff --git a/templates/repo/migrate/gogs.tmpl b/templates/repo/migrate/gogs.tmpl index 8bc57861ad..78700a7910 100644 --- a/templates/repo/migrate/gogs.tmpl +++ b/templates/repo/migrate/gogs.tmpl @@ -97,7 +97,7 @@
- +
@@ -113,7 +113,7 @@
- +
diff --git a/templates/repo/migrate/onedev.tmpl b/templates/repo/migrate/onedev.tmpl index 8463782ae7..50858edd60 100644 --- a/templates/repo/migrate/onedev.tmpl +++ b/templates/repo/migrate/onedev.tmpl @@ -83,7 +83,7 @@
- +
@@ -99,7 +99,7 @@
- +
diff --git a/templates/repo/settings/options.tmpl b/templates/repo/settings/options.tmpl index efcdaceb37..83a6bc4ba1 100644 --- a/templates/repo/settings/options.tmpl +++ b/templates/repo/settings/options.tmpl @@ -826,7 +826,7 @@
- +
diff --git a/templates/user/settings/applications.tmpl b/templates/user/settings/applications.tmpl index 84d02c0a00..1c12a0a2b7 100644 --- a/templates/user/settings/applications.tmpl +++ b/templates/user/settings/applications.tmpl @@ -45,7 +45,7 @@ {{.CsrfTokenHtml}}
- +
diff --git a/templates/user/settings/applications_oauth2_edit_form.tmpl b/templates/user/settings/applications_oauth2_edit_form.tmpl index 8a9579c5c5..45f12f22d0 100644 --- a/templates/user/settings/applications_oauth2_edit_form.tmpl +++ b/templates/user/settings/applications_oauth2_edit_form.tmpl @@ -36,11 +36,11 @@ {{.CsrfTokenHtml}}
- +
- +
diff --git a/templates/user/settings/applications_oauth2_list.tmpl b/templates/user/settings/applications_oauth2_list.tmpl index ad38c60eb9..2e42ed2758 100644 --- a/templates/user/settings/applications_oauth2_list.tmpl +++ b/templates/user/settings/applications_oauth2_list.tmpl @@ -31,7 +31,7 @@ {{.CsrfTokenHtml}}
- +
diff --git a/templates/user/settings/keys_ssh.tmpl b/templates/user/settings/keys_ssh.tmpl index f6ea508cc8..0a47c44bd8 100644 --- a/templates/user/settings/keys_ssh.tmpl +++ b/templates/user/settings/keys_ssh.tmpl @@ -12,7 +12,7 @@ {{.CsrfTokenHtml}}
- +
diff --git a/templates/user/settings/profile.tmpl b/templates/user/settings/profile.tmpl index dc1bbc84d5..e6ba283a0c 100644 --- a/templates/user/settings/profile.tmpl +++ b/templates/user/settings/profile.tmpl @@ -12,14 +12,14 @@ {{.locale.Tr "settings.change_username_prompt"}} {{.locale.Tr "settings.change_username_redirect_prompt"}} - + {{if or (not .SignedUser.IsLocal) .IsReverseProxy}}

{{$.locale.Tr "settings.password_username_disabled"}}

{{end}}
- +
@@ -33,15 +33,15 @@
- +
- +
- +