Refactor startup deprecation messages (#30305)

It doesn't change logic, it only does:

1. Rename the variable and function names
2. Use more consistent format when mentioning config section&key
3. Improve some messages
This commit is contained in:
2024-04-07 09:11:25 +08:00
committed by GitHub
parent 48223909be
commit bbe5cd7c92
11 changed files with 30 additions and 28 deletions

View File

@ -117,11 +117,11 @@ func updateSystemStatus() {
sysStatus.NumGC = m.NumGC
}
func prepareDeprecatedWarningsAlert(ctx *context.Context) {
if len(setting.DeprecatedWarnings) > 0 {
content := setting.DeprecatedWarnings[0]
if len(setting.DeprecatedWarnings) > 1 {
content += fmt.Sprintf(" (and %d more)", len(setting.DeprecatedWarnings)-1)
func prepareStartupProblemsAlert(ctx *context.Context) {
if len(setting.StartupProblems) > 0 {
content := setting.StartupProblems[0]
if len(setting.StartupProblems) > 1 {
content += fmt.Sprintf(" (and %d more)", len(setting.StartupProblems)-1)
}
ctx.Flash.Error(content, true)
}
@ -136,7 +136,7 @@ func Dashboard(ctx *context.Context) {
updateSystemStatus()
ctx.Data["SysStatus"] = sysStatus
ctx.Data["SSH"] = setting.SSH
prepareDeprecatedWarningsAlert(ctx)
prepareStartupProblemsAlert(ctx)
ctx.HTML(http.StatusOK, tplDashboard)
}
@ -191,10 +191,10 @@ func DashboardPost(ctx *context.Context) {
func SelfCheck(ctx *context.Context) {
ctx.Data["PageIsAdminSelfCheck"] = true
ctx.Data["DeprecatedWarnings"] = setting.DeprecatedWarnings
if len(setting.DeprecatedWarnings) == 0 && !setting.IsProd {
ctx.Data["StartupProblems"] = setting.StartupProblems
if len(setting.StartupProblems) == 0 && !setting.IsProd {
if time.Now().Unix()%2 == 0 {
ctx.Data["DeprecatedWarnings"] = []string{"This is a test warning message in dev mode"}
ctx.Data["StartupProblems"] = []string{"This is a test warning message in dev mode"}
}
}