From 68972a994719ae5c74e28d8fa82fa27c23399bc8 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Fri, 3 Jan 2025 12:01:19 +0800 Subject: [PATCH] Clean up legacy form CSS styles (#33081) --- routers/web/repo/repo.go | 43 +-- templates/org/create.tmpl | 32 +- templates/repo/create.tmpl | 35 +- templates/repo/migrate/codebase.tmpl | 22 +- templates/repo/migrate/codecommit.tmpl | 22 +- templates/repo/migrate/git.tmpl | 22 +- templates/repo/migrate/gitbucket.tmpl | 24 +- templates/repo/migrate/gitea.tmpl | 22 +- templates/repo/migrate/github.tmpl | 22 +- templates/repo/migrate/gitlab.tmpl | 22 +- templates/repo/migrate/gogs.tmpl | 22 +- templates/repo/migrate/onedev.tmpl | 25 +- templates/repo/pulls/fork.tmpl | 18 +- templates/user/auth/finalize_openid.tmpl | 47 --- templates/user/auth/reset_passwd.tmpl | 24 +- templates/user/auth/signin_inner.tmpl | 6 +- .../user/auth/signup_openid_connect.tmpl | 44 +-- .../user/auth/signup_openid_register.tmpl | 2 +- web_src/css/base.css | 16 - web_src/css/form.css | 356 ++---------------- web_src/css/org.css | 87 ----- 21 files changed, 231 insertions(+), 682 deletions(-) delete mode 100644 templates/user/auth/finalize_openid.tmpl diff --git a/routers/web/repo/repo.go b/routers/web/repo/repo.go index 85a745acbd..0f408b22e0 100644 --- a/routers/web/repo/repo.go +++ b/routers/web/repo/repo.go @@ -147,27 +147,33 @@ func getRepoPrivate(ctx *context.Context) bool { } } -// Create render creating repository page -func Create(ctx *context.Context) { +func createCommon(ctx *context.Context) { ctx.Data["Title"] = ctx.Tr("new_repo") - - // Give default value for template to render. ctx.Data["Gitignores"] = repo_module.Gitignores ctx.Data["LabelTemplateFiles"] = repo_module.LabelTemplateFiles ctx.Data["Licenses"] = repo_module.Licenses ctx.Data["Readmes"] = repo_module.Readmes - ctx.Data["readme"] = "Default" - ctx.Data["private"] = getRepoPrivate(ctx) ctx.Data["IsForcedPrivate"] = setting.Repository.ForcePrivate - ctx.Data["default_branch"] = setting.Repository.DefaultBranch + ctx.Data["CanCreateRepo"] = ctx.Doer.CanCreateRepo() + ctx.Data["MaxCreationLimit"] = ctx.Doer.MaxCreationLimit() + ctx.Data["SupportedObjectFormats"] = git.DefaultFeatures().SupportedObjectFormats + ctx.Data["DefaultObjectFormat"] = git.Sha1ObjectFormat +} +// Create render creating repository page +func Create(ctx *context.Context) { + createCommon(ctx) ctxUser := checkContextUser(ctx, ctx.FormInt64("org")) if ctx.Written() { return } ctx.Data["ContextUser"] = ctxUser + ctx.Data["readme"] = "Default" + ctx.Data["private"] = getRepoPrivate(ctx) + ctx.Data["default_branch"] = setting.Repository.DefaultBranch ctx.Data["repo_template_name"] = ctx.Tr("repo.template_select") + templateID := ctx.FormInt64("template_id") if templateID > 0 { templateRepo, err := repo_model.GetRepositoryByID(ctx, templateID) @@ -177,11 +183,6 @@ func Create(ctx *context.Context) { } } - ctx.Data["CanCreateRepo"] = ctx.Doer.CanCreateRepo() - ctx.Data["MaxCreationLimit"] = ctx.Doer.MaxCreationLimit() - ctx.Data["SupportedObjectFormats"] = git.DefaultFeatures().SupportedObjectFormats - ctx.Data["DefaultObjectFormat"] = git.Sha1ObjectFormat - ctx.HTML(http.StatusOK, tplCreate) } @@ -219,16 +220,8 @@ func handleCreateError(ctx *context.Context, owner *user_model.User, err error, // CreatePost response for creating repository func CreatePost(ctx *context.Context) { + createCommon(ctx) form := web.GetForm(ctx).(*forms.CreateRepoForm) - ctx.Data["Title"] = ctx.Tr("new_repo") - - ctx.Data["Gitignores"] = repo_module.Gitignores - ctx.Data["LabelTemplateFiles"] = repo_module.LabelTemplateFiles - ctx.Data["Licenses"] = repo_module.Licenses - ctx.Data["Readmes"] = repo_module.Readmes - - ctx.Data["CanCreateRepo"] = ctx.Doer.CanCreateRepo() - ctx.Data["MaxCreationLimit"] = ctx.Doer.MaxCreationLimit() ctxUser := checkContextUser(ctx, form.UID) if ctx.Written() { @@ -236,6 +229,14 @@ func CreatePost(ctx *context.Context) { } ctx.Data["ContextUser"] = ctxUser + if form.RepoTemplate > 0 { + templateRepo, err := repo_model.GetRepositoryByID(ctx, form.RepoTemplate) + if err == nil && access_model.CheckRepoUnitUser(ctx, templateRepo, ctxUser, unit.TypeCode) { + ctx.Data["repo_template"] = form.RepoTemplate + ctx.Data["repo_template_name"] = templateRepo.Name + } + } + if ctx.HasError() { ctx.HTML(http.StatusOK, tplCreate) return diff --git a/templates/org/create.tmpl b/templates/org/create.tmpl index 004cd9be80..2f19fd817f 100644 --- a/templates/org/create.tmpl +++ b/templates/org/create.tmpl @@ -2,22 +2,22 @@
-
- {{.CsrfTokenHtml}} -

- {{ctx.Locale.Tr "new_org"}} -

-
- {{template "base/alert" .}} + {{template "base/alert" .}} +

+ {{ctx.Locale.Tr "new_org"}} +

+
+ + {{.CsrfTokenHtml}}
{{ctx.Locale.Tr "org.org_name_helper"}}
-
- -
+
+ +
@@ -35,11 +35,9 @@
-
-
- - -
+
+ +
@@ -49,8 +47,8 @@ {{ctx.Locale.Tr "org.create_org"}}
-
- + +
diff --git a/templates/repo/create.tmpl b/templates/repo/create.tmpl index 78eb2f704a..36283b35e0 100644 --- a/templates/repo/create.tmpl +++ b/templates/repo/create.tmpl @@ -2,20 +2,20 @@
-
- {{.CsrfTokenHtml}} -

- {{ctx.Locale.Tr "new_repo"}} -

-
- {{template "base/alert" .}} - {{template "repo/create_helper" .}} +

+ {{ctx.Locale.Tr "new_repo"}} +

+
+ {{template "base/alert" .}} + {{template "repo/create_helper" .}} - {{if not .CanCreateRepo}} -
-

{{ctx.Locale.TrN .MaxCreationLimit "repo.form.reach_limit_of_creation_1" "repo.form.reach_limit_of_creation_n" .MaxCreationLimit}}

-
- {{end}} + {{if not .CanCreateRepo}} +
+

{{ctx.Locale.TrN .MaxCreationLimit "repo.form.reach_limit_of_creation_1" "repo.form.reach_limit_of_creation_n" .MaxCreationLimit}}

+
+ {{end}} + + {{.CsrfTokenHtml}}