From c65f8623e64199844a7862b52ee2514253f0d395 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Wed, 10 Jan 2024 19:55:59 +0800 Subject: [PATCH] Hide code related setting options in repository when code unit is disabled (#28631) Since #20805, code can be hidden. However, the related settings are still shown even though they don't have any meaning then. https://github.com/go-gitea/gitea/assets/81045/5fdee54d-ac81-418a-82f7-eadff048cedd --- templates/repo/settings/navbar.tmpl | 36 ++++++++++++++-------------- templates/repo/settings/options.tmpl | 2 +- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/templates/repo/settings/navbar.tmpl b/templates/repo/settings/navbar.tmpl index b16eb6076f..3bef0fa4c1 100644 --- a/templates/repo/settings/navbar.tmpl +++ b/templates/repo/settings/navbar.tmpl @@ -7,31 +7,31 @@ {{ctx.Locale.Tr "repo.settings.collaboration"}} - {{if not .Repository.IsEmpty}} - - {{ctx.Locale.Tr "repo.settings.branches"}} - - {{end}} - - {{ctx.Locale.Tr "repo.settings.tags"}} - {{if not DisableWebhooks}} {{ctx.Locale.Tr "repo.settings.hooks"}} {{end}} - {{if .SignedUser.CanEditGitHook}} - - {{ctx.Locale.Tr "repo.settings.githooks"}} + {{if and (.Repository.UnitEnabled $.Context $.UnitTypeCode) (not .Repository.IsEmpty)}} + + {{ctx.Locale.Tr "repo.settings.branches"}} - {{end}} - - {{ctx.Locale.Tr "repo.settings.deploy_keys"}} - - {{if .LFSStartServer}} - - {{ctx.Locale.Tr "repo.settings.lfs"}} + + {{ctx.Locale.Tr "repo.settings.tags"}} + {{if .SignedUser.CanEditGitHook}} + + {{ctx.Locale.Tr "repo.settings.githooks"}} + + {{end}} + + {{ctx.Locale.Tr "repo.settings.deploy_keys"}} + + {{if .LFSStartServer}} + + {{ctx.Locale.Tr "repo.settings.lfs"}} + + {{end}} {{end}} {{if and .EnableActions (not .UnitActionsGlobalDisabled) (.Permission.CanRead $.UnitTypeActions)}}
diff --git a/templates/repo/settings/options.tmpl b/templates/repo/settings/options.tmpl index 5a32f5e7ae..8456bb409b 100644 --- a/templates/repo/settings/options.tmpl +++ b/templates/repo/settings/options.tmpl @@ -66,7 +66,7 @@ {{/* 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}} + {{$showMirrorSettings := and (.Repository.UnitEnabled $.Context $.UnitTypeCode) (or $newMirrorsPartiallyEnabled .Repository.IsMirror .PullMirror .PushMirrors)}} {{$newMirrorsEntirelyEnabled := and (not .DisableNewPullMirrors) (not .DisableNewPushMirrors)}} {{$onlyNewPushMirrorsEnabled := and (not .DisableNewPushMirrors) .DisableNewPullMirrors}} {{$onlyNewPullMirrorsEnabled := and .DisableNewPushMirrors (not .DisableNewPullMirrors)}}