Skip to content

Commit 9e5326e

Browse files
committed
improve runner type display
1 parent 50133b0 commit 9e5326e

File tree

3 files changed

+32
-6
lines changed

3 files changed

+32
-6
lines changed

models/actions/runner.go

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,40 @@ type ActionRunner struct {
5252
Deleted timeutil.TimeStamp `xorm:"deleted"`
5353
}
5454

55-
func (r *ActionRunner) OwnType() string {
55+
// RunnerType defines the runner type
56+
type RunnerType int //revive:disable-line:exported
57+
58+
const (
59+
// RunnerTypeGlobal defines a global runner
60+
RunnerTypeGlobal RunnerType = iota
61+
62+
// RunnerTypeOrganization defines an organization runner
63+
RunnerTypeOrganization
64+
65+
// RunnerTypeRepository defines a repository runner
66+
RunnerTypeRepository
67+
)
68+
69+
func (r *ActionRunner) Type() RunnerType {
5670
if r.RepoID != 0 {
57-
return fmt.Sprintf("Repo(%s)", r.Repo.FullName())
71+
return RunnerTypeRepository
5872
}
5973
if r.OwnerID != 0 {
60-
return fmt.Sprintf("Org(%s)", r.Owner.Name)
74+
return RunnerTypeOrganization
75+
}
76+
return RunnerTypeGlobal
77+
}
78+
79+
func (r RunnerType) String() string {
80+
switch r {
81+
case RunnerTypeGlobal:
82+
return "Global"
83+
case RunnerTypeOrganization:
84+
return "Organization"
85+
case RunnerTypeRepository:
86+
return "Repository"
6187
}
62-
return "Global"
88+
return fmt.Sprintf("Unknown Type %d", r)
6389
}
6490

6591
func (r *ActionRunner) Status() runnerv1.RunnerStatus {

templates/shared/actions/runner_edit.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
</div>
2626
<div class="field gt-dib gt-mr-4 disabled">
2727
<label>{{.locale.Tr "actions.runners.owner_type"}}</label>
28-
<span>{{.Runner.OwnType}}</span>
28+
<span>{{.Runner.Type.String}}</span>
2929
</div>
3030
</div>
3131

templates/shared/actions/runner_list.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
<td>{{.ID}}</td>
6666
<td><p data-tooltip-content="{{.Description}}">{{.Name}}</p></td>
6767
<td>{{.Version}}</td>
68-
<td>{{.OwnType}}</td>
68+
<td>{{.Type.String}}</td>
6969
<td class="runner-tags">
7070
{{range .AllLabels}}<span class="ui label">{{.}}</span>{{end}}
7171
</td>

0 commit comments

Comments
 (0)