Skip to content

Commit 0bf7ed5

Browse files
aswildtechknowlogick
authored andcommitted
routers/repo/setting: display correct error for invalid mirror interval (#6429)
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: #6396
1 parent 93e8174 commit 0bf7ed5

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

routers/repo/setting.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,13 @@ func SettingsPost(ctx *context.Context, form auth.RepoSettingForm) {
124124
return
125125
}
126126

127+
// This section doesn't require repo_name/RepoName to be set in the form, don't show it
128+
// as an error on the UI for this action
129+
ctx.Data["Err_RepoName"] = nil
130+
127131
interval, err := time.ParseDuration(form.Interval)
128132
if err != nil || (interval != 0 && interval < setting.Mirror.MinInterval) {
133+
ctx.Data["Err_Interval"] = true
129134
ctx.RenderWithErr(ctx.Tr("repo.mirror_interval_invalid"), tplSettingsOptions, &form)
130135
} else {
131136
ctx.Repo.Mirror.EnablePrune = form.EnablePrune
@@ -136,6 +141,7 @@ func SettingsPost(ctx *context.Context, form auth.RepoSettingForm) {
136141
ctx.Repo.Mirror.NextUpdateUnix = 0
137142
}
138143
if err := models.UpdateMirror(ctx.Repo.Mirror); err != nil {
144+
ctx.Data["Err_Interval"] = true
139145
ctx.RenderWithErr(ctx.Tr("repo.mirror_interval_invalid"), tplSettingsOptions, &form)
140146
return
141147
}
@@ -161,6 +167,10 @@ func SettingsPost(ctx *context.Context, form auth.RepoSettingForm) {
161167
case "advanced":
162168
var units []models.RepoUnit
163169

170+
// This section doesn't require repo_name/RepoName to be set in the form, don't show it
171+
// as an error on the UI for this action
172+
ctx.Data["Err_RepoName"] = nil
173+
164174
for _, tp := range models.MustRepoUnits {
165175
units = append(units, models.RepoUnit{
166176
RepoID: repo.ID,

0 commit comments

Comments
 (0)