diff options
author | Zettat123 <zettat123@gmail.com> | 2023-04-26 00:29:00 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-25 18:29:00 +0200 |
commit | 30c1cd97758592e20b6ecb3462da0f0289622828 (patch) | |
tree | 8ffa257323112ffe0fb1b216a8bc94a62a6ea87d /routers | |
parent | 5cf7da63ee74939595b8800787dcdb4c7290fa4f (diff) | |
download | gitea-30c1cd97758592e20b6ecb3462da0f0289622828.tar.gz gitea-30c1cd97758592e20b6ecb3462da0f0289622828.zip |
Add tags list for repos whose release setting is disabled (#23465)
Close #23427
Co-Author: @wxiaoguang
If a repo's release setting is enabled, the logic has't changed.
Clicking the "Tags" button will jump to `/{user}/{repo}/tags` and
`templates/repo/release/list.tmpl` template will be used.
<img
src="https://user-images.githubusercontent.com/15528715/224939362-bd8974fd-08b0-4f79-a114-3389d15847ca.png"
width="600px" />
If the release setting is disabled, clicking the "Tags" button will
still jump to `/{user}/{repo}/tags` but a new template
`templates/repo/tag/list.tmpl` will be used.
<img
src="https://user-images.githubusercontent.com/15528715/233834564-74741e49-f4e9-47c8-ac12-e306642798dc.png"
width="600px" />
Since both templates above need to render the tags list, I moved the
tags list to a shared template located in
`templates/repo/tag/table.tmpl`.
---------
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Giteabot <teabot@gitea.io>
Diffstat (limited to 'routers')
-rw-r--r-- | routers/web/repo/release.go | 26 | ||||
-rw-r--r-- | routers/web/web.go | 10 |
2 files changed, 20 insertions, 16 deletions
diff --git a/routers/web/repo/release.go b/routers/web/repo/release.go index 6a5ebd5dad..689994c146 100644 --- a/routers/web/repo/release.go +++ b/routers/web/repo/release.go @@ -29,8 +29,9 @@ import ( ) const ( - tplReleases base.TplName = "repo/release/list" - tplReleaseNew base.TplName = "repo/release/new" + tplReleasesList base.TplName = "repo/release/list" + tplReleaseNew base.TplName = "repo/release/new" + tplTagsList base.TplName = "repo/tag/list" ) // calReleaseNumCommitsBehind calculates given release has how many commits behind release target. @@ -58,16 +59,19 @@ func calReleaseNumCommitsBehind(repoCtx *context.Repository, release *repo_model // Releases render releases list page func Releases(ctx *context.Context) { + ctx.Data["PageIsReleaseList"] = true + ctx.Data["Title"] = ctx.Tr("repo.release.releases") releasesOrTags(ctx, false) } // TagsList render tags list page func TagsList(ctx *context.Context) { + ctx.Data["PageIsTagList"] = true + ctx.Data["Title"] = ctx.Tr("repo.release.tags") releasesOrTags(ctx, true) } func releasesOrTags(ctx *context.Context, isTagList bool) { - ctx.Data["PageIsReleaseList"] = true ctx.Data["DefaultBranch"] = ctx.Repo.Repository.DefaultBranch ctx.Data["IsViewBranch"] = false ctx.Data["IsViewTag"] = true @@ -75,14 +79,6 @@ func releasesOrTags(ctx *context.Context, isTagList bool) { ctx.Data["CanCreateBranch"] = false ctx.Data["HideBranchesInDropdown"] = true - if isTagList { - ctx.Data["Title"] = ctx.Tr("repo.release.tags") - ctx.Data["PageIsTagList"] = true - } else { - ctx.Data["Title"] = ctx.Tr("repo.release.releases") - ctx.Data["PageIsTagList"] = false - } - listOptions := db.ListOptions{ Page: ctx.FormInt("page"), PageSize: ctx.FormInt("limit"), @@ -196,7 +192,11 @@ func releasesOrTags(ctx *context.Context, isTagList bool) { pager.SetDefaultParams(ctx) ctx.Data["Page"] = pager - ctx.HTML(http.StatusOK, tplReleases) + if isTagList { + ctx.HTML(http.StatusOK, tplTagsList) + } else { + ctx.HTML(http.StatusOK, tplReleasesList) + } } // ReleasesFeedRSS get feeds for releases in RSS format @@ -282,7 +282,7 @@ func SingleRelease(ctx *context.Context) { } ctx.Data["Releases"] = []*repo_model.Release{release} - ctx.HTML(http.StatusOK, tplReleases) + ctx.HTML(http.StatusOK, tplReleasesList) } // LatestRelease redirects to the latest release diff --git a/routers/web/web.go b/routers/web/web.go index f7f32734d8..9d1bd90d93 100644 --- a/routers/web/web.go +++ b/routers/web/web.go @@ -1198,7 +1198,7 @@ func RegisterRoutes(m *web.Route) { }, context.RepoMustNotBeArchived(), reqRepoCodeWriter, repo.MustBeNotEmpty) }, reqSignIn, context.RepoAssignment, context.UnitTypes()) - // Releases + // Tags m.Group("/{username}/{reponame}", func() { m.Group("/tags", func() { m.Get("", repo.TagsList) @@ -1207,6 +1207,12 @@ func RegisterRoutes(m *web.Route) { }, func(ctx *context.Context) { ctx.Data["EnableFeed"] = setting.Other.EnableFeed }, repo.MustBeNotEmpty, reqRepoCodeReader, context.RepoRefByType(context.RepoRefTag, true)) + m.Post("/tags/delete", repo.DeleteTag, reqSignIn, + repo.MustBeNotEmpty, context.RepoMustNotBeArchived(), reqRepoCodeWriter, context.RepoRef()) + }, reqSignIn, context.RepoAssignment, context.UnitTypes()) + + // Releases + m.Group("/{username}/{reponame}", func() { m.Group("/releases", func() { m.Get("/", repo.Releases) m.Get("/tag/*", repo.SingleRelease) @@ -1224,8 +1230,6 @@ func RegisterRoutes(m *web.Route) { m.Post("/attachments", repo.UploadReleaseAttachment) m.Post("/attachments/remove", repo.DeleteAttachment) }, reqSignIn, repo.MustBeNotEmpty, context.RepoMustNotBeArchived(), reqRepoReleaseWriter, context.RepoRef()) - m.Post("/tags/delete", repo.DeleteTag, reqSignIn, - repo.MustBeNotEmpty, context.RepoMustNotBeArchived(), reqRepoCodeWriter, context.RepoRef()) m.Group("/releases", func() { m.Get("/edit/*", repo.EditRelease) m.Post("/edit/*", web.Bind(forms.EditReleaseForm{}), repo.EditReleasePost) |