mirror of
https://github.com/go-gitea/gitea.git
synced 2026-04-13 20:20:06 +02:00
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>
This commit is contained in:
parent
f9b808a8d2
commit
b37e098ff0
@ -41,10 +41,10 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;
|
||||
;; App name that shows in every page title
|
||||
APP_NAME = ; Gitea: Git with a cup of tea
|
||||
;APP_NAME = Gitea: Git with a cup of tea
|
||||
;;
|
||||
;; RUN_USER will automatically detect the current user - but you can set it here change it if you run locally
|
||||
RUN_USER = ; git
|
||||
;RUN_USER =
|
||||
;;
|
||||
;; Application run mode, affects performance and debugging: "dev" or "prod", default is "prod"
|
||||
;; Mode "dev" makes Gitea easier to develop and debug, values other than "dev" are treated as "prod" which is for production use.
|
||||
|
||||
@ -201,7 +201,7 @@ func mustCurrentRunUserMatch(rootCfg ConfigProvider) {
|
||||
if HasInstallLock(rootCfg) {
|
||||
currentUser, match := IsRunUserMatchCurrentUser(RunUser)
|
||||
if !match {
|
||||
log.Fatal("Expect user '%s' but current user is: %s", RunUser, currentUser)
|
||||
log.Fatal("Expect user '%s' (RUN_USER in app.ini) but current user is: %s", RunUser, currentUser)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -269,7 +269,7 @@
|
||||
"install.lfs_path": "Git LFS Root Path",
|
||||
"install.lfs_path_helper": "Files tracked by Git LFS will be stored in this directory. Leave empty to disable.",
|
||||
"install.run_user": "Run As Username",
|
||||
"install.run_user_helper": "The operating system username that Gitea runs as. Note that this user must have access to the repository root path.",
|
||||
"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.",
|
||||
"install.domain": "Server Domain",
|
||||
"install.domain_helper": "Domain or host address for the server.",
|
||||
"install.ssh_port": "SSH Server Port",
|
||||
@ -316,7 +316,6 @@
|
||||
"install.invalid_db_table": "The database table \"%s\" is invalid: %v",
|
||||
"install.invalid_repo_path": "The repository root path is invalid: %v",
|
||||
"install.invalid_app_data_path": "The app data path is invalid: %v",
|
||||
"install.run_user_not_match": "The 'run as' username is not the current username: %s -> %s",
|
||||
"install.internal_token_failed": "Failed to generate internal token: %v",
|
||||
"install.secret_key_failed": "Failed to generate secret key: %v",
|
||||
"install.save_config_failed": "Failed to save configuration: %v",
|
||||
|
||||
@ -26,7 +26,6 @@ import (
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
"code.gitea.io/gitea/modules/templates"
|
||||
"code.gitea.io/gitea/modules/timeutil"
|
||||
"code.gitea.io/gitea/modules/user"
|
||||
"code.gitea.io/gitea/modules/web"
|
||||
"code.gitea.io/gitea/modules/web/middleware"
|
||||
"code.gitea.io/gitea/routers/common"
|
||||
@ -87,15 +86,7 @@ func Install(ctx *context.Context) {
|
||||
form.AppName = setting.AppName
|
||||
form.RepoRootPath = setting.RepoRootPath
|
||||
form.LFSRootPath = setting.LFS.Storage.Path
|
||||
|
||||
// Note(unknown): it's hard for Windows users change a running user,
|
||||
// so just use current one if config says default.
|
||||
if setting.IsWindows && setting.RunUser == "git" {
|
||||
form.RunUser = user.CurrentUsername()
|
||||
} else {
|
||||
form.RunUser = setting.RunUser
|
||||
}
|
||||
|
||||
form.RunUser = setting.RunUser
|
||||
form.Domain = setting.Domain
|
||||
form.SSHPort = setting.SSH.Port
|
||||
form.HTTPPort = setting.HTTPPort
|
||||
@ -272,13 +263,6 @@ func SubmitInstall(ctx *context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
currentUser, match := setting.IsRunUserMatchCurrentUser(form.RunUser)
|
||||
if !match {
|
||||
ctx.Data["Err_RunUser"] = true
|
||||
ctx.RenderWithErrDeprecated(ctx.Tr("install.run_user_not_match", form.RunUser, currentUser), tplInstall, &form)
|
||||
return
|
||||
}
|
||||
|
||||
// Check logic loophole between disable self-registration and no admin account.
|
||||
if form.DisableRegistration && len(form.AdminName) == 0 {
|
||||
ctx.Data["Err_Services"] = true
|
||||
|
||||
109
templates/devtest/form-fields.tmpl
Normal file
109
templates/devtest/form-fields.tmpl
Normal file
@ -0,0 +1,109 @@
|
||||
{{template "devtest/devtest-header"}}
|
||||
<div class="page-content devtest ui container">
|
||||
<form class="ui form left-right-form">
|
||||
<h4 class="ui dividing header">Input</h4>
|
||||
<div class="inline field">
|
||||
<label>Normal</label>
|
||||
<input type="text" value="value">
|
||||
</div>
|
||||
<div class="inline field">
|
||||
<label>Readonly</label>
|
||||
<input type="text" value="value" readonly>
|
||||
</div>
|
||||
<div class="inline disabled field">
|
||||
<label>Disabled</label>
|
||||
<input type="text" value="value" disabled>
|
||||
</div>
|
||||
<div class="inline field error">
|
||||
<label>Error</label>
|
||||
<input type="text" value="value">
|
||||
</div>
|
||||
|
||||
<h4 class="ui dividing header">Textarea</h4>
|
||||
<div class="inline field">
|
||||
<label>Normal</label>
|
||||
<textarea rows="2">value</textarea>
|
||||
</div>
|
||||
<div class="inline field">
|
||||
<label>Readonly</label>
|
||||
<textarea rows="2" readonly>value</textarea>
|
||||
</div>
|
||||
<div class="inline disabled field">
|
||||
<label>Disabled</label>
|
||||
<textarea rows="2" disabled>value</textarea>
|
||||
</div>
|
||||
<div class="inline field error">
|
||||
<label>Error</label>
|
||||
<textarea rows="2">value</textarea>
|
||||
</div>
|
||||
|
||||
<h4 class="ui dividing header">Dropdown</h4>
|
||||
<div class="inline field">
|
||||
<label>Normal</label>
|
||||
<div class="ui selection dropdown">
|
||||
<input type="hidden" value="a">
|
||||
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
|
||||
<div class="text">Option A</div>
|
||||
<div class="menu">
|
||||
<div class="item" data-value="a">Option A</div>
|
||||
<div class="item" data-value="b">Option B</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="inline field">
|
||||
<label>Readonly</label>
|
||||
<div class="ui selection dropdown" readonly>
|
||||
<input type="hidden" value="a">
|
||||
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
|
||||
<div class="text">Option A</div>
|
||||
<div class="menu">
|
||||
<div class="item" data-value="a">Option A</div>
|
||||
<div class="item" data-value="b">Option B</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="inline disabled field">
|
||||
<label>Disabled</label>
|
||||
<div class="ui selection dropdown">
|
||||
<input type="hidden" value="a">
|
||||
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
|
||||
<div class="text">Option A</div>
|
||||
<div class="menu">
|
||||
<div class="item" data-value="a">Option A</div>
|
||||
<div class="item" data-value="b">Option B</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="inline field error">
|
||||
<label>Error</label>
|
||||
<div class="ui selection dropdown">
|
||||
<input type="hidden" value="a">
|
||||
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
|
||||
<div class="text">Option A</div>
|
||||
<div class="menu">
|
||||
<div class="item" data-value="a">Option A</div>
|
||||
<div class="item" data-value="b">Option B</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h4 class="ui dividing header">Required</h4>
|
||||
<div class="inline required field">
|
||||
<label>Normal</label>
|
||||
<input type="text" value="value">
|
||||
</div>
|
||||
<div class="inline required field">
|
||||
<label>Readonly</label>
|
||||
<input type="text" value="value" readonly>
|
||||
</div>
|
||||
<div class="inline required disabled field">
|
||||
<label>Disabled</label>
|
||||
<input type="text" value="value" disabled>
|
||||
</div>
|
||||
<div class="inline required field error">
|
||||
<label>Error</label>
|
||||
<input type="text" value="value">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
{{template "devtest/devtest-footer"}}
|
||||
@ -117,7 +117,7 @@
|
||||
<input id="lfs_root_path" name="lfs_root_path" value="{{.lfs_root_path}}">
|
||||
<span class="help">{{ctx.Locale.Tr "install.lfs_path_helper"}}</span>
|
||||
</div>
|
||||
<div class="inline required field {{if .Err_RunUser}}error{{end}}">
|
||||
<div class="inline field">
|
||||
<label for="run_user">{{ctx.Locale.Tr "install.run_user"}}</label>
|
||||
<input id="run_user" name="run_user" value="{{.run_user}}" readonly>
|
||||
<span class="help">{{ctx.Locale.Tr "install.run_user_helper"}}</span>
|
||||
|
||||
@ -99,6 +99,13 @@ textarea:focus,
|
||||
color: var(--color-input-text);
|
||||
}
|
||||
|
||||
.ui.form input:not([type="checkbox"], [type="radio"])[readonly],
|
||||
.ui.form textarea[readonly],
|
||||
.ui.form select[readonly],
|
||||
.ui.form .ui.selection.dropdown[readonly] {
|
||||
background: var(--color-secondary-bg);
|
||||
}
|
||||
|
||||
.ui.input {
|
||||
color: var(--color-input-text);
|
||||
}
|
||||
@ -198,7 +205,6 @@ textarea:focus,
|
||||
background-color: var(--color-error-bg);
|
||||
border-color: var(--color-error-border);
|
||||
color: var(--color-error-text);
|
||||
border-radius: 0;
|
||||
}
|
||||
.ui.form .field.error textarea:focus,
|
||||
.ui.form .field.error select:focus,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user