mirror of https://github.com/go-gitea/gitea.git
Add user level action runners (#24995)
Used similar logic to organization. <img width="1437" alt="Screen Shot 2023-05-30 at 10 18 06" src="https://github.com/go-gitea/gitea/assets/17645053/49f3800a-44ae-4188-b1e6-91d49e3d7868"> <img width="1331" alt="Screen Shot 2023-05-30 at 10 31 18" src="https://github.com/go-gitea/gitea/assets/17645053/221b2068-e9b9-4e34-bb4a-d390594b2f35">
This commit is contained in:
parent
4c81dae297
commit
28a89e360f
|
@ -69,7 +69,11 @@ func (r *ActionRunner) BelongsToOwnerType() types.OwnerType {
|
||||||
return types.OwnerTypeRepository
|
return types.OwnerTypeRepository
|
||||||
}
|
}
|
||||||
if r.OwnerID != 0 {
|
if r.OwnerID != 0 {
|
||||||
return types.OwnerTypeOrganization
|
if r.Owner.Type == user_model.UserTypeOrganization {
|
||||||
|
return types.OwnerTypeOrganization
|
||||||
|
} else if r.Owner.Type == user_model.UserTypeIndividual {
|
||||||
|
return types.OwnerTypeIndividual
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return types.OwnerTypeSystemGlobal
|
return types.OwnerTypeSystemGlobal
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,9 +21,11 @@ const (
|
||||||
tplRepoRunners base.TplName = "repo/settings/actions"
|
tplRepoRunners base.TplName = "repo/settings/actions"
|
||||||
tplOrgRunners base.TplName = "org/settings/actions"
|
tplOrgRunners base.TplName = "org/settings/actions"
|
||||||
tplAdminRunners base.TplName = "admin/actions"
|
tplAdminRunners base.TplName = "admin/actions"
|
||||||
|
tplUserRunners base.TplName = "user/settings/actions"
|
||||||
tplRepoRunnerEdit base.TplName = "repo/settings/runner_edit"
|
tplRepoRunnerEdit base.TplName = "repo/settings/runner_edit"
|
||||||
tplOrgRunnerEdit base.TplName = "org/settings/runners_edit"
|
tplOrgRunnerEdit base.TplName = "org/settings/runners_edit"
|
||||||
tplAdminRunnerEdit base.TplName = "admin/runners/edit"
|
tplAdminRunnerEdit base.TplName = "admin/runners/edit"
|
||||||
|
tplUserRunnerEdit base.TplName = "user/settings/runner_edit"
|
||||||
)
|
)
|
||||||
|
|
||||||
type runnersCtx struct {
|
type runnersCtx struct {
|
||||||
|
@ -32,6 +34,7 @@ type runnersCtx struct {
|
||||||
IsRepo bool
|
IsRepo bool
|
||||||
IsOrg bool
|
IsOrg bool
|
||||||
IsAdmin bool
|
IsAdmin bool
|
||||||
|
IsUser bool
|
||||||
RunnersTemplate base.TplName
|
RunnersTemplate base.TplName
|
||||||
RunnerEditTemplate base.TplName
|
RunnerEditTemplate base.TplName
|
||||||
RedirectLink string
|
RedirectLink string
|
||||||
|
@ -71,6 +74,17 @@ func getRunnersCtx(ctx *context.Context) (*runnersCtx, error) {
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ctx.Data["PageIsUserSettings"] == true {
|
||||||
|
return &runnersCtx{
|
||||||
|
OwnerID: ctx.Doer.ID,
|
||||||
|
RepoID: 0,
|
||||||
|
IsUser: true,
|
||||||
|
RunnersTemplate: tplUserRunners,
|
||||||
|
RunnerEditTemplate: tplUserRunnerEdit,
|
||||||
|
RedirectLink: setting.AppSubURL + "/user/settings/actions/runners/",
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
return nil, errors.New("unable to set Runners context")
|
return nil, errors.New("unable to set Runners context")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,7 +116,7 @@ func Runners(ctx *context.Context) {
|
||||||
if rCtx.IsRepo {
|
if rCtx.IsRepo {
|
||||||
opts.RepoID = rCtx.RepoID
|
opts.RepoID = rCtx.RepoID
|
||||||
opts.WithAvailable = true
|
opts.WithAvailable = true
|
||||||
} else if rCtx.IsOrg {
|
} else if rCtx.IsOrg || rCtx.IsUser {
|
||||||
opts.OwnerID = rCtx.OwnerID
|
opts.OwnerID = rCtx.OwnerID
|
||||||
opts.WithAvailable = true
|
opts.WithAvailable = true
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,5 +9,5 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func RedirectToDefaultSetting(ctx *context.Context) {
|
func RedirectToDefaultSetting(ctx *context.Context) {
|
||||||
ctx.Redirect(setting.AppSubURL + "/user/settings/actions/secrets")
|
ctx.Redirect(setting.AppSubURL + "/user/settings/actions/runners")
|
||||||
}
|
}
|
|
@ -492,6 +492,7 @@ func registerRoutes(m *web.Route) {
|
||||||
|
|
||||||
m.Group("/actions", func() {
|
m.Group("/actions", func() {
|
||||||
m.Get("", user_setting.RedirectToDefaultSetting)
|
m.Get("", user_setting.RedirectToDefaultSetting)
|
||||||
|
addSettingsRunnersRoutes()
|
||||||
addSettingsSecretsRoutes()
|
addSettingsSecretsRoutes()
|
||||||
}, actions.MustEnableActions)
|
}, actions.MustEnableActions)
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
<div class="user-setting-content">
|
<div class="user-setting-content">
|
||||||
{{if eq .PageType "secrets"}}
|
{{if eq .PageType "secrets"}}
|
||||||
{{template "shared/secrets/add_list" .}}
|
{{template "shared/secrets/add_list" .}}
|
||||||
|
{{else if eq .PageType "runners"}}
|
||||||
|
{{template "shared/actions/runner_list" .}}
|
||||||
{{end}}
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,9 @@
|
||||||
<div class="item">
|
<div class="item">
|
||||||
{{.locale.Tr "actions.actions"}}
|
{{.locale.Tr "actions.actions"}}
|
||||||
<div class="menu">
|
<div class="menu">
|
||||||
|
<a class="{{if .PageIsSharedSettingsRunners}}active {{end}}item" href="{{AppSubUrl}}/user/settings/actions/runners">
|
||||||
|
{{.locale.Tr "actions.runners"}}
|
||||||
|
</a>
|
||||||
<a class="{{if .PageIsSharedSettingsSecrets}}active {{end}}item" href="{{AppSubUrl}}/user/settings/actions/secrets">
|
<a class="{{if .PageIsSharedSettingsSecrets}}active {{end}}item" href="{{AppSubUrl}}/user/settings/actions/secrets">
|
||||||
{{.locale.Tr "secrets.secrets"}}
|
{{.locale.Tr "secrets.secrets"}}
|
||||||
</a>
|
</a>
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
{{template "user/settings/layout_head" (dict "ctxData" . "pageClass" "user settings runners")}}
|
||||||
|
<div class="user-setting-content">
|
||||||
|
{{template "shared/actions/runner_edit" .}}
|
||||||
|
</div>
|
||||||
|
{{template "user/settings/layout_footer" .}}
|
Loading…
Reference in New Issue