Skip to content

Commit b7c4274

Browse files
committed
Frontend refactor, PascalCase to camelCase, remove unused code
1 parent 0208ea0 commit b7c4274

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+162
-182
lines changed

integrations/branches_test.go

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"net/url"
1010
"testing"
1111

12-
"github.com/PuerkitoBio/goquery"
1312
"github.com/stretchr/testify/assert"
1413
"github.com/unknwon/i18n"
1514
)
@@ -62,7 +61,7 @@ func branchAction(t *testing.T, button string) (*HTMLDoc, string) {
6261
}
6362

6463
req = NewRequestWithValues(t, "POST", link, map[string]string{
65-
"_csrf": getCsrf(t, htmlDoc.doc),
64+
"_csrf": htmlDoc.GetCSRF(),
6665
})
6766
session.MakeRequest(t, req, http.StatusOK)
6867

@@ -73,9 +72,3 @@ func branchAction(t *testing.T, button string) (*HTMLDoc, string) {
7372

7473
return NewHTMLParser(t, resp.Body), url.Query().Get("name")
7574
}
76-
77-
func getCsrf(t *testing.T, doc *goquery.Document) string {
78-
csrf, exists := doc.Find("meta[name=\"_csrf\"]").Attr("content")
79-
assert.True(t, exists)
80-
return csrf
81-
}

integrations/html_helper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func (doc *HTMLDoc) Find(selector string) *goquery.Selection {
4444
return doc.doc.Find(selector)
4545
}
4646

47-
// GetCSRF for get CSRC token value from input
47+
// GetCSRF for getting CSRF token value from input
4848
func (doc *HTMLDoc) GetCSRF() string {
4949
return doc.GetInputValueByName("_csrf")
5050
}

