From 2add8fe9beede4aa82c913fcb70c0cf5bb1c6185 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Thu, 21 Oct 2021 15:37:43 +0800 Subject: [PATCH] Frontend refactor, PascalCase to camelCase, remove unused code (#17365) * Frontend refactor, PascalCase to camelCase, remove unused code * fix --- integrations/branches_test.go | 9 +---- integrations/html_helper.go | 2 +- integrations/pull_create_test.go | 4 +-- modules/context/context.go | 2 +- routers/web/repo/projects.go | 4 --- templates/base/head.tmpl | 35 +++++++------------ templates/repo/projects/list.tmpl | 2 +- templates/repo/projects/new.tmpl | 2 +- templates/repo/projects/view.tmpl | 10 +++--- web_src/js/components/ContextPopup.vue | 4 +-- web_src/js/components/DashboardRepoList.js | 6 ++-- web_src/js/components/VueComponentLoader.js | 2 +- web_src/js/features/admin-common.js | 4 +-- web_src/js/features/common-global.js | 16 ++++----- web_src/js/features/comp/ImagePaste.js | 8 ++--- .../js/features/comp/MarkupContentPreview.js | 4 +-- web_src/js/features/comp/ReactionSelector.js | 4 +-- web_src/js/features/comp/SearchUserBox.js | 4 +-- web_src/js/features/comp/WebHookEditor.js | 4 +-- web_src/js/features/emoji.js | 10 +++--- web_src/js/features/issue-content-history.js | 10 +++--- web_src/js/features/lastcommitloader.js | 6 ++-- web_src/js/features/notification.js | 28 +++++++-------- web_src/js/features/org-team.js | 4 +-- web_src/js/features/projects.js | 16 ++++----- web_src/js/features/repo-common.js | 4 +-- web_src/js/features/repo-diff.js | 4 +-- web_src/js/features/repo-editor.js | 6 ++-- web_src/js/features/repo-home.js | 8 ++--- web_src/js/features/repo-issue.js | 24 ++++++------- web_src/js/features/repo-legacy.js | 10 +++--- web_src/js/features/repo-migrate.js | 6 ++-- web_src/js/features/repo-settings.js | 8 ++--- web_src/js/features/repo-template.js | 4 +-- web_src/js/features/repo-wiki.js | 4 +-- web_src/js/features/serviceworker.js | 8 ++--- web_src/js/features/stopwatch.js | 26 +++++++------- web_src/js/features/tribute.js | 2 +- web_src/js/features/user-auth-u2f.js | 18 +++++----- web_src/js/markup/mermaid.js | 6 ++-- web_src/js/markup/tasklist.js | 2 +- web_src/js/publicpath.js | 4 +-- 42 files changed, 162 insertions(+), 182 deletions(-) diff --git a/integrations/branches_test.go b/integrations/branches_test.go index b2230e7031..aa4df6ac6a 100644 --- a/integrations/branches_test.go +++ b/integrations/branches_test.go @@ -9,7 +9,6 @@ import ( "net/url" "testing" - "github.com/PuerkitoBio/goquery" "github.com/stretchr/testify/assert" "github.com/unknwon/i18n" ) @@ -62,7 +61,7 @@ func branchAction(t *testing.T, button string) (*HTMLDoc, string) { } req = NewRequestWithValues(t, "POST", link, map[string]string{ - "_csrf": getCsrf(t, htmlDoc.doc), + "_csrf": htmlDoc.GetCSRF(), }) session.MakeRequest(t, req, http.StatusOK) @@ -73,9 +72,3 @@ func branchAction(t *testing.T, button string) (*HTMLDoc, string) { return NewHTMLParser(t, resp.Body), url.Query().Get("name") } - -func getCsrf(t *testing.T, doc *goquery.Document) string { - csrf, exists := doc.Find("meta[name=\"_csrf\"]").Attr("content") - assert.True(t, exists) - return csrf -} diff --git a/integrations/html_helper.go b/integrations/html_helper.go index 6dc806a76e..001fc9a05b 100644 --- a/integrations/html_helper.go +++ b/integrations/html_helper.go @@ -44,7 +44,7 @@ func (doc *HTMLDoc) Find(selector string) *goquery.Selection { return doc.doc.Find(selector) } -// GetCSRF for get CSRC token value from input +// GetCSRF for getting CSRF token value from input func (doc *HTMLDoc) GetCSRF() string { return doc.GetInputValueByName("_csrf") } diff --git a/integrations/pull_create_test.go b/integrations/pull_create_test.go index 5a0a3eda08..948c0b9ce2 100644 --- a/integrations/pull_create_test.go +++ b/integrations/pull_create_test.go @@ -114,7 +114,7 @@ func testUIDeleteBranch(t *testing.T, session *TestSession, ownerName, repoName, htmlDoc := NewHTMLParser(t, resp.Body) req = NewRequestWithValues(t, "POST", relURL+"/delete", map[string]string{ - "_csrf": getCsrf(t, htmlDoc.doc), + "_csrf": htmlDoc.GetCSRF(), "name": branchName, }) session.MakeRequest(t, req, http.StatusOK) @@ -127,7 +127,7 @@ func testDeleteRepository(t *testing.T, session *TestSession, ownerName, repoNam htmlDoc := NewHTMLParser(t, resp.Body) req = NewRequestWithValues(t, "POST", relURL+"?action=delete", map[string]string{ - "_csrf": getCsrf(t, htmlDoc.doc), + "_csrf": htmlDoc.GetCSRF(), "repo_name": repoName, }) session.MakeRequest(t, req, http.StatusFound) diff --git a/modules/context/context.go b/modules/context/context.go index 383a69ad63..f652d3845a 100644 --- a/modules/context/context.go +++ b/modules/context/context.go @@ -645,7 +645,7 @@ func Contexter() func(next http.Handler) http.Handler { "CurrentURL": setting.AppSubURL + req.URL.RequestURI(), "PageStartTime": startTime, "Link": link, - "IsProd": setting.IsProd, + "RunModeIsProd": setting.IsProd, }, } // PageData is passed by reference, and it will be rendered to `window.config.pageData` in `head.tmpl` for JavaScript modules diff --git a/routers/web/repo/projects.go b/routers/web/repo/projects.go index 2490efc923..e98d189c1a 100644 --- a/routers/web/repo/projects.go +++ b/routers/web/repo/projects.go @@ -205,7 +205,6 @@ func DeleteProject(ctx *context.Context) { // EditProject allows a project to be edited func EditProject(ctx *context.Context) { ctx.Data["Title"] = ctx.Tr("repo.projects.edit") - ctx.Data["PageIsProjects"] = true ctx.Data["PageIsEditProjects"] = true ctx.Data["CanWriteProjects"] = ctx.Repo.Permission.CanWrite(models.UnitTypeProjects) @@ -233,7 +232,6 @@ func EditProject(ctx *context.Context) { func EditProjectPost(ctx *context.Context) { form := web.GetForm(ctx).(*forms.CreateProjectForm) ctx.Data["Title"] = ctx.Tr("repo.projects.edit") - ctx.Data["PageIsProjects"] = true ctx.Data["PageIsEditProjects"] = true ctx.Data["CanWriteProjects"] = ctx.Repo.Permission.CanWrite(models.UnitTypeProjects) @@ -335,8 +333,6 @@ func ViewProject(ctx *context.Context) { ctx.Data["CanWriteProjects"] = ctx.Repo.Permission.CanWrite(models.UnitTypeProjects) ctx.Data["Project"] = project ctx.Data["Boards"] = boards - ctx.Data["PageIsProjects"] = true - ctx.Data["RequiresDraggable"] = true ctx.HTML(http.StatusOK, tplProjectsView) } diff --git a/templates/base/head.tmpl b/templates/base/head.tmpl index 80bb121c6b..23d1190d94 100644 --- a/templates/base/head.tmpl +++ b/templates/base/head.tmpl @@ -3,7 +3,7 @@ - {{if .Title}}{{.Title | RenderEmojiPlain}} - {{end}} {{if .Repository.Name}}{{.Repository.Name}} - {{end}}{{AppName}} + {{if .Title}}{{.Title | RenderEmojiPlain}} - {{end}} {{if .Repository.Name}}{{.Repository.Name}} - {{end}}{{AppName}} @@ -11,7 +11,6 @@ - {{if .GoGetImport}} @@ -19,25 +18,17 @@ diff --git a/templates/repo/projects/list.tmpl b/templates/repo/projects/list.tmpl index ec7370709f..f152d20915 100644 --- a/templates/repo/projects/list.tmpl +++ b/templates/repo/projects/list.tmpl @@ -1,5 +1,5 @@ {{template "base/head" .}} -
+
{{template "repo/header" .}}