Skip to content

Commit 198a9ca

Browse files
lunnydelvh
andauthored
Display all user types and org types on admin management UI (#27050)
Follow #24026 <img width="1049" alt="图片" src="https://github.com/go-gitea/gitea/assets/81045/d3fc5159-b5e7-411a-b6f8-4a111a027e6b"> --------- Co-authored-by: delvh <[email protected]>
1 parent a457eb9 commit 198a9ca

File tree

6 files changed

+32
-4
lines changed

6 files changed

+32
-4
lines changed

models/user/search.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,26 @@ type SearchUserOptions struct {
3434
IsRestricted util.OptionalBool
3535
IsTwoFactorEnabled util.OptionalBool
3636
IsProhibitLogin util.OptionalBool
37+
IncludeReserved bool
3738

3839
ExtraParamStrings map[string]string
3940
}
4041

4142
func (opts *SearchUserOptions) toSearchQueryBase() *xorm.Session {
42-
var cond builder.Cond = builder.Eq{"type": opts.Type}
43+
var cond builder.Cond
44+
cond = builder.Eq{"type": opts.Type}
45+
if opts.IncludeReserved {
46+
if opts.Type == UserTypeIndividual {
47+
cond = cond.Or(builder.Eq{"type": UserTypeUserReserved}).Or(
48+
builder.Eq{"type": UserTypeBot},
49+
).Or(
50+
builder.Eq{"type": UserTypeRemoteUser},
51+
)
52+
} else if opts.Type == UserTypeOrganization {
53+
cond = cond.Or(builder.Eq{"type": UserTypeOrganizationReserved})
54+
}
55+
}
56+
4357
if len(opts.Keyword) > 0 {
4458
lowerKeyword := strings.ToLower(opts.Keyword)
4559
keywordCond := builder.Or(

options/locale/locale_en-US.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2780,6 +2780,9 @@ users.full_name = Full Name
27802780
users.activated = Activated
27812781
users.admin = Admin
27822782
users.restricted = Restricted
2783+
users.reserved = Reserved
2784+
users.bot = Bot
2785+
users.remote = Remote
27832786
users.2fa = 2FA
27842787
users.repos = Repos
27852788
users.created = Created

routers/web/admin/orgs.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ func Organizations(ctx *context.Context) {
2828
}
2929

3030
explore.RenderUserSearch(ctx, &user_model.SearchUserOptions{
31-
Actor: ctx.Doer,
32-
Type: user_model.UserTypeOrganization,
31+
Actor: ctx.Doer,
32+
Type: user_model.UserTypeOrganization,
33+
IncludeReserved: true, // administrator needs to list all acounts include reserved
3334
ListOptions: db.ListOptions{
3435
PageSize: setting.UI.Admin.OrgPagingNum,
3536
},

routers/web/admin/users.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ func Users(ctx *context.Context) {
7777
IsRestricted: util.OptionalBoolParse(statusFilterMap["is_restricted"]),
7878
IsTwoFactorEnabled: util.OptionalBoolParse(statusFilterMap["is_2fa_enabled"]),
7979
IsProhibitLogin: util.OptionalBoolParse(statusFilterMap["is_prohibit_login"]),
80+
IncludeReserved: true, // administrator needs to list all acounts include reserved, bot, remote ones
8081
ExtraParamStrings: extraParamStrings,
8182
}, tplUsers)
8283
}

templates/admin/org/list.tmpl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737
{{if .Visibility.IsPrivate}}
3838
<span class="text gold">{{svg "octicon-lock"}}</span>
3939
{{end}}
40+
{{if eq .Type 3}}{{/* Reserved organization */}}
41+
<span class="ui mini label">{{$.locale.Tr "admin.users.reserved"}}</span>
42+
{{end}}
4043
</td>
4144
<td>{{.NumTeams}}</td>
4245
<td>{{.NumMembers}}</td>

templates/admin/user/list.tmpl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,13 @@
8484
<td>
8585
<a href="{{$.Link}}/{{.ID}}">{{.Name}}</a>
8686
{{if .IsAdmin}}
87-
<span class="ui basic label">{{$.locale.Tr "admin.users.admin"}}</span>
87+
<span class="ui mini label">{{$.locale.Tr "admin.users.admin"}}</span>
88+
{{else if eq 2 .Type}}{{/* Reserved user */}}
89+
<span class="ui mini label">{{$.locale.Tr "admin.users.reserved"}}</span>
90+
{{else if eq 4 .Type}}{{/* Bot "user" */}}
91+
<span class="ui mini label">{{$.locale.Tr "admin.users.bot"}}</span>
92+
{{else if eq 5 .Type}}{{/* Remote user */}}
93+
<span class="ui mini label">{{$.locale.Tr "admin.users.remote"}}</span>
8894
{{end}}
8995
</td>
9096
<td class="gt-ellipsis gt-max-width-12rem">{{.Email}}</td>

0 commit comments

Comments
 (0)