integrations/pull_create_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ func testUIDeleteBranch(t *testing.T, session *TestSession, ownerName, repoName,
114114
htmlDoc := NewHTMLParser(t, resp.Body)
115115

116116
req = NewRequestWithValues(t, "POST", relURL+"/delete", map[string]string{
117-
"_csrf": getCsrf(t, htmlDoc.doc),
117+
"_csrf": htmlDoc.GetCSRF(),
118118
"name": branchName,
119119
})
120120
session.MakeRequest(t, req, http.StatusOK)
@@ -127,7 +127,7 @@ func testDeleteRepository(t *testing.T, session *TestSession, ownerName, repoNam
127127
htmlDoc := NewHTMLParser(t, resp.Body)
128128

129129
req = NewRequestWithValues(t, "POST", relURL+"?action=delete", map[string]string{
130-
"_csrf": getCsrf(t, htmlDoc.doc),
130+
"_csrf": htmlDoc.GetCSRF(),
131131
"repo_name": repoName,
132132
})
133133
session.MakeRequest(t, req, http.StatusFound)

modules/context/context.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ func Contexter() func(next http.Handler) http.Handler {
645645
"CurrentURL": setting.AppSubURL + req.URL.RequestURI(),
646646
"PageStartTime": startTime,
647647
"Link": link,
648-
"IsProd": setting.IsProd(),
648+
"RunModeIsProd": setting.IsProd(),
649649
},
650650
}
651651
// PageData is passed by reference, and it will be rendered to `window.config.pageData` in `head.tmpl` for JavaScript modules

routers/web/repo/projects.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,6 @@ func DeleteProject(ctx *context.Context) {
205205
// EditProject allows a project to be edited
206206
func EditProject(ctx *context.Context) {
207207
ctx.Data["Title"] = ctx.Tr("repo.projects.edit")
208-
ctx.Data["PageIsProjects"] = true
209208
ctx.Data["PageIsEditProjects"] = true
210209
ctx.Data["CanWriteProjects"] = ctx.Repo.Permission.CanWrite(models.UnitTypeProjects)
211210

@@ -233,7 +232,6 @@ func EditProject(ctx *context.Context) {
233232
func EditProjectPost(ctx *context.Context) {
234233
form := web.GetForm(ctx).(*forms.CreateProjectForm)
235234
ctx.Data["Title"] = ctx.Tr("repo.projects.edit")
236-
ctx.Data["PageIsProjects"] = true
237235
ctx.Data["PageIsEditProjects"] = true
238236
ctx.Data["CanWriteProjects"] = ctx.Repo.Permission.CanWrite(models.UnitTypeProjects)
239237

@@ -335,8 +333,6 @@ func ViewProject(ctx *context.Context) {
335333
ctx.Data["CanWriteProjects"] = ctx.Repo.Permission.CanWrite(models.UnitTypeProjects)
336334
ctx.Data["Project"] = project
337335
ctx.Data["Boards"] = boards
338-
ctx.Data["PageIsProjects"] = true
339-
ctx.Data["RequiresDraggable"] = true
340336

341337
ctx.HTML(http.StatusOK, tplProjectsView)
342338
}

templates/base/head.tmpl

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,41 +3,32 @@
33
<head>
44
<meta charset="utf-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1">
6-
<title>{{if .Title}}{{.Title | RenderEmojiPlain}} - {{end}} {{if .Repository.Name}}{{.Repository.Name}} - {{end}}{{AppName}} </title>
6+
<title>{{if .Title}}{{.Title | RenderEmojiPlain}} - {{end}} {{if .Repository.Name}}{{.Repository.Name}} - {{end}}{{AppName}}</title>
77
<link rel="manifest" href="data:{{.ManifestData}}"/>
88
<meta name="theme-color" content="{{ThemeColorMetaTag}}">
99
<meta name="default-theme" content="{{DefaultTheme}}" />
1010
<meta name="author" content="{{if .Repository}}{{.Owner.Name}}{{else}}{{MetaAuthor}}{{end}}" />
1111
<meta name="description" content="{{if .Repository}}{{.Repository.Name}}{{if .Repository.Description}} - {{.Repository.Description}}{{end}}{{else}}{{MetaDescription}}{{end}}" />
1212
<meta name="keywords" content="{{MetaKeywords}}">
1313
<meta name="referrer" content="no-referrer" />
14-
<meta name="_csrf" content="{{.CsrfToken}}" />
1514
{{if .GoGetImport}}
1615
<meta name="go-import" content="{{.GoGetImport}} git {{.CloneLink.HTTPS}}">
1716
<meta name="go-source" content="{{.GoGetImport}} _ {{.GoDocDirectory}} {{.GoDocFile}}">
1817
{{end}}
1918
<script>
2019
<!-- /* eslint-disable */ -->
2120
window.config = {
22-
AppVer: '{{AppVer}}',
23-
AppSubUrl: '{{AppSubUrl}}',
24-
AssetUrlPrefix: '{{AssetUrlPrefix}}',
25-
IsProd: {{.IsProd}},
26-
CustomEmojis: {{CustomEmojis}},
27-
UseServiceWorker: {{UseServiceWorker}},
28-
csrf: '{{.CsrfToken}}',
29-
pageData: {{ .PageData }},
30-
HighlightJS: {{if .RequireHighlightJS}}true{{else}}false{{end}},
31-
SimpleMDE: {{if .RequireSimpleMDE}}true{{else}}false{{end}},
32-
Tribute: {{if .RequireTribute}}true{{else}}false{{end}},
33-
NotificationSettings: {
34-
MinTimeout: {{NotificationSettings.MinTimeout}},
35-
TimeoutStep: {{NotificationSettings.TimeoutStep}},
36-
MaxTimeout: {{NotificationSettings.MaxTimeout}},
37-
EventSourceUpdateTime: {{NotificationSettings.EventSourceUpdateTime}},
38-
},
39-
EnableTimetracking: {{if EnableTimetracking}}true{{else}}false{{end}},
40-
PageIsProjects: {{if .PageIsProjects }}true{{else}}false{{end}},
21+
appVer: '{{AppVer}}',
22+
appSubUrl: '{{AppSubUrl}}',
23+
assetUrlPrefix: '{{AssetUrlPrefix}}',
24+
runModeIsProd: {{.RunModeIsProd}},
25+
customEmojis: {{CustomEmojis}},
26+
useServiceWorker: {{UseServiceWorker}},
27+
csrfToken: '{{.CsrfToken}}',
28+
pageData: {{.PageData}},
29+
requireTribute: {{.RequireTribute}},
30+
notificationSettings: {{NotificationSettings}}, {{/*a map provided by NewFuncMap in helper.go*/}}
31+
enableTimeTracking: {{EnableTimetracking}},
4132
{{if .RequireTribute}}
4233
tributeValues: Array.from(new Map([
4334
{{ range .Participants }}
@@ -54,7 +45,7 @@
5445
{{ end }}
5546
]).values()),
5647
{{end}}
57-
MermaidMaxSourceCharacters: {{MermaidMaxSourceCharacters}},
48+
mermaidMaxSourceCharacters: {{MermaidMaxSourceCharacters}},
5849
};
5950
</script>
6051
<link rel="icon" href="{{AssetUrlPrefix}}/img/logo.svg" type="image/svg+xml">

templates/repo/projects/list.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{{template "base/head" .}}
2-
<div class="page-content repository milestones">
2+
<div class="page-content repository projects milestones">
33
{{template "repo/header" .}}
44
<div class="ui container">
55
<div class="navbar">

templates/repo/projects/new.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{{template "base/head" .}}
2-
<div class="page-content repository new milestone">
2+
<div class="page-content repository projects edit-project new milestone">
33
{{template "repo/header" .}}
44
<div class="ui container">
55
<div class="navbar">

templates/repo/projects/view.tmpl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{{template "base/head" .}}
2-
<div class="page-content repository">
2+
<div class="page-content repository projects view-project">
33
{{template "repo/header" .}}
44
<div class="ui container">
55
<div class="ui two column stackable grid">
66
<div class="column">
77
{{template "repo/issue/navbar" .}}
88
</div>
99
<div class="column right aligned">
10-
{{if and .CanWriteProjects (not .Repository.IsArchived) .PageIsProjects}}
10+
{{if and .CanWriteProjects (not .Repository.IsArchived)}}
1111
<a class="ui green button show-modal item" href="{{$.RepoLink}}/issues/new?project={{$.Project.ID}}">{{.i18n.Tr "repo.issues.new"}}</a>
1212
<a class="ui green button show-modal item" data-modal="#new-board-item">{{.i18n.Tr "new_project_board"}}</a>
1313
{{end}}
@@ -80,10 +80,10 @@
8080
<div class="board">
8181
{{ range $board := .Boards }}
8282

83-
<div class="ui segment board-column" style="background: {{.Color}}!important;" data-id="{{.ID}}" data-sorting="{{.Sorting}}" data-url="{{$.RepoLink}}/projects/{{$.Project.ID}}/{{.ID}}">
83+
<div class="ui segment board-column" style="background: {{.Color}} !important;" data-id="{{.ID}}" data-sorting="{{.Sorting}}" data-url="{{$.RepoLink}}/projects/{{$.Project.ID}}/{{.ID}}">
8484
<div class="board-column-header df ac sb">
8585
<div class="ui large label board-label py-2">{{.Title}}</div>
86-
{{if and $.CanWriteProjects (not $.Repository.IsArchived) $.PageIsProjects (ne .ID 0)}}
86+
{{if and $.CanWriteProjects (not $.Repository.IsArchived) (ne .ID 0)}}
8787
<div class="ui dropdown jump item poping up" data-variation="tiny inverted">
8888
<div class="not-mobile px-3" tabindex="-1">
8989
{{svg "octicon-kebab-horizontal"}}
@@ -232,7 +232,7 @@
232232
{{if .Labels}}
233233
<div class="extra content labels-list p-0 pt-2">
234234
{{ range .Labels }}
235-
<a class="ui label" href="{{$.RepoLink}}/issues?labels={{.ID}}" style="color: {{.ForegroundColor}}; background-color: {{.Color}}" title="{{.Description | RenderEmojiPlain}}">{{.Name | RenderEmoji}}</a>
235+
<a class="ui label" href="{{$.RepoLink}}/issues?labels={{.ID}}" style="color: {{.ForegroundColor}}; background-color: {{.Color}};" title="{{.Description | RenderEmojiPlain}}">{{.Name | RenderEmoji}}</a>
236236
{{ end }}
237237
</div>
238238
{{end}}

web_src/js/components/ContextPopup.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<script>
2323
import {SvgIcon} from '../svg.js';
2424
25-
const {AppSubUrl} = window.config;
25+
const {appSubUrl} = window.config;
2626
2727
// NOTE: see models/issue_label.go for similar implementation
2828
const srgbToLinear = (color) => {
@@ -112,7 +112,7 @@ export default {
112112
methods: {
113113
load(data, callback) {
114114
this.loading = true;
115-
$.get(`${AppSubUrl}/api/v1/repos/${data.owner}/${data.repo}/issues/${data.index}`, (issue) => {
115+
$.get(`${appSubUrl}/api/v1/repos/${data.owner}/${data.repo}/issues/${data.index}`, (issue) => {
116116
this.issue = issue;
117117
this.loading = false;
118118
this.$nextTick(() => {

0 commit comments

Comments
 (0)