From 7486f276815e1f5203ada3534a0a7a43c7be4141 Mon Sep 17 00:00:00 2001 From: yp05327 <576951401@qq.com> Date: Mon, 21 Oct 2024 04:58:48 +0000 Subject: [PATCH] improve --- routers/web/repo/activity.go | 5 +++++ routers/web/web.go | 2 +- templates/repo/header.tmpl | 2 +- templates/repo/navbar.tmpl | 2 ++ 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/routers/web/repo/activity.go b/routers/web/repo/activity.go index c8fa60f77a..17f4cfb749 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 2c7795d475..119f450030 100644 --- a/routers/web/web.go +++ b/routers/web/web.go @@ -1456,7 +1456,7 @@ func registerRoutes(m *web.Router) { 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 d52891b02a..2958bbf299 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 9bb88be69a..077e330480 100644 --- a/templates/repo/navbar.tmpl +++ b/templates/repo/navbar.tmpl @@ -1,7 +1,9 @@