From 3f0a39a57a66279a686e741cf7db3ba77edfa8a9 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Thu, 28 Dec 2023 18:42:35 +0800 Subject: [PATCH 1/2] Hide code related setting options in repository when code unit is disabled --- templates/repo/settings/navbar.tmpl | 40 ++++++++++++++-------------- templates/repo/settings/options.tmpl | 2 +- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/templates/repo/settings/navbar.tmpl b/templates/repo/settings/navbar.tmpl index b16eb6076fad5..3c2c2b564d3d5 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}} + {{if and (.Repository.UnitEnabled $.Context $.UnitTypeCode) (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"}} + + {{ctx.Locale.Tr "repo.settings.tags"}} - {{end}} - {{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"}} + {{if not DisableWebhooks}} + + {{ctx.Locale.Tr "repo.settings.hooks"}} + + {{end}} + {{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 5a32f5e7ae1a1..8456bb409b358 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)}} From 6d2b2b7c24dcf2c53dae97c229c1262e41bcc963 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sun, 7 Jan 2024 16:47:03 +0800 Subject: [PATCH 2/2] webhook is shared by code and other units --- templates/repo/settings/navbar.tmpl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/templates/repo/settings/navbar.tmpl b/templates/repo/settings/navbar.tmpl index 3c2c2b564d3d5..3bef0fa4c143d 100644 --- a/templates/repo/settings/navbar.tmpl +++ b/templates/repo/settings/navbar.tmpl @@ -7,6 +7,11 @@ {{ctx.Locale.Tr "repo.settings.collaboration"}} + {{if not DisableWebhooks}} + + {{ctx.Locale.Tr "repo.settings.hooks"}} + + {{end}} {{if and (.Repository.UnitEnabled $.Context $.UnitTypeCode) (not .Repository.IsEmpty)}} {{ctx.Locale.Tr "repo.settings.branches"}} @@ -14,11 +19,6 @@ {{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"}}