Skip to content

Commit 7486f27

Browse files
committed
improve
1 parent 0956e50 commit 7486f27

File tree

4 files changed

+9
-2
lines changed

4 files changed

+9
-2
lines changed

routers/web/repo/activity.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ func Activity(ctx *context.Context) {
2222
ctx.Data["Title"] = ctx.Tr("repo.activity")
2323
ctx.Data["PageIsActivity"] = true
2424

25+
if !ctx.Repo.CanReadAny(unit.TypePullRequests, unit.TypeIssues, unit.TypeReleases) {
26+
ctx.Redirect(ctx.Repo.RepoLink + "/activity/contributors")
27+
return
28+
}
29+
2530
ctx.Data["PageIsPulse"] = true
2631

2732
ctx.Data["Period"] = ctx.PathParam("period")

routers/web/web.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1456,7 +1456,7 @@ func registerRoutes(m *web.Router) {
14561456
m.Get("/data", repo.RecentCommitsData)
14571457
}, reqRepoCodeReader)
14581458
},
1459-
ignSignIn, context.RepoAssignment, context.RequireRepoReaderOr(unit.TypePullRequests, unit.TypeIssues, unit.TypeReleases),
1459+
ignSignIn, context.RepoAssignment, context.RequireRepoReaderOr(unit.TypePullRequests, unit.TypeIssues, unit.TypeReleases, unit.TypeCode),
14601460
context.RepoRef(), repo.MustBeNotEmpty,
14611461
)
14621462
// end "/{username}/{reponame}/activity"

templates/repo/header.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@
208208
</a>
209209
{{end}}
210210

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

templates/repo/navbar.tmpl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
<div class="ui fluid vertical menu">
2+
{{if (or (.Permission.CanRead ctx.Consts.RepoUnitTypeIssues) (.Permission.CanRead ctx.Consts.RepoUnitTypePullRequests))}}
23
<a class="{{if .PageIsPulse}}active {{end}}item" href="{{.RepoLink}}/activity">
34
{{ctx.Locale.Tr "repo.activity.navbar.pulse"}}
45
</a>
6+
{{end}}
57
{{if .Permission.CanRead ctx.Consts.RepoUnitTypeCode}}
68
<a class="{{if .PageIsContributors}}active {{end}}item" href="{{.RepoLink}}/activity/contributors">
79
{{ctx.Locale.Tr "repo.activity.navbar.contributors"}}

0 commit comments

Comments
 (0)