Frontend refactor, PascalCase to camelCase, remove unused code #17365
Labels
No Label
backport/done
backport/v1.0
backport/v1.1
backport/v1.10
backport/v1.11
backport/v1.12
backport/v1.13
backport/v1.14
backport/v1.15
backport/v1.2
backport/v1.3
backport/v1.4
backport/v1.5
backport/v1.6
backport/v1.7
backport/v1.8
backport/v1.9
bounty
changelog
dependencies
frontport/done
frontport/main
good first issue
Hacktoberfest
hacktoberfest-accepted
in progress
kind/api
kind/breaking
kind/bug
kind/build
kind/deployment
kind/deprecated
kind/docs
kind/enhancement
kind/feature
kind/lint
kind/misc
kind/moderation
kind/package
kind/proposal
kind/question
kind/refactor
kind/regression
kind/security
kind/summary
kind/testing
kind/translation
kind/ui
kind/upstream-related
kind/usability
kind/ux
lgtm/done
lgtm/need 1
lgtm/need 2
performance/bigrepo
performance/cpu
performance/memory
performance/speed
priority/critical
priority/low
priority/maybe
priority/medium
proposal/rejected
reviewed/confirmed
reviewed/duplicate
reviewed/fixed
reviewed/invalid
reviewed/not-a-bug
reviewed/wontfix
skip-changelog
stale
status/blocked
status/needs-feedback
status/wip
theme/2fa
theme/authentication
theme/avatar
theme/backup-restore
theme/docker
theme/federation
theme/issues
theme/kanban
theme/markdown
theme/migration
theme/mobile
theme/pr
theme/signing
theme/sqlite
theme/timetracker
theme/webhook
theme/wiki
No Milestone
No project
No Assignees
3 Participants
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: lunny/gitea#17365
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "frontend-rename"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
As discussed in Frontend Plan https://github.com/go-gitea/gitea/issues/17149 and https://github.com/go-gitea/gitea/pull/17315 , we'd like to use camelCase instead of PascalCase for keys in
window.config
This PR does the rename, and improve some code.
Changes:
window.config
are camelCase now.PageIsProjects
is not necessary, related templates arerepo/projects/new.tmpl
andrepo/projects/view.tmpl
, the logic is replaced by checking CSS names$('.repository.projects')
RequiresDraggable
inrepo/projects.go
is never used in whole project, so it is removed. Here was a bug: guest users can also drag the issues between board (the update is denied of course), this PR doesn't touch it, it may be fixed in future.csrf
is renamed tocsrfToken
to make it clear, it is a token.HighlightJS
is never used in whole project and removed. The usage of template data.RequireHighlightJS
is documented so keep it as it is.SimpleMDE
is never used and removed.NotificationSettings
is rendered directly by the map generated by backend<meta name="_csrf" content="{{.CsrfToken}}" />
in<head>
is removed, no code uses it, and we already havecsrfToken
inwindow.config
.This PR may break something if some users are using
window.config.HighlightJS
orwindow.config.SimpleMDE
, so I think we mark this PR as a breaking change. Users who require these two options can check or inject {{.RequireHighlightJS}} or {{.RequireSimpleMDE}} in their own custom templates.@ -54,7 +45,7 @@
{{ end }}
Maybe expose
runMode
directly? Thought it would have to be compared insensitively, e.g.runMode.toLowerCase() === 'prod'
.@ -54,7 +45,7 @@
{{ end }}
But it's not guaranteed what value a user may set, the backend code is:
I do not want to touch it or couple with the setting option logic.
If we use
runMode.toLowerCase() === 'prod'
in front code, then we have two magic stringsprod
....I like magic but I do not like magic values. ?
@ -54,7 +45,7 @@
{{ end }}
Okay we can keep it as boolean, but I'd suggest shortening to
isProd
.@ -54,7 +45,7 @@
{{ end }}
It was
isProd
but it was too short, I worry about the name conflicts with others, so I changed the name a little longer. For global names, a little longer really helps, we can search the name easily from all files.runModeIsProd
is still shorter thanassetUrlPrefix
anyway, and we still have a chance to introducerunModeValue
in future.Are you sure that SimpleMDE is no longer needed anymore?
Isn't that a separate pull request that is quite a bit larger (#15394)?
@ -3,3 +3,3 @@
import {joinPaths} from './utils.js';
const {AssetUrlPrefix} = window.config;
const {assetUrlPrefix} = window.config;
Since GitHub suddenly decided to break multiline suggestions, here you have it in two separate suggestions.
No, I won't touch existing logic if it is unrelated during the refactoring. I only change the code it has to be changed.
@ -3,3 +3,3 @@
import {joinPaths} from './utils.js';
const {AssetUrlPrefix} = window.config;
const {assetUrlPrefix} = window.config;
No, I won't touch existing logic if it is unrelated during the refactoring. I only change the code it has to be changed.