Skip to content

Commit c65f862

Browse files
authored
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
1 parent 839cd26 commit c65f862

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

templates/repo/settings/navbar.tmpl

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,31 @@
77
<a class="{{if .PageIsSettingsCollaboration}}active {{end}}item" href="{{.RepoLink}}/settings/collaboration">
88
{{ctx.Locale.Tr "repo.settings.collaboration"}}
99
</a>
10-
{{if not .Repository.IsEmpty}}
11-
<a class="{{if .PageIsSettingsBranches}}active {{end}}item" href="{{.RepoLink}}/settings/branches">
12-
{{ctx.Locale.Tr "repo.settings.branches"}}
13-
</a>
14-
{{end}}
15-
<a class="{{if .PageIsSettingsTags}}active {{end}}item" href="{{.RepoLink}}/settings/tags">
16-
{{ctx.Locale.Tr "repo.settings.tags"}}
17-
</a>
1810
{{if not DisableWebhooks}}
1911
<a class="{{if .PageIsSettingsHooks}}active {{end}}item" href="{{.RepoLink}}/settings/hooks">
2012
{{ctx.Locale.Tr "repo.settings.hooks"}}
2113
</a>
2214
{{end}}
23-
{{if .SignedUser.CanEditGitHook}}
24-
<a class="{{if .PageIsSettingsGitHooks}}active {{end}}item" href="{{.RepoLink}}/settings/hooks/git">
25-
{{ctx.Locale.Tr "repo.settings.githooks"}}
15+
{{if and (.Repository.UnitEnabled $.Context $.UnitTypeCode) (not .Repository.IsEmpty)}}
16+
<a class="{{if .PageIsSettingsBranches}}active {{end}}item" href="{{.RepoLink}}/settings/branches">
17+
{{ctx.Locale.Tr "repo.settings.branches"}}
2618
</a>
27-
{{end}}
28-
<a class="{{if .PageIsSettingsKeys}}active {{end}}item" href="{{.RepoLink}}/settings/keys">
29-
{{ctx.Locale.Tr "repo.settings.deploy_keys"}}
30-
</a>
31-
{{if .LFSStartServer}}
32-
<a class="{{if .PageIsSettingsLFS}}active {{end}}item" href="{{.RepoLink}}/settings/lfs">
33-
{{ctx.Locale.Tr "repo.settings.lfs"}}
19+
<a class="{{if .PageIsSettingsTags}}active {{end}}item" href="{{.RepoLink}}/settings/tags">
20+
{{ctx.Locale.Tr "repo.settings.tags"}}
3421
</a>
22+
{{if .SignedUser.CanEditGitHook}}
23+
<a class="{{if .PageIsSettingsGitHooks}}active {{end}}item" href="{{.RepoLink}}/settings/hooks/git">
24+
{{ctx.Locale.Tr "repo.settings.githooks"}}
25+
</a>
26+
{{end}}
27+
<a class="{{if .PageIsSettingsKeys}}active {{end}}item" href="{{.RepoLink}}/settings/keys">
28+
{{ctx.Locale.Tr "repo.settings.deploy_keys"}}
29+
</a>
30+
{{if .LFSStartServer}}
31+
<a class="{{if .PageIsSettingsLFS}}active {{end}}item" href="{{.RepoLink}}/settings/lfs">
32+
{{ctx.Locale.Tr "repo.settings.lfs"}}
33+
</a>
34+
{{end}}
3535
{{end}}
3636
{{if and .EnableActions (not .UnitActionsGlobalDisabled) (.Permission.CanRead $.UnitTypeActions)}}
3737
<details class="item toggleable-item" {{if or .PageIsSharedSettingsRunners .PageIsSharedSettingsSecrets .PageIsSharedSettingsVariables}}open{{end}}>

templates/repo/settings/options.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
{{/* These variables exist to make the logic in the Settings window easier to comprehend and are not used later on. */}}
6767
{{$newMirrorsPartiallyEnabled := or (not .DisableNewPullMirrors) (not .DisableNewPushMirrors)}}
6868
{{/* .Repository.IsMirror is not always reliable if the repository is not actively acting as a mirror because of errors. */}}
69-
{{$showMirrorSettings := or $newMirrorsPartiallyEnabled .Repository.IsMirror .PullMirror .PushMirrors}}
69+
{{$showMirrorSettings := and (.Repository.UnitEnabled $.Context $.UnitTypeCode) (or $newMirrorsPartiallyEnabled .Repository.IsMirror .PullMirror .PushMirrors)}}
7070
{{$newMirrorsEntirelyEnabled := and (not .DisableNewPullMirrors) (not .DisableNewPushMirrors)}}
7171
{{$onlyNewPushMirrorsEnabled := and (not .DisableNewPushMirrors) .DisableNewPullMirrors}}
7272
{{$onlyNewPullMirrorsEnabled := and .DisableNewPushMirrors (not .DisableNewPullMirrors)}}

0 commit comments

Comments
 (0)