Skip to content

Commit b37e098

Browse files
GiteaBotsilverwindclaudewxiaoguang
authored
Indicate form field readonly via background, fix RunUser config (#37175, #37180) (#37184)
Backport #37175 by @silverwind The `Run As Username` field on the install page was a `readonly` input that looked editable but wasn't, confusing users. Style `readonly` inputs with a subtle background, matching other frameworks. <img width="735" height="131" alt="image" src="https://github.com/user-attachments/assets/cb76ce71-faab-4300-811e-e4c503b59f9a" /> Backport #37180 The comment "so just use current one if config says default" is not right anymore: "git" isn't the "default" value of RunUser (Comment out app.example.ini #15807). The RunUser's value is from current session's username. Fixes #37174 --------- Signed-off-by: wxiaoguang <wxiaoguang@gmail.com> Signed-off-by: silverwind <me@silverwind.io> Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: Claude (Opus 4.6) <noreply@anthropic.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
1 parent f9b808a commit b37e098

7 files changed

Lines changed: 122 additions & 24 deletions

File tree

custom/conf/app.example.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@
4141
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4242
;;
4343
;; App name that shows in every page title
44-
APP_NAME = ; Gitea: Git with a cup of tea
44+
;APP_NAME = Gitea: Git with a cup of tea
4545
;;
4646
;; RUN_USER will automatically detect the current user - but you can set it here change it if you run locally
47-
RUN_USER = ; git
47+
;RUN_USER =
4848
;;
4949
;; Application run mode, affects performance and debugging: "dev" or "prod", default is "prod"
5050
;; Mode "dev" makes Gitea easier to develop and debug, values other than "dev" are treated as "prod" which is for production use.

modules/setting/setting.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ func mustCurrentRunUserMatch(rootCfg ConfigProvider) {
201201
if HasInstallLock(rootCfg) {
202202
currentUser, match := IsRunUserMatchCurrentUser(RunUser)
203203
if !match {
204-
log.Fatal("Expect user '%s' but current user is: %s", RunUser, currentUser)
204+
log.Fatal("Expect user '%s' (RUN_USER in app.ini) but current user is: %s", RunUser, currentUser)
205205
}
206206
}
207207
}

options/locale/locale_en-US.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@
269269
"install.lfs_path": "Git LFS Root Path",
270270
"install.lfs_path_helper": "Files tracked by Git LFS will be stored in this directory. Leave empty to disable.",
271271
"install.run_user": "Run As Username",
272-
"install.run_user_helper": "The operating system username that Gitea runs as. Note that this user must have access to the repository root path.",
272+
"install.run_user_helper": "The operating system username that Gitea runs as, it must have write access to the data paths. This value is auto-detected and cannot be changed here. To use a different user, restart Gitea under that account.",
273273
"install.domain": "Server Domain",
274274
"install.domain_helper": "Domain or host address for the server.",
275275
"install.ssh_port": "SSH Server Port",
@@ -316,7 +316,6 @@
316316
"install.invalid_db_table": "The database table \"%s\" is invalid: %v",
317317
"install.invalid_repo_path": "The repository root path is invalid: %v",
318318
"install.invalid_app_data_path": "The app data path is invalid: %v",
319-
"install.run_user_not_match": "The 'run as' username is not the current username: %s -> %s",
320319
"install.internal_token_failed": "Failed to generate internal token: %v",
321320
"install.secret_key_failed": "Failed to generate secret key: %v",
322321
"install.save_config_failed": "Failed to save configuration: %v",

routers/install/install.go

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import (
2626
"code.gitea.io/gitea/modules/setting"
2727
"code.gitea.io/gitea/modules/templates"
2828
"code.gitea.io/gitea/modules/timeutil"
29-
"code.gitea.io/gitea/modules/user"
3029
"code.gitea.io/gitea/modules/web"
3130
"code.gitea.io/gitea/modules/web/middleware"
3231
"code.gitea.io/gitea/routers/common"
@@ -87,15 +86,7 @@ func Install(ctx *context.Context) {
8786
form.AppName = setting.AppName
8887
form.RepoRootPath = setting.RepoRootPath
8988
form.LFSRootPath = setting.LFS.Storage.Path
90-
91-
// Note(unknown): it's hard for Windows users change a running user,
92-
// so just use current one if config says default.
93-
if setting.IsWindows && setting.RunUser == "git" {
94-
form.RunUser = user.CurrentUsername()
95-
} else {
96-
form.RunUser = setting.RunUser
97-
}
98-
89+
form.RunUser = setting.RunUser
9990
form.Domain = setting.Domain
10091
form.SSHPort = setting.SSH.Port
10192
form.HTTPPort = setting.HTTPPort
@@ -272,13 +263,6 @@ func SubmitInstall(ctx *context.Context) {
272263
return
273264
}
274265

275-
currentUser, match := setting.IsRunUserMatchCurrentUser(form.RunUser)
276-
if !match {
277-
ctx.Data["Err_RunUser"] = true
278-
ctx.RenderWithErrDeprecated(ctx.Tr("install.run_user_not_match", form.RunUser, currentUser), tplInstall, &form)
279-
return
280-
}
281-
282266
// Check logic loophole between disable self-registration and no admin account.
283267
if form.DisableRegistration && len(form.AdminName) == 0 {
284268
ctx.Data["Err_Services"] = true

templates/devtest/form-fields.tmpl

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
{{template "devtest/devtest-header"}}
2+
<div class="page-content devtest ui container">
3+
<form class="ui form left-right-form">
4+
<h4 class="ui dividing header">Input</h4>
5+
<div class="inline field">
6+
<label>Normal</label>
7+
<input type="text" value="value">
8+
</div>
9+
<div class="inline field">
10+
<label>Readonly</label>
11+
<input type="text" value="value" readonly>
12+
</div>
13+
<div class="inline disabled field">
14+
<label>Disabled</label>
15+
<input type="text" value="value" disabled>
16+
</div>
17+
<div class="inline field error">
18+
<label>Error</label>
19+
<input type="text" value="value">
20+
</div>
21+
22+
<h4 class="ui dividing header">Textarea</h4>
23+
<div class="inline field">
24+
<label>Normal</label>
25+
<textarea rows="2">value</textarea>
26+
</div>
27+
<div class="inline field">
28+
<label>Readonly</label>
29+
<textarea rows="2" readonly>value</textarea>
30+
</div>
31+
<div class="inline disabled field">
32+
<label>Disabled</label>
33+
<textarea rows="2" disabled>value</textarea>
34+
</div>
35+
<div class="inline field error">
36+
<label>Error</label>
37+
<textarea rows="2">value</textarea>
38+
</div>
39+
40+
<h4 class="ui dividing header">Dropdown</h4>
41+
<div class="inline field">
42+
<label>Normal</label>
43+
<div class="ui selection dropdown">
44+
<input type="hidden" value="a">
45+
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
46+
<div class="text">Option A</div>
47+
<div class="menu">
48+
<div class="item" data-value="a">Option A</div>
49+
<div class="item" data-value="b">Option B</div>
50+
</div>
51+
</div>
52+
</div>
53+
<div class="inline field">
54+
<label>Readonly</label>
55+
<div class="ui selection dropdown" readonly>
56+
<input type="hidden" value="a">
57+
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
58+
<div class="text">Option A</div>
59+
<div class="menu">
60+
<div class="item" data-value="a">Option A</div>
61+
<div class="item" data-value="b">Option B</div>
62+
</div>
63+
</div>
64+
</div>
65+
<div class="inline disabled field">
66+
<label>Disabled</label>
67+
<div class="ui selection dropdown">
68+
<input type="hidden" value="a">
69+
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
70+
<div class="text">Option A</div>
71+
<div class="menu">
72+
<div class="item" data-value="a">Option A</div>
73+
<div class="item" data-value="b">Option B</div>
74+
</div>
75+
</div>
76+
</div>
77+
<div class="inline field error">
78+
<label>Error</label>
79+
<div class="ui selection dropdown">
80+
<input type="hidden" value="a">
81+
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
82+
<div class="text">Option A</div>
83+
<div class="menu">
84+
<div class="item" data-value="a">Option A</div>
85+
<div class="item" data-value="b">Option B</div>
86+
</div>
87+
</div>
88+
</div>
89+
90+
<h4 class="ui dividing header">Required</h4>
91+
<div class="inline required field">
92+
<label>Normal</label>
93+
<input type="text" value="value">
94+
</div>
95+
<div class="inline required field">
96+
<label>Readonly</label>
97+
<input type="text" value="value" readonly>
98+
</div>
99+
<div class="inline required disabled field">
100+
<label>Disabled</label>
101+
<input type="text" value="value" disabled>
102+
</div>
103+
<div class="inline required field error">
104+
<label>Error</label>
105+
<input type="text" value="value">
106+
</div>
107+
</form>
108+
</div>
109+
{{template "devtest/devtest-footer"}}

templates/install.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@
117117
<input id="lfs_root_path" name="lfs_root_path" value="{{.lfs_root_path}}">
118118
<span class="help">{{ctx.Locale.Tr "install.lfs_path_helper"}}</span>
119119
</div>
120-
<div class="inline required field {{if .Err_RunUser}}error{{end}}">
120+
<div class="inline field">
121121
<label for="run_user">{{ctx.Locale.Tr "install.run_user"}}</label>
122122
<input id="run_user" name="run_user" value="{{.run_user}}" readonly>
123123
<span class="help">{{ctx.Locale.Tr "install.run_user_helper"}}</span>

web_src/css/modules/form.css

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,13 @@ textarea:focus,
9999
color: var(--color-input-text);
100100
}
101101

102+
.ui.form input:not([type="checkbox"], [type="radio"])[readonly],
103+
.ui.form textarea[readonly],
104+
.ui.form select[readonly],
105+
.ui.form .ui.selection.dropdown[readonly] {
106+
background: var(--color-secondary-bg);
107+
}
108+
102109
.ui.input {
103110
color: var(--color-input-text);
104111
}
@@ -198,7 +205,6 @@ textarea:focus,
198205
background-color: var(--color-error-bg);
199206
border-color: var(--color-error-border);
200207
color: var(--color-error-text);
201-
border-radius: 0;
202208
}
203209
.ui.form .field.error textarea:focus,
204210
.ui.form .field.error select:focus,

0 commit comments

Comments
 (0)