fix some ui bug about draft release (#15137)
* fix some ui bug about draft release - should not show draft release in tag list because it will't create real tag - still show draft release without tag and commit message for draft release instead of 404 error - remove tag load for attachement links because it's useless Signed-off-by: a1012112796 <1012112796@qq.com> * add test code * fix test That's because has added a new release in relaese test database. * fix dropdown link for draft release
This commit is contained in:
parent
eedc0c8324
commit
3088866531
7 changed files with 128 additions and 22 deletions
|
@ -99,7 +99,7 @@ func releasesOrTags(ctx *context.Context, isTagList bool) {
|
|||
Page: ctx.QueryInt("page"),
|
||||
PageSize: convert.ToCorrectPageSize(ctx.QueryInt("limit")),
|
||||
},
|
||||
IncludeDrafts: writeAccess,
|
||||
IncludeDrafts: writeAccess && !isTagList,
|
||||
IncludeTags: isTagList,
|
||||
}
|
||||
|
||||
|
@ -141,10 +141,7 @@ func releasesOrTags(ctx *context.Context, isTagList bool) {
|
|||
}
|
||||
cacheUsers[r.PublisherID] = r.Publisher
|
||||
}
|
||||
if err := calReleaseNumCommitsBehind(ctx.Repo, r, countCache); err != nil {
|
||||
ctx.ServerError("calReleaseNumCommitsBehind", err)
|
||||
return
|
||||
}
|
||||
|
||||
r.Note, err = markdown.RenderString(&markup.RenderContext{
|
||||
URLPrefix: ctx.Repo.RepoLink,
|
||||
Metas: ctx.Repo.Repository.ComposeMetas(),
|
||||
|
@ -153,6 +150,15 @@ func releasesOrTags(ctx *context.Context, isTagList bool) {
|
|||
ctx.ServerError("RenderString", err)
|
||||
return
|
||||
}
|
||||
|
||||
if r.IsDraft {
|
||||
continue
|
||||
}
|
||||
|
||||
if err := calReleaseNumCommitsBehind(ctx.Repo, r, countCache); err != nil {
|
||||
ctx.ServerError("calReleaseNumCommitsBehind", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
ctx.Data["Releases"] = releases
|
||||
|
@ -198,9 +204,11 @@ func SingleRelease(ctx *context.Context) {
|
|||
return
|
||||
}
|
||||
}
|
||||
if err := calReleaseNumCommitsBehind(ctx.Repo, release, make(map[string]int64)); err != nil {
|
||||
ctx.ServerError("calReleaseNumCommitsBehind", err)
|
||||
return
|
||||
if !release.IsDraft {
|
||||
if err := calReleaseNumCommitsBehind(ctx.Repo, release, make(map[string]int64)); err != nil {
|
||||
ctx.ServerError("calReleaseNumCommitsBehind", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
release.Note, err = markdown.RenderString(&markup.RenderContext{
|
||||
URLPrefix: ctx.Repo.RepoLink,
|
||||
|
|
|
@ -912,8 +912,8 @@ func RegisterRoutes(m *web.Route) {
|
|||
m.Get("/", repo.Releases)
|
||||
m.Get("/tag/*", repo.SingleRelease)
|
||||
m.Get("/latest", repo.LatestRelease)
|
||||
m.Get("/attachments/{uuid}", repo.GetAttachment)
|
||||
}, repo.MustBeNotEmpty, reqRepoReleaseReader, context.RepoRefByType(context.RepoRefTag))
|
||||
}, repo.MustBeNotEmpty, reqRepoReleaseReader, context.RepoRefByType(context.RepoRefTag, true))
|
||||
m.Get("/releases/attachments/{uuid}", repo.GetAttachment, repo.MustBeNotEmpty, reqRepoReleaseReader)
|
||||
m.Group("/releases", func() {
|
||||
m.Get("/new", repo.NewRelease)
|
||||
m.Post("/new", bindIgnErr(forms.NewReleaseForm{}), repo.NewReleasePost)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue