diff options
author | HesterG <hestergong@gmail.com> | 2023-05-31 09:39:54 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-31 09:39:54 +0800 |
commit | 28a89e360f720c5ca7fb71319beb2519adad5972 (patch) | |
tree | 4415e33b9e519bead6b10e3a0605b5d924226292 /routers | |
parent | 4c81dae2977b1723330459be754649c6a3080129 (diff) | |
download | gitea-28a89e360f720c5ca7fb71319beb2519adad5972.tar.gz gitea-28a89e360f720c5ca7fb71319beb2519adad5972.zip |
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">
Diffstat (limited to 'routers')
-rw-r--r-- | routers/web/repo/setting/runners.go | 16 | ||||
-rw-r--r-- | routers/web/user/setting/runner.go (renamed from routers/web/user/setting/secrets.go) | 2 | ||||
-rw-r--r-- | routers/web/web.go | 1 |
3 files changed, 17 insertions, 2 deletions
diff --git a/routers/web/repo/setting/runners.go b/routers/web/repo/setting/runners.go index e8ad635826..2c192e9790 100644 --- a/routers/web/repo/setting/runners.go +++ b/routers/web/repo/setting/runners.go @@ -21,9 +21,11 @@ const ( tplRepoRunners base.TplName = "repo/settings/actions" tplOrgRunners base.TplName = "org/settings/actions" tplAdminRunners base.TplName = "admin/actions" + tplUserRunners base.TplName = "user/settings/actions" tplRepoRunnerEdit base.TplName = "repo/settings/runner_edit" tplOrgRunnerEdit base.TplName = "org/settings/runners_edit" tplAdminRunnerEdit base.TplName = "admin/runners/edit" + tplUserRunnerEdit base.TplName = "user/settings/runner_edit" ) type runnersCtx struct { @@ -32,6 +34,7 @@ type runnersCtx struct { IsRepo bool IsOrg bool IsAdmin bool + IsUser bool RunnersTemplate base.TplName RunnerEditTemplate base.TplName RedirectLink string @@ -71,6 +74,17 @@ func getRunnersCtx(ctx *context.Context) (*runnersCtx, error) { }, 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") } @@ -102,7 +116,7 @@ func Runners(ctx *context.Context) { if rCtx.IsRepo { opts.RepoID = rCtx.RepoID opts.WithAvailable = true - } else if rCtx.IsOrg { + } else if rCtx.IsOrg || rCtx.IsUser { opts.OwnerID = rCtx.OwnerID opts.WithAvailable = true } diff --git a/routers/web/user/setting/secrets.go b/routers/web/user/setting/runner.go index eb09477bdb..451fd0ca97 100644 --- a/routers/web/user/setting/secrets.go +++ b/routers/web/user/setting/runner.go @@ -9,5 +9,5 @@ import ( ) func RedirectToDefaultSetting(ctx *context.Context) { - ctx.Redirect(setting.AppSubURL + "/user/settings/actions/secrets") + ctx.Redirect(setting.AppSubURL + "/user/settings/actions/runners") } diff --git a/routers/web/web.go b/routers/web/web.go index a70e9cc3d3..ef47b6679f 100644 --- a/routers/web/web.go +++ b/routers/web/web.go @@ -492,6 +492,7 @@ func registerRoutes(m *web.Route) { m.Group("/actions", func() { m.Get("", user_setting.RedirectToDefaultSetting) + addSettingsRunnersRoutes() addSettingsSecretsRoutes() }, actions.MustEnableActions) |