summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2022-04-01 16:00:26 +0800
committerGitHub <noreply@github.com>2022-04-01 16:00:26 +0800
commit5b7466053d993685939da8623fb78e94e4ee0797 (patch)
tree896d786c4dc8b692dc1fbba61ee70173593dd1b9
parent89b9d42f083b1f83ee8fc3ba0feaaa7cf04ec05b (diff)
downloadgitea-5b7466053d993685939da8623fb78e94e4ee0797.tar.gz
gitea-5b7466053d993685939da8623fb78e94e4ee0797.zip
Skip frontend ROOT_URL check on installation page, remove unnecessary global var (#19291)
Skip `checkAppUrl` message on installation page because the ROOT_URL is not determined yet Move global var `supportedDbTypeNames` into `install.Init` as a local var
-rw-r--r--routers/install/install.go16
-rw-r--r--web_src/js/features/common-global.js3
2 files changed, 10 insertions, 9 deletions
diff --git a/routers/install/install.go b/routers/install/install.go
index 164ce68405..ec1719439f 100644
--- a/routers/install/install.go
+++ b/routers/install/install.go
@@ -42,20 +42,18 @@ const (
tplPostInstall base.TplName = "post-install"
)
-var supportedDbTypeNames []map[string]string // use a slice to keep order
-func getDbTypeNames() []map[string]string {
- if supportedDbTypeNames == nil {
- for _, t := range setting.SupportedDatabaseTypes {
- supportedDbTypeNames = append(supportedDbTypeNames, map[string]string{"type": t, "name": setting.DatabaseTypeNames[t]})
- }
+// getSupportedDbTypeNames returns a slice for supported database types and names. The slice is used to keep the order
+func getSupportedDbTypeNames() (dbTypeNames []map[string]string) {
+ for _, t := range setting.SupportedDatabaseTypes {
+ dbTypeNames = append(dbTypeNames, map[string]string{"type": t, "name": setting.DatabaseTypeNames[t]})
}
- return supportedDbTypeNames
+ return dbTypeNames
}
// Init prepare for rendering installation page
func Init(next http.Handler) http.Handler {
rnd := templates.HTMLRenderer()
-
+ dbTypeNames := getSupportedDbTypeNames()
return http.HandlerFunc(func(resp http.ResponseWriter, req *http.Request) {
if setting.InstallLock {
resp.Header().Add("Refresh", "1; url="+setting.AppURL+"user/login")
@@ -74,7 +72,7 @@ func Init(next http.Handler) http.Handler {
"i18n": locale,
"Title": locale.Tr("install.install"),
"PageIsInstall": true,
- "DbTypeNames": getDbTypeNames(),
+ "DbTypeNames": dbTypeNames,
"AllLangs": translation.AllLangs(),
"PageStartTime": startTime,
diff --git a/web_src/js/features/common-global.js b/web_src/js/features/common-global.js
index 60af4d0d67..dda803ae8d 100644
--- a/web_src/js/features/common-global.js
+++ b/web_src/js/features/common-global.js
@@ -358,6 +358,9 @@ export function checkAppUrl() {
if (curUrl.startsWith(appUrl)) {
return;
}
+ if (document.querySelector('.page-content.install')) {
+ return; // no need to show the message on the installation page
+ }
showGlobalErrorMessage(`Your ROOT_URL in app.ini is ${appUrl} but you are visiting ${curUrl}
You should set ROOT_URL correctly, otherwise the web may not work correctly.`);
}