mirror of
https://github.com/go-gitea/gitea.git
synced 2025-04-07 20:25:21 +02:00
Improve ui for builds
This commit is contained in:
parent
d69423a3b0
commit
3518c098b9
@ -8,6 +8,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"hash/fnv"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/gitea/core"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
@ -84,6 +85,10 @@ func (r *Run) LoadAttributes(ctx context.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (run *Run) TakeTime() time.Duration {
|
||||
return run.EndTime.AsTime().Sub(run.StartTime.AsTime())
|
||||
}
|
||||
|
||||
func updateRepoRunsNumbers(ctx context.Context, repo *repo_model.Repository) error {
|
||||
_, err := db.GetEngine(ctx).ID(repo.ID).
|
||||
SetExpr("num_runs",
|
||||
|
@ -41,6 +41,54 @@ func SanitizeRefPattern(name string) string {
|
||||
return refNamePatternInvalid.ReplaceAllString(name, "_")
|
||||
}
|
||||
|
||||
// RefName represents a git reference name
|
||||
type RefName string
|
||||
|
||||
func (ref RefName) IsBranch() bool {
|
||||
return strings.HasPrefix(string(ref), BranchPrefix)
|
||||
}
|
||||
|
||||
func (ref RefName) IsTag() bool {
|
||||
return strings.HasPrefix(string(ref), TagPrefix)
|
||||
}
|
||||
|
||||
// ShortName returns the short name of the reference name
|
||||
func (ref RefName) ShortName() string {
|
||||
refName := string(ref)
|
||||
if strings.HasPrefix(refName, BranchPrefix) {
|
||||
return strings.TrimPrefix(refName, BranchPrefix)
|
||||
}
|
||||
if strings.HasPrefix(refName, TagPrefix) {
|
||||
return strings.TrimPrefix(refName, TagPrefix)
|
||||
}
|
||||
if strings.HasPrefix(refName, RemotePrefix) {
|
||||
return strings.TrimPrefix(refName, RemotePrefix)
|
||||
}
|
||||
if strings.HasPrefix(refName, PullPrefix) && strings.IndexByte(refName[pullLen:], '/') > -1 {
|
||||
return refName[pullLen : strings.IndexByte(refName[pullLen:], '/')+pullLen]
|
||||
}
|
||||
|
||||
return refName
|
||||
}
|
||||
|
||||
// RefGroup returns the group type of the reference
|
||||
func (ref RefName) RefGroup() string {
|
||||
refName := string(ref)
|
||||
if strings.HasPrefix(refName, BranchPrefix) {
|
||||
return "heads"
|
||||
}
|
||||
if strings.HasPrefix(refName, TagPrefix) {
|
||||
return "tags"
|
||||
}
|
||||
if strings.HasPrefix(refName, RemotePrefix) {
|
||||
return "remotes"
|
||||
}
|
||||
if strings.HasPrefix(refName, PullPrefix) && strings.IndexByte(refName[pullLen:], '/') > -1 {
|
||||
return "pull"
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// Reference represents a Git ref.
|
||||
type Reference struct {
|
||||
Name string
|
||||
@ -54,43 +102,12 @@ func (ref *Reference) Commit() (*Commit, error) {
|
||||
return ref.repo.getCommit(ref.Object)
|
||||
}
|
||||
|
||||
// ShortName returns the short name of the reference
|
||||
// ShortName returns the short name of the reference name
|
||||
func (ref *Reference) ShortName() string {
|
||||
if ref == nil {
|
||||
return ""
|
||||
}
|
||||
if strings.HasPrefix(ref.Name, BranchPrefix) {
|
||||
return strings.TrimPrefix(ref.Name, BranchPrefix)
|
||||
}
|
||||
if strings.HasPrefix(ref.Name, TagPrefix) {
|
||||
return strings.TrimPrefix(ref.Name, TagPrefix)
|
||||
}
|
||||
if strings.HasPrefix(ref.Name, RemotePrefix) {
|
||||
return strings.TrimPrefix(ref.Name, RemotePrefix)
|
||||
}
|
||||
if strings.HasPrefix(ref.Name, PullPrefix) && strings.IndexByte(ref.Name[pullLen:], '/') > -1 {
|
||||
return ref.Name[pullLen : strings.IndexByte(ref.Name[pullLen:], '/')+pullLen]
|
||||
}
|
||||
|
||||
return ref.Name
|
||||
return RefName(ref.Name).ShortName()
|
||||
}
|
||||
|
||||
// RefGroup returns the group type of the reference
|
||||
func (ref *Reference) RefGroup() string {
|
||||
if ref == nil {
|
||||
return ""
|
||||
}
|
||||
if strings.HasPrefix(ref.Name, BranchPrefix) {
|
||||
return "heads"
|
||||
}
|
||||
if strings.HasPrefix(ref.Name, TagPrefix) {
|
||||
return "tags"
|
||||
}
|
||||
if strings.HasPrefix(ref.Name, RemotePrefix) {
|
||||
return "remotes"
|
||||
}
|
||||
if strings.HasPrefix(ref.Name, PullPrefix) && strings.IndexByte(ref.Name[pullLen:], '/') > -1 {
|
||||
return "pull"
|
||||
}
|
||||
return ""
|
||||
return RefName(ref.Name).RefGroup()
|
||||
}
|
||||
|
@ -472,6 +472,9 @@ func NewFuncMap() []template.FuncMap {
|
||||
curBranch,
|
||||
)
|
||||
},
|
||||
"RefShortName": func(ref string) string {
|
||||
return git.RefName(ref).ShortName()
|
||||
},
|
||||
}}
|
||||
}
|
||||
|
||||
|
@ -65,13 +65,16 @@ func List(ctx *context.Context) {
|
||||
page = 1
|
||||
}
|
||||
|
||||
workflow := ctx.FormString("workflow")
|
||||
ctx.Data["CurWorkflow"] = workflow
|
||||
|
||||
opts := bots_model.FindRunOptions{
|
||||
ListOptions: db.ListOptions{
|
||||
Page: page,
|
||||
PageSize: convert.ToCorrectPageSize(ctx.FormInt("limit")),
|
||||
},
|
||||
RepoID: ctx.Repo.Repository.ID,
|
||||
WorkflowFileName: ctx.FormString("workflow"),
|
||||
WorkflowFileName: workflow,
|
||||
}
|
||||
if ctx.FormString("state") == "closed" {
|
||||
opts.IsClosed = util.OptionalBoolTrue
|
||||
|
@ -2,22 +2,22 @@
|
||||
{{range .Builds}}
|
||||
<li class="item df py-3">
|
||||
<div class="issue-item-left df">
|
||||
{{if $.CanWriteIssuesOrPulls}}
|
||||
<div class="ui checkbox issue-checkbox">
|
||||
<input type="checkbox" data-issue-id={{.ID}}></input>
|
||||
<label></label>
|
||||
</div>
|
||||
{{end}}
|
||||
{{template "repo/builds/status" .Status}}
|
||||
</div>
|
||||
<div class="issue-item-main f1 fc df">
|
||||
<div class="desc issue-item-bottom-row df ac fw my-1">
|
||||
<div class="issue-item-top-row">
|
||||
<a class="index ml-0 mr-2" href="{{if .HTMLURL}}{{.HTMLURL}}{{else}}{{$.Link}}/{{.Index}}{{end}}">
|
||||
#{{.Index}} {{.Title}}
|
||||
{{.Title}} <span class="ui label">{{RefShortName .Ref}}</span>
|
||||
</a>
|
||||
{{ $timeStr := TimeSinceUnix .Updated $.locale }}
|
||||
{{$.locale.Tr "repo.builds.opened_by" $timeStr (.TriggerUser.GetDisplayName | Escape) | Safe}}
|
||||
</div>
|
||||
<div class="desc issue-item-bottom-row df ac fw my-1">
|
||||
<b>{{if not $.CurWorkflow}}{{.WorkflowID}} {{end}}#{{.Index}}</b>: Commit
|
||||
<a href="{{$.Link}}/commit/{{.CommitSHA}}">{{SubStr .CommitSHA 0 10}}</a> pushed by {{.TriggerUser.GetDisplayName | Escape}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="issue-item-right">
|
||||
<div>{{ TimeSinceUnix .Updated $.locale }}</div>
|
||||
<div>{{.TakeTime}}</div>
|
||||
</div>
|
||||
</li>
|
||||
{{end}}
|
||||
|
@ -6,10 +6,10 @@
|
||||
<div class="ui grid">
|
||||
<div class="four wide column">
|
||||
<div class="ui fluid vertical menu">
|
||||
<a class="item" href="{{$.Link}}">All Workflows</a>
|
||||
<a class="item{{if not $.CurWorkflow}} active{{end}}" href="{{$.Link}}">All Workflows</a>
|
||||
<div class="divider"></div>
|
||||
{{range .workflows}}
|
||||
<a class="item" href="{{$.Link}}?workflow={{.Name}}">{{.Name}}</a>
|
||||
<a class="item{{if eq .Name $.CurWorkflow}} active{{end}}" href="{{$.Link}}?workflow={{.Name}}">{{.Name}}</a>
|
||||
{{end}}
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user