aboutsummaryrefslogtreecommitdiffstats
path: root/models/actions/runner.go
diff options
context:
space:
mode:
authoryp05327 <576951401@qq.com>2023-05-12 17:43:27 +0900
committerGitHub <noreply@github.com>2023-05-12 08:43:27 +0000
commit49808136c5af5946851c5486d4630482d79eff8b (patch)
tree0e1d5ef1b5e5abf3d01b53e8471b8ad390c2f4f9 /models/actions/runner.go
parent4aec1f87a4affe606e96e27c2e8660092aac3afb (diff)
downloadgitea-49808136c5af5946851c5486d4630482d79eff8b.tar.gz
gitea-49808136c5af5946851c5486d4630482d79eff8b.zip
Display owner of a runner as a tooltip instead of static text (#24377)
Before: ![image](https://user-images.githubusercontent.com/18380374/234779250-8bbd325c-190e-4a30-ac3e-766498d17df5.png) After: ![image](https://user-images.githubusercontent.com/18380374/234779094-e232ecba-d9f4-4d62-a702-6d5e4a522782.png) ![image](https://user-images.githubusercontent.com/18380374/234779120-0293af17-a566-4b69-b454-af4e95844e3b.png) --------- Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: Giteabot <teabot@gitea.io> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Diffstat (limited to 'models/actions/runner.go')
-rw-r--r--models/actions/runner.go22
1 files changed, 17 insertions, 5 deletions
diff --git a/models/actions/runner.go b/models/actions/runner.go
index cce8b4f443..f1638eb0ba 100644
--- a/models/actions/runner.go
+++ b/models/actions/runner.go
@@ -11,6 +11,7 @@ import (
"code.gitea.io/gitea/models/db"
repo_model "code.gitea.io/gitea/models/repo"
+ "code.gitea.io/gitea/models/shared/types"
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/timeutil"
"code.gitea.io/gitea/modules/translation"
@@ -28,7 +29,7 @@ type ActionRunner struct {
Version string `xorm:"VARCHAR(64)"`
OwnerID int64 `xorm:"index"` // org level runner, 0 means system
Owner *user_model.User `xorm:"-"`
- RepoID int64 `xorm:"index"` // repo level runner, if orgid also is zero, then it's a global
+ RepoID int64 `xorm:"index"` // repo level runner, if OwnerID also is zero, then it's a global
Repo *repo_model.Repository `xorm:"-"`
Description string `xorm:"TEXT"`
Base int // 0 native 1 docker 2 virtual machine
@@ -52,14 +53,25 @@ type ActionRunner struct {
Deleted timeutil.TimeStamp `xorm:"deleted"`
}
-func (r *ActionRunner) OwnType() string {
+// BelongsToOwnerName before calling, should guarantee that all attributes are loaded
+func (r *ActionRunner) BelongsToOwnerName() string {
if r.RepoID != 0 {
- return fmt.Sprintf("Repo(%s)", r.Repo.FullName())
+ return r.Repo.FullName()
}
if r.OwnerID != 0 {
- return fmt.Sprintf("Org(%s)", r.Owner.Name)
+ return r.Owner.Name
}
- return "Global"
+ return ""
+}
+
+func (r *ActionRunner) BelongsToOwnerType() types.OwnerType {
+ if r.RepoID != 0 {
+ return types.OwnerTypeRepository
+ }
+ if r.OwnerID != 0 {
+ return types.OwnerTypeOrganization
+ }
+ return types.OwnerTypeSystemGlobal
}
func (r *ActionRunner) Status() runnerv1.RunnerStatus {