From 5e047b9bd7ba4bfa1c1ae3683eabe7e290de5728 Mon Sep 17 00:00:00 2001 From: Jonathan Tran Date: Mon, 3 May 2021 13:27:48 -0400 Subject: [PATCH] Add compare tag dropdown to releases page (#15695) * Add compare tag dropdown to releases page * Change defaults to be more intuitive and remove unneeded option * Fix to select branch on releases page Co-authored-by: Jonathan Tran Co-authored-by: Kyle D --- options/locale/locale_en-US.ini | 2 + routers/repo/release.go | 12 +++++ templates/repo/branch_dropdown.tmpl | 78 +++++++++++++++++------------ 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 +++++- 8 files changed, 78 insertions(+), 36 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 25b0a1b0bd..69923ebb83 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 abce3e9ac1..6b0b92743d 100644 --- a/routers/repo/release.go +++ b/routers/repo/release.go @@ -70,6 +70,11 @@ 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 in the dropdown on this page. + ctx.Data["CanCreateBranch"] = false + ctx.Data["HideBranchesInDropdown"] = true if isTagList { ctx.Data["Title"] = ctx.Tr("repo.release.tags") @@ -79,6 +84,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 ca805fa587..3fd461c64f 100644 --- a/templates/repo/branch_dropdown.tmpl +++ b/templates/repo/branch_dropdown.tmpl @@ -1,64 +1,78 @@ -
-