Skip to content

Commit 63a401a

Browse files
HesterGwxiaoguang
andauthored
Move secrets and runners settings to actions settings (#24200)
This PR moves the secrets and runners settings to actions settings on all settings(repo,org,user,admin) levels. After this PR, if [ENABLED](https://github.com/go-gitea/gitea/blob/5e7543fcf441afb30aba6188edac754ef32b9ac3/custom/conf/app.example.ini#L2604) inside `app.ini` under `[actions]` is set to `false`, the "Actions" tab (including runners management and secrets management) will not be shown. After, the settings under actions settings for each level: 1. Admin Level "Runners Management" <img width="1437" alt="Screen Shot 2023-04-26 at 14 34 20" src="https://user-images.githubusercontent.com/17645053/234489731-15822d21-38e1-4560-8bbe-69f122376abc.png"> 2. User Level "Secrets Management" <img width="1427" alt="Screen Shot 2023-04-26 at 14 34 30" src="https://user-images.githubusercontent.com/17645053/234489795-68c9c0cb-24f8-4f09-95c6-458ab914c313.png"> 3. Repo and Organization Levels "Runners Management" and "Secrets Management" Org: <img width="1437" alt="Screen Shot 2023-04-26 at 14 35 07" src="https://user-images.githubusercontent.com/17645053/234489996-f3af5ebb-d354-46ca-9087-a0b586845281.png"> <img width="1433" alt="Screen Shot 2023-04-26 at 14 35 14" src="https://user-images.githubusercontent.com/17645053/234490004-3abf8fed-81fd-4ce2-837a-935dade1793d.png"> Repo: <img width="1419" alt="Screen Shot 2023-04-26 at 14 34 50" src="https://user-images.githubusercontent.com/17645053/234489904-80c11038-4b58-462c-9d0b-8b7cf70bc2b3.png"> <img width="1430" alt="Screen Shot 2023-04-26 at 14 34 57" src="https://user-images.githubusercontent.com/17645053/234489918-4e8d1fe2-9bcd-4d8a-96c1-238a8088d92e.png"> It also finished these tasks : - [x] rename routers function "runners" to "actions", and refactor related file names - [x] check and modify part of the runners related functions to match their name - [x] Fix backend check caused by fmt check --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
1 parent 6dfc0c8 commit 63a401a

40 files changed

+445
-504
lines changed

options/locale/locale_en-US.ini

+1
Original file line numberDiff line numberDiff line change
@@ -3357,6 +3357,7 @@ deletion = Remove secret
33573357
deletion.description = Removing a secret is permanent and cannot be undone. Continue?
33583358
deletion.success = The secret has been removed.
33593359
deletion.failed = Failed to remove secret.
3360+
management = Secrets Management
33603361
33613362
[actions]
33623363
actions = Actions

routers/web/admin/admin.go

-5
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ func updateSystemStatus() {
113113
// Dashboard show admin panel dashboard
114114
func Dashboard(ctx *context.Context) {
115115
ctx.Data["Title"] = ctx.Tr("admin.dashboard")
116-
ctx.Data["PageIsAdmin"] = true
117116
ctx.Data["PageIsAdminDashboard"] = true
118117
ctx.Data["Stats"] = activities_model.GetStatistic()
119118
ctx.Data["NeedUpdate"] = updatechecker.GetNeedUpdate()
@@ -129,7 +128,6 @@ func Dashboard(ctx *context.Context) {
129128
func DashboardPost(ctx *context.Context) {
130129
form := web.GetForm(ctx).(*forms.AdminDashboardForm)
131130
ctx.Data["Title"] = ctx.Tr("admin.dashboard")
132-
ctx.Data["PageIsAdmin"] = true
133131
ctx.Data["PageIsAdminDashboard"] = true
134132
ctx.Data["Stats"] = activities_model.GetStatistic()
135133
updateSystemStatus()
@@ -155,7 +153,6 @@ func DashboardPost(ctx *context.Context) {
155153
// Monitor show admin monitor page
156154
func Monitor(ctx *context.Context) {
157155
ctx.Data["Title"] = ctx.Tr("admin.monitor")
158-
ctx.Data["PageIsAdmin"] = true
159156
ctx.Data["PageIsAdminMonitor"] = true
160157
ctx.Data["Processes"], ctx.Data["ProcessCount"] = process.GetManager().Processes(false, true)
161158
ctx.Data["Entries"] = cron.ListTasks()
@@ -167,7 +164,6 @@ func Monitor(ctx *context.Context) {
167164
// GoroutineStacktrace show admin monitor goroutines page
168165
func GoroutineStacktrace(ctx *context.Context) {
169166
ctx.Data["Title"] = ctx.Tr("admin.monitor")
170-
ctx.Data["PageIsAdmin"] = true
171167
ctx.Data["PageIsAdminMonitor"] = true
172168

173169
processStacks, processCount, goroutineCount, err := process.GetManager().ProcessStacktraces(false, false)
@@ -202,7 +198,6 @@ func Queue(ctx *context.Context) {
202198
return
203199
}
204200
ctx.Data["Title"] = ctx.Tr("admin.monitor.queue", mq.Name)
205-
ctx.Data["PageIsAdmin"] = true
206201
ctx.Data["PageIsAdminMonitor"] = true
207202
ctx.Data["Queue"] = mq
208203
ctx.HTML(http.StatusOK, tplQueue)

routers/web/admin/applications.go

-5
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ func newOAuth2CommonHandlers() *user_setting.OAuth2CommonHandlers {
3131
// Applications render org applications page (for org, at the moment, there are only OAuth2 applications)
3232
func Applications(ctx *context.Context) {
3333
ctx.Data["Title"] = ctx.Tr("settings.applications")
34-
ctx.Data["PageIsAdmin"] = true
3534
ctx.Data["PageIsAdminApplications"] = true
3635

3736
apps, err := auth.GetOAuth2ApplicationsByUserID(ctx, 0)
@@ -47,7 +46,6 @@ func Applications(ctx *context.Context) {
4746
// ApplicationsPost response for adding an oauth2 application
4847
func ApplicationsPost(ctx *context.Context) {
4948
ctx.Data["Title"] = ctx.Tr("settings.applications")
50-
ctx.Data["PageIsAdmin"] = true
5149
ctx.Data["PageIsAdminApplications"] = true
5250

5351
oa := newOAuth2CommonHandlers()
@@ -56,7 +54,6 @@ func ApplicationsPost(ctx *context.Context) {
5654

5755
// EditApplication displays the given application
5856
func EditApplication(ctx *context.Context) {
59-
ctx.Data["PageIsAdmin"] = true
6057
ctx.Data["PageIsAdminApplications"] = true
6158

6259
oa := newOAuth2CommonHandlers()
@@ -66,7 +63,6 @@ func EditApplication(ctx *context.Context) {
6663
// EditApplicationPost response for editing oauth2 application
6764
func EditApplicationPost(ctx *context.Context) {
6865
ctx.Data["Title"] = ctx.Tr("settings.applications")
69-
ctx.Data["PageIsAdmin"] = true
7066
ctx.Data["PageIsAdminApplications"] = true
7167

7268
oa := newOAuth2CommonHandlers()
@@ -76,7 +72,6 @@ func EditApplicationPost(ctx *context.Context) {
7672
// ApplicationsRegenerateSecret handles the post request for regenerating the secret
7773
func ApplicationsRegenerateSecret(ctx *context.Context) {
7874
ctx.Data["Title"] = ctx.Tr("settings")
79-
ctx.Data["PageIsAdmin"] = true
8075
ctx.Data["PageIsAdminApplications"] = true
8176

8277
oa := newOAuth2CommonHandlers()

routers/web/admin/auths.go

-5
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ var (
4545
// Authentications show authentication config page
4646
func Authentications(ctx *context.Context) {
4747
ctx.Data["Title"] = ctx.Tr("admin.authentication")
48-
ctx.Data["PageIsAdmin"] = true
4948
ctx.Data["PageIsAdminAuthentications"] = true
5049

5150
var err error
@@ -89,7 +88,6 @@ var (
8988
// NewAuthSource render adding a new auth source page
9089
func NewAuthSource(ctx *context.Context) {
9190
ctx.Data["Title"] = ctx.Tr("admin.auths.new")
92-
ctx.Data["PageIsAdmin"] = true
9391
ctx.Data["PageIsAdminAuthentications"] = true
9492

9593
ctx.Data["type"] = auth.LDAP.Int()
@@ -237,7 +235,6 @@ func parseSSPIConfig(ctx *context.Context, form forms.AuthenticationForm) (*sspi
237235
func NewAuthSourcePost(ctx *context.Context) {
238236
form := *web.GetForm(ctx).(*forms.AuthenticationForm)
239237
ctx.Data["Title"] = ctx.Tr("admin.auths.new")
240-
ctx.Data["PageIsAdmin"] = true
241238
ctx.Data["PageIsAdminAuthentications"] = true
242239

243240
ctx.Data["CurrentTypeName"] = auth.Type(form.Type).String()
@@ -333,7 +330,6 @@ func NewAuthSourcePost(ctx *context.Context) {
333330
// EditAuthSource render editing auth source page
334331
func EditAuthSource(ctx *context.Context) {
335332
ctx.Data["Title"] = ctx.Tr("admin.auths.edit")
336-
ctx.Data["PageIsAdmin"] = true
337333
ctx.Data["PageIsAdminAuthentications"] = true
338334

339335
ctx.Data["SecurityProtocols"] = securityProtocols
@@ -369,7 +365,6 @@ func EditAuthSource(ctx *context.Context) {
369365
func EditAuthSourcePost(ctx *context.Context) {
370366
form := *web.GetForm(ctx).(*forms.AuthenticationForm)
371367
ctx.Data["Title"] = ctx.Tr("admin.auths.edit")
372-
ctx.Data["PageIsAdmin"] = true
373368
ctx.Data["PageIsAdminAuthentications"] = true
374369

375370
ctx.Data["SMTPAuths"] = smtp.Authenticators

routers/web/admin/config.go

-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ func shadowPassword(provider, cfgItem string) string {
100100
// Config show admin config page
101101
func Config(ctx *context.Context) {
102102
ctx.Data["Title"] = ctx.Tr("admin.config")
103-
ctx.Data["PageIsAdmin"] = true
104103
ctx.Data["PageIsAdminConfig"] = true
105104

106105
systemSettings, err := system_model.GetAllSettings(ctx)

routers/web/admin/emails.go

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ const (
2424
// Emails show all emails
2525
func Emails(ctx *context.Context) {
2626
ctx.Data["Title"] = ctx.Tr("admin.emails")
27-
ctx.Data["PageIsAdmin"] = true
2827
ctx.Data["PageIsAdminEmails"] = true
2928

3029
opts := &user_model.SearchEmailOptions{

routers/web/admin/notice.go

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ const (
2222
// Notices show notices for admin
2323
func Notices(ctx *context.Context) {
2424
ctx.Data["Title"] = ctx.Tr("admin.notices")
25-
ctx.Data["PageIsAdmin"] = true
2625
ctx.Data["PageIsAdminNotices"] = true
2726

2827
total := system_model.CountNotices()

routers/web/admin/orgs.go

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ const (
2121
// Organizations show all the organizations
2222
func Organizations(ctx *context.Context) {
2323
ctx.Data["Title"] = ctx.Tr("admin.organizations")
24-
ctx.Data["PageIsAdmin"] = true
2524
ctx.Data["PageIsAdminOrganizations"] = true
2625

2726
explore.RenderUserSearch(ctx, &user_model.SearchUserOptions{

routers/web/admin/packages.go

-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ func Packages(ctx *context.Context) {
6464
}
6565

6666
ctx.Data["Title"] = ctx.Tr("packages.title")
67-
ctx.Data["PageIsAdmin"] = true
6867
ctx.Data["PageIsAdminPackages"] = true
6968
ctx.Data["Query"] = query
7069
ctx.Data["PackageType"] = packageType

routers/web/admin/repos.go

-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ const (
2929
// Repos show all the repositories
3030
func Repos(ctx *context.Context) {
3131
ctx.Data["Title"] = ctx.Tr("admin.repositories")
32-
ctx.Data["PageIsAdmin"] = true
3332
ctx.Data["PageIsAdminRepositories"] = true
3433

3534
explore.RenderRepoSearch(ctx, &explore.RepoSearchOptions{
@@ -67,7 +66,6 @@ func DeleteRepo(ctx *context.Context) {
6766
// UnadoptedRepos lists the unadopted repositories
6867
func UnadoptedRepos(ctx *context.Context) {
6968
ctx.Data["Title"] = ctx.Tr("admin.repositories")
70-
ctx.Data["PageIsAdmin"] = true
7169
ctx.Data["PageIsAdminRepositories"] = true
7270

7371
opts := db.ListOptions{

routers/web/admin/runners.go

+2-67
Original file line numberDiff line numberDiff line change
@@ -4,75 +4,10 @@
44
package admin
55

66
import (
7-
"net/url"
8-
9-
actions_model "code.gitea.io/gitea/models/actions"
10-
"code.gitea.io/gitea/models/db"
11-
"code.gitea.io/gitea/modules/base"
127
"code.gitea.io/gitea/modules/context"
138
"code.gitea.io/gitea/modules/setting"
14-
actions_shared "code.gitea.io/gitea/routers/web/shared/actions"
15-
)
16-
17-
const (
18-
tplRunners base.TplName = "admin/runners/base"
19-
tplRunnerEdit base.TplName = "admin/runners/edit"
209
)
2110

22-
// Runners show all the runners
23-
func Runners(ctx *context.Context) {
24-
ctx.Data["Title"] = ctx.Tr("actions.runners")
25-
ctx.Data["PageIsAdmin"] = true
26-
ctx.Data["PageIsAdminRunners"] = true
27-
28-
page := ctx.FormInt("page")
29-
if page <= 1 {
30-
page = 1
31-
}
32-
33-
opts := actions_model.FindRunnerOptions{
34-
ListOptions: db.ListOptions{
35-
Page: page,
36-
PageSize: 100,
37-
},
38-
Sort: ctx.Req.URL.Query().Get("sort"),
39-
Filter: ctx.Req.URL.Query().Get("q"),
40-
}
41-
42-
actions_shared.RunnersList(ctx, tplRunners, opts)
43-
}
44-
45-
// EditRunner show editing runner page
46-
func EditRunner(ctx *context.Context) {
47-
ctx.Data["Title"] = ctx.Tr("actions.runners.edit_runner")
48-
ctx.Data["PageIsAdmin"] = true
49-
ctx.Data["PageIsAdminRunners"] = true
50-
51-
page := ctx.FormInt("page")
52-
if page <= 1 {
53-
page = 1
54-
}
55-
56-
actions_shared.RunnerDetails(ctx, tplRunnerEdit, page, ctx.ParamsInt64(":runnerid"), 0, 0)
57-
}
58-
59-
// EditRunnerPost response for editing runner
60-
func EditRunnerPost(ctx *context.Context) {
61-
ctx.Data["Title"] = ctx.Tr("actions.runners.edit")
62-
ctx.Data["PageIsAdmin"] = true
63-
ctx.Data["PageIsAdminRunners"] = true
64-
actions_shared.RunnerDetailsEditPost(ctx, ctx.ParamsInt64(":runnerid"), 0, 0,
65-
setting.AppSubURL+"/admin/runners/"+url.PathEscape(ctx.Params(":runnerid")))
66-
}
67-
68-
// DeleteRunnerPost response for deleting a runner
69-
func DeleteRunnerPost(ctx *context.Context) {
70-
actions_shared.RunnerDeletePost(ctx, ctx.ParamsInt64(":runnerid"),
71-
setting.AppSubURL+"/admin/runners/",
72-
setting.AppSubURL+"/admin/runners/"+url.PathEscape(ctx.Params(":runnerid")),
73-
)
74-
}
75-
76-
func ResetRunnerRegistrationToken(ctx *context.Context) {
77-
actions_shared.RunnerResetRegistrationToken(ctx, 0, 0, setting.AppSubURL+"/admin/runners/")
11+
func RedirectToDefaultSetting(ctx *context.Context) {
12+
ctx.Redirect(setting.AppSubURL + "/admin/actions/runners")
7813
}

routers/web/admin/users.go

-5
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ const (
3737
// Users show all the users
3838
func Users(ctx *context.Context) {
3939
ctx.Data["Title"] = ctx.Tr("admin.users")
40-
ctx.Data["PageIsAdmin"] = true
4140
ctx.Data["PageIsAdminUsers"] = true
4241

4342
extraParamStrings := map[string]string{}
@@ -80,7 +79,6 @@ func Users(ctx *context.Context) {
8079
// NewUser render adding a new user page
8180
func NewUser(ctx *context.Context) {
8281
ctx.Data["Title"] = ctx.Tr("admin.users.new_account")
83-
ctx.Data["PageIsAdmin"] = true
8482
ctx.Data["PageIsAdminUsers"] = true
8583
ctx.Data["DefaultUserVisibilityMode"] = setting.Service.DefaultUserVisibilityMode
8684
ctx.Data["AllowedUserVisibilityModes"] = setting.Service.AllowedUserVisibilityModesSlice.ToVisibleTypeSlice()
@@ -102,7 +100,6 @@ func NewUser(ctx *context.Context) {
102100
func NewUserPost(ctx *context.Context) {
103101
form := web.GetForm(ctx).(*forms.AdminCreateUserForm)
104102
ctx.Data["Title"] = ctx.Tr("admin.users.new_account")
105-
ctx.Data["PageIsAdmin"] = true
106103
ctx.Data["PageIsAdminUsers"] = true
107104
ctx.Data["DefaultUserVisibilityMode"] = setting.Service.DefaultUserVisibilityMode
108105
ctx.Data["AllowedUserVisibilityModes"] = setting.Service.AllowedUserVisibilityModesSlice.ToVisibleTypeSlice()
@@ -253,7 +250,6 @@ func prepareUserInfo(ctx *context.Context) *user_model.User {
253250
// EditUser show editing user page
254251
func EditUser(ctx *context.Context) {
255252
ctx.Data["Title"] = ctx.Tr("admin.users.edit_account")
256-
ctx.Data["PageIsAdmin"] = true
257253
ctx.Data["PageIsAdminUsers"] = true
258254
ctx.Data["DisableRegularOrgCreation"] = setting.Admin.DisableRegularOrgCreation
259255
ctx.Data["DisableMigrations"] = setting.Repository.DisableMigrations
@@ -271,7 +267,6 @@ func EditUser(ctx *context.Context) {
271267
func EditUserPost(ctx *context.Context) {
272268
form := web.GetForm(ctx).(*forms.AdminEditUserForm)
273269
ctx.Data["Title"] = ctx.Tr("admin.users.edit_account")
274-
ctx.Data["PageIsAdmin"] = true
275270
ctx.Data["PageIsAdminUsers"] = true
276271
ctx.Data["DisableMigrations"] = setting.Repository.DisableMigrations
277272
ctx.Data["AllowedUserVisibilityModes"] = setting.Service.AllowedUserVisibilityModesSlice.ToVisibleTypeSlice()

routers/web/org/org_runners.go

-78
This file was deleted.

routers/web/org/setting.go

-4
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@ const (
3737
tplSettingsHooks base.TplName = "org/settings/hooks"
3838
// tplSettingsLabels template path for render labels settings
3939
tplSettingsLabels base.TplName = "org/settings/labels"
40-
// tplSettingsRunners template path for render runners settings
41-
tplSettingsRunners base.TplName = "org/settings/runners"
42-
// tplSettingsRunnersEdit template path for render runners edit settings
43-
tplSettingsRunnersEdit base.TplName = "org/settings/runners_edit"
4440
)
4541

4642
// Settings render the main settings page

0 commit comments

Comments
 (0)