From eb8c54d5446d1ea2c04d544c9c54c935645f42dd Mon Sep 17 00:00:00 2001 From: Jonathan Tran Date: Fri, 30 Apr 2021 20:09:36 -0400 Subject: [PATCH 1/3] Add compare tag dropdown to releases page --- modules/context/repo.go | 2 + options/locale/locale_en-US.ini | 2 + routers/repo/release.go | 13 +++++ templates/repo/branch_dropdown.tmpl | 75 +++++++++++++++++------------ templates/repo/commits.tmpl | 2 +- templates/repo/home.tmpl | 2 +- templates/repo/release/list.tmpl | 1 + web_src/js/index.js | 3 +- web_src/less/_repository.less | 14 +++++- 9 files changed, 78 insertions(+), 36 deletions(-) diff --git a/modules/context/repo.go b/modules/context/repo.go index 5ce31e9e3504..047b3e07daa3 100644 --- a/modules/context/repo.go +++ b/modules/context/repo.go @@ -834,6 +834,8 @@ func RepoRefByType(refType RepoRefType) func(*Context) { ctx.Data["IsViewTag"] = ctx.Repo.IsViewTag ctx.Data["IsViewCommit"] = ctx.Repo.IsViewCommit ctx.Data["CanCreateBranch"] = ctx.Repo.CanCreateBranch() + ctx.Data["ShowBranchesInDropdown"] = true + ctx.Data["ShowTagsInDropdown"] = true ctx.Repo.CommitsCount, err = ctx.Repo.GetCommitsCount() if err != nil { diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 25b0a1b0bd33..69923ebb8375 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -855,6 +855,7 @@ branch = Branch tree = Tree clear_ref = `Clear current reference` filter_branch_and_tag = Filter branch or tag +find_tag = Find tag branches = Branches tags = Tags issues = Issues @@ -1913,6 +1914,7 @@ release.new_release = New Release release.draft = Draft release.prerelease = Pre-Release release.stable = Stable +release.compare = Compare release.edit = edit release.ahead.commits = %d commits release.ahead.target = to %s since this release diff --git a/routers/repo/release.go b/routers/repo/release.go index abce3e9ac1a2..da51911c6246 100644 --- a/routers/repo/release.go +++ b/routers/repo/release.go @@ -70,6 +70,12 @@ func TagsList(ctx *context.Context) { 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 + // Disable the showCreateNewBranch form on this page. + ctx.Data["CanCreateBranch"] = false + ctx.Data["ShowBranchesInDropdown"] = false + ctx.Data["ShowTagsInDropdown"] = true if isTagList { ctx.Data["Title"] = ctx.Tr("repo.release.tags") @@ -79,6 +85,13 @@ func releasesOrTags(ctx *context.Context, isTagList bool) { ctx.Data["PageIsTagList"] = false } + tags, err := ctx.Repo.GitRepo.GetTags() + if err != nil { + ctx.ServerError("GetTags", err) + return + } + ctx.Data["Tags"] = tags + writeAccess := ctx.Repo.CanWrite(models.UnitTypeReleases) ctx.Data["CanCreateRelease"] = writeAccess && !ctx.Repo.Repository.IsArchived diff --git a/templates/repo/branch_dropdown.tmpl b/templates/repo/branch_dropdown.tmpl index ca805fa5877d..09c3f26a87c6 100644 --- a/templates/repo/branch_dropdown.tmpl +++ b/templates/repo/branch_dropdown.tmpl @@ -1,64 +1,75 @@ -
-