diff --git a/routers/web/repo/activity.go b/routers/web/repo/activity.go index c8fa60f77a74a..17f4cfb749d7a 100644 --- a/routers/web/repo/activity.go +++ b/routers/web/repo/activity.go @@ -22,6 +22,11 @@ func Activity(ctx *context.Context) { ctx.Data["Title"] = ctx.Tr("repo.activity") ctx.Data["PageIsActivity"] = true + if !ctx.Repo.CanReadAny(unit.TypePullRequests, unit.TypeIssues, unit.TypeReleases) { + ctx.Redirect(ctx.Repo.RepoLink + "/activity/contributors") + return + } + ctx.Data["PageIsPulse"] = true ctx.Data["Period"] = ctx.PathParam("period") diff --git a/routers/web/web.go b/routers/web/web.go index f28ec82c8f0b8..dfd9735bbf10e 100644 --- a/routers/web/web.go +++ b/routers/web/web.go @@ -1450,13 +1450,13 @@ func registerRoutes(m *web.Router) { m.Group("/code-frequency", func() { m.Get("", repo.CodeFrequency) m.Get("/data", repo.CodeFrequencyData) - }) + }, reqRepoCodeReader) m.Group("/recent-commits", func() { m.Get("", repo.RecentCommits) m.Get("/data", repo.RecentCommitsData) - }) + }, reqRepoCodeReader) }, - ignSignIn, context.RepoAssignment, context.RequireRepoReaderOr(unit.TypePullRequests, unit.TypeIssues, unit.TypeReleases), + ignSignIn, context.RepoAssignment, context.RequireRepoReaderOr(unit.TypePullRequests, unit.TypeIssues, unit.TypeReleases, unit.TypeCode), context.RepoRef(), repo.MustBeNotEmpty, ) // end "/{username}/{reponame}/activity" diff --git a/templates/repo/header.tmpl b/templates/repo/header.tmpl index d52891b02a76a..2958bbf29966e 100644 --- a/templates/repo/header.tmpl +++ b/templates/repo/header.tmpl @@ -208,7 +208,7 @@ {{end}} - {{if and (.Permission.CanReadAny ctx.Consts.RepoUnitTypePullRequests ctx.Consts.RepoUnitTypeIssues ctx.Consts.RepoUnitTypeReleases) (not .IsEmptyRepo)}} + {{if and (.Permission.CanReadAny ctx.Consts.RepoUnitTypePullRequests ctx.Consts.RepoUnitTypeIssues ctx.Consts.RepoUnitTypeReleases ctx.Consts.RepoUnitTypeCode) (not .IsEmptyRepo)}} {{svg "octicon-pulse"}} {{ctx.Locale.Tr "repo.activity"}} diff --git a/templates/repo/navbar.tmpl b/templates/repo/navbar.tmpl index b2471dc17e7c0..077e330480ded 100644 --- a/templates/repo/navbar.tmpl +++ b/templates/repo/navbar.tmpl @@ -1,7 +1,10 @@