summaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorAllen Wild <aswild@users.noreply.github.com>2019-03-25 17:51:55 -0400
committertechknowlogick <matti@mdranta.net>2019-03-25 17:51:55 -0400
commit909feaafa7ca1a2529a381b2ff19c02f99e0153e (patch)
tree9eae12e6d5053796bb8a1dad7d5f4fbefeece8a9 /routers
parentd86f878b3e78acdbce0b96121cf10ba080815bda (diff)
downloadgitea-909feaafa7ca1a2529a381b2ff19c02f99e0153e.tar.gz
gitea-909feaafa7ca1a2529a381b2ff19c02f99e0153e.zip
routers/repo/setting: display correct error for invalid mirror interval (#6414)
Set Err_Interval in the context data so that the mirror interval box is highlighted red as expected. Clear Err_RepoName for the mirror and advanced actions. repo_name is not set by these forms, causing auth.validate() to set the Err_RepoName before SettingsPost is called, which would lead to the repository name box getting erroneously highlighted red. Fixes: https://github.com/go-gitea/gitea/issues/6396
Diffstat (limited to 'routers')
-rw-r--r--routers/repo/setting.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/routers/repo/setting.go b/routers/repo/setting.go
index 853c343115..d68edb4e56 100644
--- a/routers/repo/setting.go
+++ b/routers/repo/setting.go
@@ -124,8 +124,13 @@ func SettingsPost(ctx *context.Context, form auth.RepoSettingForm) {
return
}
+ // This section doesn't require repo_name/RepoName to be set in the form, don't show it
+ // as an error on the UI for this action
+ ctx.Data["Err_RepoName"] = nil
+
interval, err := time.ParseDuration(form.Interval)
if err != nil || (interval != 0 && interval < setting.Mirror.MinInterval) {
+ ctx.Data["Err_Interval"] = true
ctx.RenderWithErr(ctx.Tr("repo.mirror_interval_invalid"), tplSettingsOptions, &form)
} else {
ctx.Repo.Mirror.EnablePrune = form.EnablePrune
@@ -136,6 +141,7 @@ func SettingsPost(ctx *context.Context, form auth.RepoSettingForm) {
ctx.Repo.Mirror.NextUpdateUnix = 0
}
if err := models.UpdateMirror(ctx.Repo.Mirror); err != nil {
+ ctx.Data["Err_Interval"] = true
ctx.RenderWithErr(ctx.Tr("repo.mirror_interval_invalid"), tplSettingsOptions, &form)
return
}
@@ -161,6 +167,10 @@ func SettingsPost(ctx *context.Context, form auth.RepoSettingForm) {
case "advanced":
var units []models.RepoUnit
+ // This section doesn't require repo_name/RepoName to be set in the form, don't show it
+ // as an error on the UI for this action
+ ctx.Data["Err_RepoName"] = nil
+
for _, tp := range models.MustRepoUnits {
units = append(units, models.RepoUnit{
RepoID: repo.ID,