diff options
author | Panagiotis "Ivory" Vasilopoulos <git@n0toose.net> | 2023-05-29 11:32:52 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-29 11:32:52 +0000 |
commit | 35ce7ca25b5756441949312d79aa6382f98ce8d6 (patch) | |
tree | f614b73b98dd55c2af316d9806a30ebb703e2269 /templates/repo/settings | |
parent | a70d853d064a97f0be1d3702a9c3912494b546ec (diff) | |
download | gitea-35ce7ca25b5756441949312d79aa6382f98ce8d6.tar.gz gitea-35ce7ca25b5756441949312d79aa6382f98ce8d6.zip |
Hide 'Mirror Settings' when unneeded, improve hints (#24433)
Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: Giteabot <teabot@gitea.io>
Diffstat (limited to 'templates/repo/settings')
-rw-r--r-- | templates/repo/settings/options.tmpl | 40 |
1 files changed, 35 insertions, 5 deletions
diff --git a/templates/repo/settings/options.tmpl b/templates/repo/settings/options.tmpl index 83a6bc4ba1..18a5b04463 100644 --- a/templates/repo/settings/options.tmpl +++ b/templates/repo/settings/options.tmpl @@ -67,14 +67,44 @@ </div> - {{if .MirrorsEnabled}} + + {{/* These variables exist to make the logic in the Settings window easier to comprehend and are not used later on. */}} + {{$newMirrorsPartiallyEnabled := or (not .DisableNewPullMirrors) (not .DisableNewPushMirrors)}} + {{/* .Repository.IsMirror is not always reliable if the repository is not actively acting as a mirror because of errors. */}} + {{$showMirrorSettings := or $newMirrorsPartiallyEnabled .Repository.IsMirror .PullMirror .PushMirrors}} + {{$newMirrorsEntirelyEnabled := and (not .DisableNewPullMirrors) (not .DisableNewPushMirrors)}} + {{$onlyNewPushMirrorsEnabled := and (not .DisableNewPushMirrors) .DisableNewPullMirrors}} + {{$onlyNewPullMirrorsEnabled := and .DisableNewPushMirrors (not .DisableNewPullMirrors)}} + {{$existingPushMirror := or .Repository.IsMirror .PushMirrors}} + {{$modifyBrokenPullMirror := and .Repository.IsMirror (not .PullMirror)}} + {{$isWorkingPullMirror := .PullMirror}} + + {{if $showMirrorSettings}} <h4 class="ui top attached header"> {{.locale.Tr "repo.settings.mirror_settings"}} </h4> <div class="ui attached segment"> - {{$.locale.Tr "repo.settings.mirror_settings.docs" | Safe}} + {{if $newMirrorsEntirelyEnabled}} + {{$.locale.Tr "repo.settings.mirror_settings.docs"}} + <a target="_blank" rel="noopener noreferrer" href="https://docs.gitea.io/en-us/usage/repo-mirror/#pushing-to<ing-to-a-remote-repository">{{$.locale.Tr "repo.settings.mirror_settings.docs.doc_link_title"}}</a><br><br> + {{$.locale.Tr "repo.settings.mirror_settings.docs.pull_mirror_instructions"}} + <a target="_blank" rel="noopener noreferrer" href="https://docs.gitea.io/en-us/usage/repo-mirror/#pulling-from-a-remote-repository">{{$.locale.Tr "repo.settings.mirror_settings.docs.doc_link_title"}}</a><br> + {{else if $onlyNewPushMirrorsEnabled}} + {{$.locale.Tr "repo.settings.mirror_settings.docs.disabled_pull_mirror.instructions"}} + <a target="_blank" rel="noopener noreferrer" href="https://docs.gitea.io/en-us/usage/repo-mirror/#pulling-from-a-remote-repository">{{$.locale.Tr "repo.settings.mirror_settings.docs.doc_link_title"}}</a><br> + {{else if $onlyNewPullMirrorsEnabled}} + {{$.locale.Tr "repo.settings.mirror_settings.docs.disabled_push_mirror.instructions"}} + {{$.locale.Tr "repo.settings.mirror_settings.docs.disabled_push_mirror.pull_mirror_warning"}} + <a target="_blank" rel="noopener noreferrer" href="https://docs.gitea.io/en-us/usage/repo-mirror/#pulling-from-a-remote-repository">{{$.locale.Tr "repo.settings.mirror_settings.docs.doc_link_title"}}</a><br><br> + {{$.locale.Tr "repo.settings.mirror_settings.docs.disabled_push_mirror.info"}} + {{if $existingPushMirror}} + {{$.locale.Tr "repo.settings.mirror_settings.docs.can_still_use"}} + {{end}} + {{else}} + {{$.locale.Tr "repo.settings.mirror_settings.docs.no_new_mirrors"}} {{$.locale.Tr "repo.settings.mirror_settings.docs.can_still_use"}}<br> + {{end}} <table class="ui table"> - {{if or .Repository.IsMirror .PushMirrors}} + {{if $existingPushMirror}} <thead> <tr> <th style="width:40%">{{$.locale.Tr "repo.settings.mirror_settings.mirrored_repository"}}</th> @@ -84,7 +114,7 @@ </tr> </thead> {{end}} - {{if and .Repository.IsMirror (not .PullMirror)}} + {{if $modifyBrokenPullMirror}} {{/* even if a repo is a pull mirror (IsMirror=true), the PullMirror might still be nil if the mirror migration is broken */}} <tbody> <tr> @@ -93,7 +123,7 @@ </td> </tr> </tbody> - {{else if .PullMirror}} + {{else if $isWorkingPullMirror}} <tbody> <tr> <td>{{(MirrorRemoteAddress $.Context .Repository .PullMirror.GetRemoteName false).Address}}</td> |