Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to set language in admin user view #28449

Merged
merged 17 commits into from
Mar 2, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions routers/web/admin/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ func EditUserPost(ctx *context.Context) {
u.Email = form.Email
u.Website = form.Website
u.Location = form.Location
u.Language = form.Language
u.MaxRepoCreation = form.MaxRepoCreation
u.IsActive = form.Active
u.IsAdmin = form.Admin
Expand Down
1 change: 1 addition & 0 deletions services/forms/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type AdminEditUserForm struct {
Password string `binding:"MaxSize(255)"`
Website string `binding:"ValidUrl;MaxSize(255)"`
Location string `binding:"MaxSize(50)"`
Language string `binding:"MaxSize(5)"`
delvh marked this conversation as resolved.
Show resolved Hide resolved
MaxRepoCreation int
Active bool
Admin bool
Expand Down
15 changes: 15 additions & 0 deletions templates/admin/user/edit.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,21 @@
<input id="password" name="password" type="password" autocomplete="new-password">
<p class="help">{{ctx.Locale.Tr "admin.users.password_helper"}}</p>
</div>

<div class="field {{if .Err_Language}}error{{end}}">
<label for="language">{{ctx.Locale.Tr "settings.language"}}</label>
<div class="ui selection dropdown">
<input name="language" type="hidden" value="{{.User.Language}}">
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
<div class="text">{{range .AllLangs}}{{if eq $.User.Language .Lang}}{{.Name}}{{end}}{{end}}</div>
6543 marked this conversation as resolved.
Show resolved Hide resolved
<div class="menu">
{{range .AllLangs}}
<div class="item{{if eq $.User.Language .Lang}} active selected{{end}}" data-value="{{.Lang}}">{{.Name}}</div>
{{end}}
</div>
</div>
delvh marked this conversation as resolved.
Show resolved Hide resolved
</div>

<div class="field {{if .Err_Website}}error{{end}}">
<label for="website">{{ctx.Locale.Tr "settings.website"}}</label>
<input id="website" name="website" type="url" value="{{.User.Website}}" placeholder="http://mydomain.com or https://mydomain.com" maxlength="255">
Expand Down
8 changes: 8 additions & 0 deletions templates/admin/user/view_details.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@
{{svg "octicon-x"}}
{{end}}
</div>
{{if .User.Language}}
<div class="flex-item-body">
<span class="flex-text-inline">
<b>{{ctx.Locale.Tr "settings.language"}}:</b>
{{range .AllLangs}}{{if eq $.User.Language .Lang}}{{.Name}}{{end}}{{end}}
</span>
</div>
{{end}}
{{if .User.Location}}
<div class="flex-item-body">
<span class="flex-text-inline">{{svg "octicon-location"}}{{.User.Location}}</span>
Expand Down