Skip to content

Commit 2fd0b7a

Browse files
committed
fix
1 parent 58b204b commit 2fd0b7a

22 files changed

+369
-363
lines changed

models/organization/team.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -174,23 +174,27 @@ func (t *Team) LoadMembers(ctx context.Context) (err error) {
174174
return err
175175
}
176176

177-
// UnitEnabled returns if the team has the given unit type enabled
177+
// UnitEnabled returns true if the team has the given unit type enabled
178178
func (t *Team) UnitEnabled(ctx context.Context, tp unit.Type) bool {
179179
return t.UnitAccessMode(ctx, tp) > perm.AccessModeNone
180180
}
181181

182-
// UnitAccessMode returns if the team has the given unit type enabled
182+
// UnitAccessMode returns the access mode for the given unit type, "none" for non-existent units
183183
func (t *Team) UnitAccessMode(ctx context.Context, tp unit.Type) perm.AccessMode {
184+
accessMode, _ := t.UnitAccessModeEx(ctx, tp)
185+
return accessMode
186+
}
187+
188+
func (t *Team) UnitAccessModeEx(ctx context.Context, tp unit.Type) (accessMode perm.AccessMode, exist bool) {
184189
if err := t.LoadUnits(ctx); err != nil {
185190
log.Warn("Error loading team (ID: %d) units: %s", t.ID, err.Error())
186191
}
187-
188-
for _, unit := range t.Units {
189-
if unit.Type == tp {
190-
return unit.AccessMode
192+
for _, u := range t.Units {
193+
if u.Type == tp {
194+
return u.AccessMode, true
191195
}
192196
}
193-
return perm.AccessModeNone
197+
return perm.AccessModeNone, false
194198
}
195199

196200
// IsUsableTeamName tests if a name could be as team name

models/perm/access/repo_permission.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -229,12 +229,8 @@ func GetUserRepoPermission(ctx context.Context, repo *repo_model.Repository, use
229229
for _, u := range repo.Units {
230230
var found bool
231231
for _, team := range teams {
232-
teamMode := team.UnitAccessMode(ctx, u.Type)
233-
if teamMode > perm_model.AccessModeNone {
234-
m := perm.UnitsMode[u.Type]
235-
if m < teamMode {
236-
perm.UnitsMode[u.Type] = teamMode
237-
}
232+
if teamMode, exist := team.UnitAccessModeEx(ctx, u.Type); exist {
233+
perm.UnitsMode[u.Type] = max(perm.UnitsMode[u.Type], teamMode)
238234
found = true
239235
}
240236
}

routers/web/web.go

Lines changed: 264 additions & 253 deletions
Large diffs are not rendered by default.

services/context/context.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,18 @@ func NewTemplateContextForWeb(ctx *Context) TemplateContext {
102102
tmplCtx["Locale"] = ctx.Base.Locale
103103
tmplCtx["AvatarUtils"] = templates.NewAvatarUtils(ctx)
104104
tmplCtx["RootData"] = ctx.Data
105+
tmplCtx["Consts"] = map[string]any{
106+
"RepoUnitTypeCode": unit.TypeCode,
107+
"RepoUnitTypeIssues": unit.TypeIssues,
108+
"RepoUnitTypePullRequests": unit.TypePullRequests,
109+
"RepoUnitTypeReleases": unit.TypeReleases,
110+
"RepoUnitTypeWiki": unit.TypeWiki,
111+
"RepoUnitTypeExternalWiki": unit.TypeExternalWiki,
112+
"RepoUnitTypeExternalTracker": unit.TypeExternalTracker,
113+
"RepoUnitTypeProjects": unit.TypeProjects,
114+
"RepoUnitTypePackages": unit.TypePackages,
115+
"RepoUnitTypeActions": unit.TypeActions,
116+
}
105117
return tmplCtx
106118
}
107119

services/context/repo.go

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,6 @@ func repoAssignment(ctx *Context, repo *repo_model.Repository) {
383383
ctx.NotFound("no access right", nil)
384384
return
385385
}
386-
ctx.Data["HasAccess"] = true
387386
ctx.Data["Permission"] = &ctx.Repo.Permission
388387

389388
if repo.IsMirror {
@@ -1052,19 +1051,3 @@ func GitHookService() func(ctx *Context) {
10521051
}
10531052
}
10541053
}
1055-
1056-
// UnitTypes returns a middleware to set unit types to context variables.
1057-
func UnitTypes() func(ctx *Context) {
1058-
return func(ctx *Context) {
1059-
ctx.Data["UnitTypeCode"] = unit_model.TypeCode
1060-
ctx.Data["UnitTypeIssues"] = unit_model.TypeIssues
1061-
ctx.Data["UnitTypePullRequests"] = unit_model.TypePullRequests
1062-
ctx.Data["UnitTypeReleases"] = unit_model.TypeReleases
1063-
ctx.Data["UnitTypeWiki"] = unit_model.TypeWiki
1064-
ctx.Data["UnitTypeExternalWiki"] = unit_model.TypeExternalWiki
1065-
ctx.Data["UnitTypeExternalTracker"] = unit_model.TypeExternalTracker
1066-
ctx.Data["UnitTypeProjects"] = unit_model.TypeProjects
1067-
ctx.Data["UnitTypePackages"] = unit_model.TypePackages
1068-
ctx.Data["UnitTypeActions"] = unit_model.TypeActions
1069-
}
1070-
}

templates/explore/navbar.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<a class="{{if .PageIsExploreOrganizations}}active {{end}}item" href="{{AppSubUrl}}/explore/organizations">
1212
{{svg "octicon-organization"}} {{ctx.Locale.Tr "explore.organizations"}}
1313
</a>
14-
{{if and (not $.UnitTypeCode.UnitGlobalDisabled) .IsRepoIndexerEnabled}}
14+
{{if and (not ctx.Consts.RepoUnitTypeCode.UnitGlobalDisabled) .IsRepoIndexerEnabled}}
1515
<a class="{{if .PageIsExploreCode}}active {{end}}item" href="{{AppSubUrl}}/explore/code">
1616
{{svg "octicon-code"}} {{ctx.Locale.Tr "explore.code"}}
1717
</a>

templates/repo/blame.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
</table>
8181
{{end}}{{/* end if .IsFileTooLarge */}}
8282
<div class="code-line-menu tippy-target">
83-
{{if $.Permission.CanRead $.UnitTypeIssues}}
83+
{{if $.Permission.CanRead ctx.Consts.RepoUnitTypeIssues}}
8484
<a class="item ref-in-new-issue" role="menuitem" data-url-issue-new="{{.RepoLink}}/issues/new" data-url-param-body-link="{{.Repository.Link}}/src/commit/{{PathEscape .CommitID}}/{{PathEscapeSegments .TreePath}}{{if $.HasSourceRenderedToggle}}?display=source{{end}}" rel="nofollow noindex">{{ctx.Locale.Tr "repo.issues.context.reference_issue"}}</a>
8585
{{end}}
8686
<a class="item copy-line-permalink" role="menuitem" data-url="{{.Repository.Link}}/src/commit/{{PathEscape .CommitID}}/{{PathEscapeSegments .TreePath}}{{if $.HasSourceRenderedToggle}}?display=source{{end}}">{{ctx.Locale.Tr "repo.file_copy_permalink"}}</a>

templates/repo/code_frequency.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{if .Permission.CanRead $.UnitTypeCode}}
1+
{{if .Permission.CanRead ctx.Consts.RepoUnitTypeCode}}
22
<div id="repo-code-frequency-chart"
33
data-locale-loading-title="{{ctx.Locale.Tr "graphs.component_loading" (ctx.Locale.Tr "graphs.code_frequency.what")}}"
44
data-locale-loading-title-failed="{{ctx.Locale.Tr "graphs.component_loading_failed" (ctx.Locale.Tr "graphs.code_frequency.what")}}"

templates/repo/commit_page.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<a class="ui primary tiny button" href="{{.SourcePath}}">
2626
{{ctx.Locale.Tr "repo.diff.browse_source"}}
2727
</a>
28-
{{if and ($.Permission.CanWrite $.UnitTypeCode) (not $.Repository.IsArchived) (not .IsDeleted)}}{{- /* */ -}}
28+
{{if and ($.Permission.CanWrite ctx.Consts.RepoUnitTypeCode) (not $.Repository.IsArchived) (not .IsDeleted)}}{{- /* */ -}}
2929
<div class="ui dropdown primary tiny button">
3030
{{ctx.Locale.Tr "repo.commit.operations"}}
3131
{{svg "octicon-triangle-down" 14 "dropdown icon"}}

templates/repo/contributors.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{if .Permission.CanRead $.UnitTypeCode}}
1+
{{if .Permission.CanRead ctx.Consts.RepoUnitTypeCode}}
22
<div id="repo-contributors-chart"
33
data-locale-filter-label="{{ctx.Locale.Tr "repo.contributors.contribution_type.filter_label"}}"
44
data-locale-contribution-type-commits="{{ctx.Locale.Tr "repo.contributors.contribution_type.commits"}}"

templates/repo/graph/commits.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
{{if eq $refGroup "pull"}}
3838
{{if or (not $.HidePRRefs) (SliceUtils.Contains $.SelectedBranches .Name)}}
3939
<!-- it's intended to use issues not pulls, if it's a pull you will get redirected -->
40-
<a class="ui labelled basic tiny button" href="{{$.RepoLink}}/{{if $.Repository.UnitEnabled $.Context $.UnitTypePullRequests}}pulls{{else}}issues{{end}}/{{.ShortName|PathEscape}}">
40+
<a class="ui labelled basic tiny button" href="{{$.RepoLink}}/{{if $.Repository.UnitEnabled $.Context ctx.Consts.RepoUnitTypePullRequests}}pulls{{else}}issues{{end}}/{{.ShortName|PathEscape}}">
4141
{{svg "octicon-git-pull-request"}} #{{.ShortName}}
4242
</a>
4343
{{end}}

templates/repo/header.tmpl

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
{{if not $.DisableStars}}
6565
{{template "repo/star_unstar" $}}
6666
{{end}}
67-
{{if and (not .IsEmpty) ($.Permission.CanRead $.UnitTypeCode)}}
67+
{{if and (not .IsEmpty) ($.Permission.CanRead ctx.Consts.RepoUnitTypeCode)}}
6868
<div class="ui labeled button
6969
{{if or (not $.IsSigned) (and (not $.CanSignedUserFork) (not $.UserAndOrgForks))}}
7070
disabled
@@ -131,13 +131,13 @@
131131
<overflow-menu class="ui container secondary pointing tabular top attached borderless menu tw-pt-0 tw-my-0">
132132
{{if not (or .Repository.IsBeingCreated .Repository.IsBroken)}}
133133
<div class="overflow-menu-items">
134-
{{if .Permission.CanRead $.UnitTypeCode}}
134+
{{if .Permission.CanRead ctx.Consts.RepoUnitTypeCode}}
135135
<a class="{{if .PageIsViewCode}}active {{end}}item" href="{{.RepoLink}}{{if and (ne .BranchName .Repository.DefaultBranch) (not $.PageIsWiki)}}/src/{{.BranchNameSubURL}}{{end}}">
136136
{{svg "octicon-code"}} {{ctx.Locale.Tr "repo.code"}}
137137
</a>
138138
{{end}}
139139

140-
{{if .Permission.CanRead $.UnitTypeIssues}}
140+
{{if .Permission.CanRead ctx.Consts.RepoUnitTypeIssues}}
141141
<a class="{{if .PageIsIssueList}}active {{end}}item" href="{{.RepoLink}}/issues">
142142
{{svg "octicon-issue-opened"}} {{ctx.Locale.Tr "repo.issues"}}
143143
{{if .Repository.NumOpenIssues}}
@@ -146,13 +146,13 @@
146146
</a>
147147
{{end}}
148148

149-
{{if .Permission.CanRead $.UnitTypeExternalTracker}}
149+
{{if .Permission.CanRead ctx.Consts.RepoUnitTypeExternalTracker}}
150150
<a class="{{if .PageIsIssueList}}active {{end}}item" href="{{.RepoExternalIssuesLink}}" target="_blank" rel="noopener noreferrer">
151151
{{svg "octicon-link-external"}} {{ctx.Locale.Tr "repo.issues"}}
152152
</a>
153153
{{end}}
154154

155-
{{if and .Repository.CanEnablePulls (.Permission.CanRead $.UnitTypePullRequests)}}
155+
{{if and .Repository.CanEnablePulls (.Permission.CanRead ctx.Consts.RepoUnitTypePullRequests)}}
156156
<a class="{{if .PageIsPullList}}active {{end}}item" href="{{.RepoLink}}/pulls">
157157
{{svg "octicon-git-pull-request"}} {{ctx.Locale.Tr "repo.pulls"}}
158158
{{if .Repository.NumOpenPulls}}
@@ -161,7 +161,7 @@
161161
</a>
162162
{{end}}
163163

164-
{{if and .EnableActions (not .UnitActionsGlobalDisabled) (.Permission.CanRead $.UnitTypeActions)}}
164+
{{if and .EnableActions (not .UnitActionsGlobalDisabled) (.Permission.CanRead ctx.Consts.RepoUnitTypeActions)}}
165165
<a class="{{if .PageIsActions}}active {{end}}item" href="{{.RepoLink}}/actions">
166166
{{svg "octicon-play"}} {{ctx.Locale.Tr "actions.actions"}}
167167
{{if .Repository.NumOpenActionRuns}}
@@ -170,14 +170,14 @@
170170
</a>
171171
{{end}}
172172

173-
{{if .Permission.CanRead $.UnitTypePackages}}
173+
{{if .Permission.CanRead ctx.Consts.RepoUnitTypePackages}}
174174
<a href="{{.RepoLink}}/packages" class="{{if .IsPackagesPage}}active {{end}}item">
175175
{{svg "octicon-package"}} {{ctx.Locale.Tr "packages.title"}}
176176
</a>
177177
{{end}}
178178

179-
{{$projectsUnit := .Repository.MustGetUnit $.Context $.UnitTypeProjects}}
180-
{{if and (not .UnitProjectsGlobalDisabled) (.Permission.CanRead $.UnitTypeProjects) ($projectsUnit.ProjectsConfig.IsProjectsAllowed "repo")}}
179+
{{$projectsUnit := .Repository.MustGetUnit $.Context ctx.Consts.RepoUnitTypeProjects}}
180+
{{if and (not .UnitProjectsGlobalDisabled) (.Permission.CanRead ctx.Consts.RepoUnitTypeProjects) ($projectsUnit.ProjectsConfig.IsProjectsAllowed "repo")}}
181181
<a href="{{.RepoLink}}/projects" class="{{if .IsProjectsPage}}active {{end}}item">
182182
{{svg "octicon-project"}} {{ctx.Locale.Tr "repo.project_board"}}
183183
{{if .Repository.NumOpenProjects}}
@@ -186,7 +186,7 @@
186186
</a>
187187
{{end}}
188188

189-
{{if and (.Permission.CanRead $.UnitTypeReleases) (not .IsEmptyRepo)}}
189+
{{if and (.Permission.CanRead ctx.Consts.RepoUnitTypeReleases) (not .IsEmptyRepo)}}
190190
<a class="{{if or .PageIsReleaseList .PageIsTagList}}active {{end}}item" href="{{.RepoLink}}/releases">
191191
{{svg "octicon-tag"}} {{ctx.Locale.Tr "repo.releases"}}
192192
{{if .NumReleases}}
@@ -195,19 +195,19 @@
195195
</a>
196196
{{end}}
197197

198-
{{if .Permission.CanRead $.UnitTypeWiki}}
198+
{{if .Permission.CanRead ctx.Consts.RepoUnitTypeWiki}}
199199
<a class="{{if .PageIsWiki}}active {{end}}item" href="{{.RepoLink}}/wiki">
200200
{{svg "octicon-book"}} {{ctx.Locale.Tr "repo.wiki"}}
201201
</a>
202202
{{end}}
203203

204-
{{if .Permission.CanRead $.UnitTypeExternalWiki}}
205-
<a class="item" href="{{(.Repository.MustGetUnit $.Context $.UnitTypeExternalWiki).ExternalWikiConfig.ExternalWikiURL}}" target="_blank" rel="noopener noreferrer">
204+
{{if .Permission.CanRead ctx.Consts.RepoUnitTypeExternalWiki}}
205+
<a class="item" href="{{(.Repository.MustGetUnit $.Context ctx.Consts.RepoUnitTypeExternalWiki).ExternalWikiConfig.ExternalWikiURL}}" target="_blank" rel="noopener noreferrer">
206206
{{svg "octicon-link-external"}} {{ctx.Locale.Tr "repo.wiki"}}
207207
</a>
208208
{{end}}
209209

210-
{{if and (.Permission.CanReadAny $.UnitTypePullRequests $.UnitTypeIssues $.UnitTypeReleases) (not .IsEmptyRepo)}}
210+
{{if and (.Permission.CanReadAny ctx.Consts.RepoUnitTypePullRequests ctx.Consts.RepoUnitTypeIssues ctx.Consts.RepoUnitTypeReleases) (not .IsEmptyRepo)}}
211211
<a class="{{if .PageIsActivity}}active {{end}}item" href="{{.RepoLink}}/activity">
212212
{{svg "octicon-pulse"}} {{ctx.Locale.Tr "repo.activity"}}
213213
</a>

templates/repo/issue/view_content/pull.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@
196196
{{end}}
197197

198198
{{if .AllowMerge}} {{/* user is allowed to merge */}}
199-
{{$prUnit := .Repository.MustGetUnit $.Context $.UnitTypePullRequests}}
199+
{{$prUnit := .Repository.MustGetUnit $.Context ctx.Consts.RepoUnitTypePullRequests}}
200200
{{$approvers := (.Issue.PullRequest.GetApprovers ctx)}}
201201
{{if or $prUnit.PullRequestsConfig.AllowMerge $prUnit.PullRequestsConfig.AllowRebase $prUnit.PullRequestsConfig.AllowRebaseMerge $prUnit.PullRequestsConfig.AllowSquash $prUnit.PullRequestsConfig.AllowFastForwardOnly}}
202202
{{$hasPendingPullRequestMergeTip := ""}}

templates/repo/pulse.tmpl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
</div>
1919
</h2>
2020

21-
{{if (or (.Permission.CanRead $.UnitTypeIssues) (.Permission.CanRead $.UnitTypePullRequests))}}
21+
{{if (or (.Permission.CanRead ctx.Consts.RepoUnitTypeIssues) (.Permission.CanRead ctx.Consts.RepoUnitTypePullRequests))}}
2222
<h4 class="ui top attached header">{{ctx.Locale.Tr "repo.activity.overview"}}</h4>
2323
<div class="ui attached segment two column grid">
24-
{{if .Permission.CanRead $.UnitTypePullRequests}}
24+
{{if .Permission.CanRead ctx.Consts.RepoUnitTypePullRequests}}
2525
<div class="column">
2626
{{if gt .Activity.ActivePRCount 0}}
2727
<div class="stats-table">
@@ -38,7 +38,7 @@
3838
{{ctx.Locale.TrN .Activity.ActivePRCount "repo.activity.active_prs_count_1" "repo.activity.active_prs_count_n" .Activity.ActivePRCount}}
3939
</div>
4040
{{end}}
41-
{{if .Permission.CanRead $.UnitTypeIssues}}
41+
{{if .Permission.CanRead ctx.Consts.RepoUnitTypeIssues}}
4242
<div class="column">
4343
{{if gt .Activity.ActiveIssueCount 0}}
4444
<div class="stats-table">
@@ -57,7 +57,7 @@
5757
{{end}}
5858
</div>
5959
<div class="ui attached segment horizontal segments">
60-
{{if .Permission.CanRead $.UnitTypePullRequests}}
60+
{{if .Permission.CanRead ctx.Consts.RepoUnitTypePullRequests}}
6161
<a href="#merged-pull-requests" class="ui attached segment text center">
6262
<span class="text purple">{{svg "octicon-git-pull-request"}}</span> <strong>{{.Activity.MergedPRCount}}</strong><br>
6363
{{ctx.Locale.TrN .Activity.MergedPRCount "repo.activity.merged_prs_count_1" "repo.activity.merged_prs_count_n"}}
@@ -67,7 +67,7 @@
6767
{{ctx.Locale.TrN .Activity.OpenedPRCount "repo.activity.opened_prs_count_1" "repo.activity.opened_prs_count_n"}}
6868
</a>
6969
{{end}}
70-
{{if .Permission.CanRead $.UnitTypeIssues}}
70+
{{if .Permission.CanRead ctx.Consts.RepoUnitTypeIssues}}
7171
<a href="#closed-issues" class="ui attached segment text center">
7272
<span class="text red">{{svg "octicon-issue-closed"}}</span> <strong>{{.Activity.ClosedIssueCount}}</strong><br>
7373
{{ctx.Locale.TrN .Activity.ClosedIssueCount "repo.activity.closed_issues_count_1" "repo.activity.closed_issues_count_n"}}
@@ -80,7 +80,7 @@
8080
</div>
8181
{{end}}
8282

83-
{{if .Permission.CanRead $.UnitTypeCode}}
83+
{{if .Permission.CanRead ctx.Consts.RepoUnitTypeCode}}
8484
{{if eq .Activity.Code.CommitCountInAllBranches 0}}
8585
<div class="ui center aligned segment">
8686
<h4 class="ui header">{{ctx.Locale.Tr "repo.activity.no_git_activity"}}</h4>

templates/repo/recent_commits.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{if .Permission.CanRead $.UnitTypeCode}}
1+
{{if .Permission.CanRead ctx.Consts.RepoUnitTypeCode}}
22
<div id="repo-recent-commits-chart"
33
data-locale-loading-title="{{ctx.Locale.Tr "graphs.component_loading" (ctx.Locale.Tr "graphs.recent_commits.what")}}"
44
data-locale-loading-title-failed="{{ctx.Locale.Tr "graphs.component_loading_failed" (ctx.Locale.Tr "graphs.recent_commits.what")}}"

templates/repo/release/list.tmpl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
{{$release := $info.Release}}
1010
<li class="ui grid">
1111
<div class="ui four wide column meta">
12-
<a class="muted" href="{{if not (and $release.Sha1 ($.Permission.CanRead $.UnitTypeCode))}}#{{else}}{{$.RepoLink}}/src/tag/{{$release.TagName | PathEscapeSegments}}{{end}}" rel="nofollow">{{svg "octicon-tag" 16 "tw-mr-1"}}{{$release.TagName}}</a>
13-
{{if and $release.Sha1 ($.Permission.CanRead $.UnitTypeCode)}}
12+
<a class="muted" href="{{if not (and $release.Sha1 ($.Permission.CanRead ctx.Consts.RepoUnitTypeCode))}}#{{else}}{{$.RepoLink}}/src/tag/{{$release.TagName | PathEscapeSegments}}{{end}}" rel="nofollow">{{svg "octicon-tag" 16 "tw-mr-1"}}{{$release.TagName}}</a>
13+
{{if and $release.Sha1 ($.Permission.CanRead ctx.Consts.RepoUnitTypeCode)}}
1414
<a class="muted tw-font-mono" href="{{$.RepoLink}}/src/commit/{{$release.Sha1}}" rel="nofollow">{{svg "octicon-git-commit" 16 "tw-mr-1"}}{{ShortSha $release.Sha1}}</a>
1515
{{template "repo/branch_dropdown" dict "root" $ "release" $release}}
1616
{{end}}
@@ -53,7 +53,7 @@
5353
{{if $release.CreatedUnix}}
5454
<span class="time">{{TimeSinceUnix $release.CreatedUnix ctx.Locale}}</span>
5555
{{end}}
56-
{{if and (not $release.IsDraft) ($.Permission.CanRead $.UnitTypeCode)}}
56+
{{if and (not $release.IsDraft) ($.Permission.CanRead ctx.Consts.RepoUnitTypeCode)}}
5757
| <span class="ahead"><a href="{{$.RepoLink}}/compare/{{$release.TagName | PathEscapeSegments}}...{{$release.TargetBehind | PathEscapeSegments}}">{{ctx.Locale.Tr "repo.release.ahead.commits" $release.NumCommitsBehind}}</a> {{ctx.Locale.Tr "repo.release.ahead.target" $release.TargetBehind}}</span>
5858
{{end}}
5959
</p>
@@ -66,7 +66,7 @@
6666
{{ctx.Locale.Tr "repo.release.downloads"}}
6767
</summary>
6868
<ul class="list">
69-
{{if and (not $.DisableDownloadSourceArchives) (not $release.IsDraft) ($.Permission.CanRead $.UnitTypeCode)}}
69+
{{if and (not $.DisableDownloadSourceArchives) (not $release.IsDraft) ($.Permission.CanRead ctx.Consts.RepoUnitTypeCode)}}
7070
<li>
7171
<a class="archive-link" href="{{$.RepoLink}}/archive/{{$release.TagName | PathEscapeSegments}}.zip" rel="nofollow"><strong>{{svg "octicon-file-zip" 16 "tw-mr-1"}}{{ctx.Locale.Tr "repo.release.source_code"}} (ZIP)</strong></a>
7272
</li>
@@ -99,7 +99,7 @@
9999
</div>
100100
</div>
101101

102-
{{if (and ($.Permission.CanWrite $.UnitTypeCode) .PageIsTagList)}}
102+
{{if (and ($.Permission.CanWrite ctx.Consts.RepoUnitTypeCode) .PageIsTagList)}}
103103
<div class="ui g-modal-confirm delete modal">
104104
<div class="header">
105105
{{svg "octicon-trash"}}

templates/repo/release_tag_header.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
{{$canReadReleases := $.Permission.CanRead $.UnitTypeReleases}}
2-
{{$canReadCode := $.Permission.CanRead $.UnitTypeCode}}
1+
{{$canReadReleases := $.Permission.CanRead ctx.Consts.RepoUnitTypeReleases}}
2+
{{$canReadCode := $.Permission.CanRead ctx.Consts.RepoUnitTypeCode}}
33

44
{{if $canReadReleases}}
55
<div class="tw-flex">

templates/repo/settings/navbar.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
{{ctx.Locale.Tr "repo.settings.hooks"}}
1313
</a>
1414
{{end}}
15-
{{if .Repository.UnitEnabled $.Context $.UnitTypeCode}}
15+
{{if .Repository.UnitEnabled $.Context ctx.Consts.RepoUnitTypeCode}}
1616
{{if not .Repository.IsEmpty}}
1717
<a class="{{if .PageIsSettingsBranches}}active {{end}}item" href="{{.RepoLink}}/settings/branches">
1818
{{ctx.Locale.Tr "repo.settings.branches"}}
@@ -35,7 +35,7 @@
3535
</a>
3636
{{end}}
3737
{{end}}
38-
{{if and .EnableActions (not .UnitActionsGlobalDisabled) (.Permission.CanRead $.UnitTypeActions)}}
38+
{{if and .EnableActions (not .UnitActionsGlobalDisabled) (.Permission.CanRead ctx.Consts.RepoUnitTypeActions)}}
3939
<details class="item toggleable-item" {{if or .PageIsSharedSettingsRunners .PageIsSharedSettingsSecrets .PageIsSharedSettingsVariables}}open{{end}}>
4040
<summary>{{ctx.Locale.Tr "actions.actions"}}</summary>
4141
<div class="menu">

0 commit comments

Comments
 (0)