Ensure minimum mirror interval is reported on settings page (#19895)
* Ensure minimum mirror interval is reported on settings page Expecting users to guess the minimum mirror interval appears a little unkind. In this PR we simply change the locale string to include the minimum interval. This will of course be affected by our current localization framework but... we can fix that else where. This PR also includes some fixes for error handling on the settings page as previously the mirror block amongst others would simply disappear on error. Fix #3737 Signed-off-by: Andrew Thornton <art27@cantab.net> * Update options/locale/locale_en-US.ini Co-authored-by: Gusted <williamzijl7@hotmail.com> * placate lint Signed-off-by: Andrew Thornton <art27@cantab.net> * Update options/locale/locale_en-US.ini Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: Gusted <williamzijl7@hotmail.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
This commit is contained in:
parent
81cf006863
commit
d8236f1b16
3 changed files with 25 additions and 12 deletions
|
@ -860,7 +860,7 @@ default_branch = Default Branch
|
||||||
default_branch_helper = The default branch is the base branch for pull requests and code commits.
|
default_branch_helper = The default branch is the base branch for pull requests and code commits.
|
||||||
mirror_prune = Prune
|
mirror_prune = Prune
|
||||||
mirror_prune_desc = Remove obsolete remote-tracking references
|
mirror_prune_desc = Remove obsolete remote-tracking references
|
||||||
mirror_interval = Mirror Interval (valid time units are 'h', 'm', 's'). 0 to disable automatic sync.
|
mirror_interval = Mirror Interval (valid time units are 'h', 'm', 's'). 0 to disable automatic sync. (Minimum interval: %s)
|
||||||
mirror_interval_invalid = The mirror interval is not valid.
|
mirror_interval_invalid = The mirror interval is not valid.
|
||||||
mirror_address = Clone From URL
|
mirror_address = Clone From URL
|
||||||
mirror_address_desc = Put any required credentials in the Authorization section.
|
mirror_address_desc = Put any required credentials in the Authorization section.
|
||||||
|
|
|
@ -65,11 +65,13 @@ func Settings(ctx *context.Context) {
|
||||||
ctx.Data["MirrorsEnabled"] = setting.Mirror.Enabled
|
ctx.Data["MirrorsEnabled"] = setting.Mirror.Enabled
|
||||||
ctx.Data["DisableNewPushMirrors"] = setting.Mirror.DisableNewPush
|
ctx.Data["DisableNewPushMirrors"] = setting.Mirror.DisableNewPush
|
||||||
ctx.Data["DefaultMirrorInterval"] = setting.Mirror.DefaultInterval
|
ctx.Data["DefaultMirrorInterval"] = setting.Mirror.DefaultInterval
|
||||||
|
ctx.Data["MinimumMirrorInterval"] = setting.Mirror.MinInterval
|
||||||
|
|
||||||
signing, _ := asymkey_service.SigningKey(ctx, ctx.Repo.Repository.RepoPath())
|
signing, _ := asymkey_service.SigningKey(ctx, ctx.Repo.Repository.RepoPath())
|
||||||
ctx.Data["SigningKeyAvailable"] = len(signing) > 0
|
ctx.Data["SigningKeyAvailable"] = len(signing) > 0
|
||||||
ctx.Data["SigningSettings"] = setting.Repository.Signing
|
ctx.Data["SigningSettings"] = setting.Repository.Signing
|
||||||
ctx.Data["CodeIndexerEnabled"] = setting.Indexer.RepoIndexerEnabled
|
ctx.Data["CodeIndexerEnabled"] = setting.Indexer.RepoIndexerEnabled
|
||||||
|
|
||||||
if ctx.Doer.IsAdmin {
|
if ctx.Doer.IsAdmin {
|
||||||
if setting.Indexer.RepoIndexerEnabled {
|
if setting.Indexer.RepoIndexerEnabled {
|
||||||
status, err := repo_model.GetIndexerStatus(ctx, ctx.Repo.Repository, repo_model.RepoIndexerTypeCode)
|
status, err := repo_model.GetIndexerStatus(ctx, ctx.Repo.Repository, repo_model.RepoIndexerTypeCode)
|
||||||
|
@ -102,6 +104,17 @@ func SettingsPost(ctx *context.Context) {
|
||||||
ctx.Data["Title"] = ctx.Tr("repo.settings")
|
ctx.Data["Title"] = ctx.Tr("repo.settings")
|
||||||
ctx.Data["PageIsSettingsOptions"] = true
|
ctx.Data["PageIsSettingsOptions"] = true
|
||||||
|
|
||||||
|
ctx.Data["ForcePrivate"] = setting.Repository.ForcePrivate
|
||||||
|
ctx.Data["MirrorsEnabled"] = setting.Mirror.Enabled
|
||||||
|
ctx.Data["DisableNewPushMirrors"] = setting.Mirror.DisableNewPush
|
||||||
|
ctx.Data["DefaultMirrorInterval"] = setting.Mirror.DefaultInterval
|
||||||
|
ctx.Data["MinimumMirrorInterval"] = setting.Mirror.MinInterval
|
||||||
|
|
||||||
|
signing, _ := asymkey_service.SigningKey(ctx, ctx.Repo.Repository.RepoPath())
|
||||||
|
ctx.Data["SigningKeyAvailable"] = len(signing) > 0
|
||||||
|
ctx.Data["SigningSettings"] = setting.Repository.Signing
|
||||||
|
ctx.Data["CodeIndexerEnabled"] = setting.Indexer.RepoIndexerEnabled
|
||||||
|
|
||||||
repo := ctx.Repo.Repository
|
repo := ctx.Repo.Repository
|
||||||
|
|
||||||
switch ctx.FormString("action") {
|
switch ctx.FormString("action") {
|
||||||
|
@ -191,15 +204,15 @@ func SettingsPost(ctx *context.Context) {
|
||||||
if err != nil || (interval != 0 && interval < setting.Mirror.MinInterval) {
|
if err != nil || (interval != 0 && interval < setting.Mirror.MinInterval) {
|
||||||
ctx.Data["Err_Interval"] = true
|
ctx.Data["Err_Interval"] = true
|
||||||
ctx.RenderWithErr(ctx.Tr("repo.mirror_interval_invalid"), tplSettingsOptions, &form)
|
ctx.RenderWithErr(ctx.Tr("repo.mirror_interval_invalid"), tplSettingsOptions, &form)
|
||||||
} else {
|
return
|
||||||
ctx.Repo.Mirror.EnablePrune = form.EnablePrune
|
}
|
||||||
ctx.Repo.Mirror.Interval = interval
|
|
||||||
ctx.Repo.Mirror.ScheduleNextUpdate()
|
ctx.Repo.Mirror.EnablePrune = form.EnablePrune
|
||||||
if err := repo_model.UpdateMirror(ctx, ctx.Repo.Mirror); err != nil {
|
ctx.Repo.Mirror.Interval = interval
|
||||||
ctx.Data["Err_Interval"] = true
|
ctx.Repo.Mirror.ScheduleNextUpdate()
|
||||||
ctx.RenderWithErr(ctx.Tr("repo.mirror_interval_invalid"), tplSettingsOptions, &form)
|
if err := repo_model.UpdateMirror(ctx, ctx.Repo.Mirror); err != nil {
|
||||||
return
|
ctx.ServerError("UpdateMirror", err)
|
||||||
}
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
u, _ := git.GetRemoteAddress(ctx, ctx.Repo.Repository.RepoPath(), ctx.Repo.Mirror.GetRemoteName())
|
u, _ := git.GetRemoteAddress(ctx, ctx.Repo.Repository.RepoPath(), ctx.Repo.Mirror.GetRemoteName())
|
||||||
|
|
|
@ -116,7 +116,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="inline field {{if .Err_Interval}}error{{end}}">
|
<div class="inline field {{if .Err_Interval}}error{{end}}">
|
||||||
<label for="interval">{{.i18n.Tr "repo.mirror_interval"}}</label>
|
<label for="interval">{{.i18n.Tr "repo.mirror_interval" .MinimumMirrorInterval}}</label>
|
||||||
<input id="interval" name="interval" value="{{.MirrorInterval}}">
|
<input id="interval" name="interval" value="{{.MirrorInterval}}">
|
||||||
</div>
|
</div>
|
||||||
{{$address := MirrorRemoteAddress $.Context .Mirror}}
|
{{$address := MirrorRemoteAddress $.Context .Mirror}}
|
||||||
|
@ -220,7 +220,7 @@
|
||||||
</div>
|
</div>
|
||||||
</details>
|
</details>
|
||||||
<div class="inline field {{if .Err_PushMirrorInterval}}error{{end}}">
|
<div class="inline field {{if .Err_PushMirrorInterval}}error{{end}}">
|
||||||
<label for="push_mirror_interval">{{.i18n.Tr "repo.mirror_interval"}}</label>
|
<label for="push_mirror_interval">{{.i18n.Tr "repo.mirror_interval" .MinimumMirrorInterval}}</label>
|
||||||
<input id="push_mirror_interval" name="push_mirror_interval" value="{{if .push_mirror_interval}}{{.push_mirror_interval}}{{else}}{{.DefaultMirrorInterval}}{{end}}">
|
<input id="push_mirror_interval" name="push_mirror_interval" value="{{if .push_mirror_interval}}{{.push_mirror_interval}}{{else}}{{.DefaultMirrorInterval}}{{end}}">
|
||||||
</div>
|
</div>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
|
|
Loading…
Reference in a new issue