diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2023-09-14 14:53:36 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-14 06:53:36 +0000 |
commit | 198a9ca6350954a6d3327a408021fec2bc0fc805 (patch) | |
tree | de73b2232ca2474ce9126f52d26298f8eaef3dfd | |
parent | a457eb94151a718be64d12eff9d9b7eafd6511ad (diff) | |
download | gitea-198a9ca6350954a6d3327a408021fec2bc0fc805.tar.gz gitea-198a9ca6350954a6d3327a408021fec2bc0fc805.zip |
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 <dev.lh@web.de>
-rw-r--r-- | models/user/search.go | 16 | ||||
-rw-r--r-- | options/locale/locale_en-US.ini | 3 | ||||
-rw-r--r-- | routers/web/admin/orgs.go | 5 | ||||
-rw-r--r-- | routers/web/admin/users.go | 1 | ||||
-rw-r--r-- | templates/admin/org/list.tmpl | 3 | ||||
-rw-r--r-- | templates/admin/user/list.tmpl | 8 |
6 files changed, 32 insertions, 4 deletions
diff --git a/models/user/search.go b/models/user/search.go index bf35fcd9eb..446556f89b 100644 --- a/models/user/search.go +++ b/models/user/search.go @@ -34,12 +34,26 @@ type SearchUserOptions struct { IsRestricted util.OptionalBool IsTwoFactorEnabled util.OptionalBool IsProhibitLogin util.OptionalBool + IncludeReserved bool ExtraParamStrings map[string]string } func (opts *SearchUserOptions) toSearchQueryBase() *xorm.Session { - var cond builder.Cond = builder.Eq{"type": opts.Type} + var cond builder.Cond + cond = builder.Eq{"type": opts.Type} + if opts.IncludeReserved { + if opts.Type == UserTypeIndividual { + cond = cond.Or(builder.Eq{"type": UserTypeUserReserved}).Or( + builder.Eq{"type": UserTypeBot}, + ).Or( + builder.Eq{"type": UserTypeRemoteUser}, + ) + } else if opts.Type == UserTypeOrganization { + cond = cond.Or(builder.Eq{"type": UserTypeOrganizationReserved}) + } + } + if len(opts.Keyword) > 0 { lowerKeyword := strings.ToLower(opts.Keyword) keywordCond := builder.Or( diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 39da4be179..ad7d35127e 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -2780,6 +2780,9 @@ users.full_name = Full Name users.activated = Activated users.admin = Admin users.restricted = Restricted +users.reserved = Reserved +users.bot = Bot +users.remote = Remote users.2fa = 2FA users.repos = Repos users.created = Created diff --git a/routers/web/admin/orgs.go b/routers/web/admin/orgs.go index d0fd0d5002..ab44f8048b 100644 --- a/routers/web/admin/orgs.go +++ b/routers/web/admin/orgs.go @@ -28,8 +28,9 @@ func Organizations(ctx *context.Context) { } explore.RenderUserSearch(ctx, &user_model.SearchUserOptions{ - Actor: ctx.Doer, - Type: user_model.UserTypeOrganization, + Actor: ctx.Doer, + Type: user_model.UserTypeOrganization, + IncludeReserved: true, // administrator needs to list all acounts include reserved ListOptions: db.ListOptions{ PageSize: setting.UI.Admin.OrgPagingNum, }, diff --git a/routers/web/admin/users.go b/routers/web/admin/users.go index 47dff6e852..03ffaf5f3f 100644 --- a/routers/web/admin/users.go +++ b/routers/web/admin/users.go @@ -77,6 +77,7 @@ func Users(ctx *context.Context) { IsRestricted: util.OptionalBoolParse(statusFilterMap["is_restricted"]), IsTwoFactorEnabled: util.OptionalBoolParse(statusFilterMap["is_2fa_enabled"]), IsProhibitLogin: util.OptionalBoolParse(statusFilterMap["is_prohibit_login"]), + IncludeReserved: true, // administrator needs to list all acounts include reserved, bot, remote ones ExtraParamStrings: extraParamStrings, }, tplUsers) } diff --git a/templates/admin/org/list.tmpl b/templates/admin/org/list.tmpl index a400dcbc86..ac86e7606a 100644 --- a/templates/admin/org/list.tmpl +++ b/templates/admin/org/list.tmpl @@ -37,6 +37,9 @@ {{if .Visibility.IsPrivate}} <span class="text gold">{{svg "octicon-lock"}}</span> {{end}} + {{if eq .Type 3}}{{/* Reserved organization */}} + <span class="ui mini label">{{$.locale.Tr "admin.users.reserved"}}</span> + {{end}} </td> <td>{{.NumTeams}}</td> <td>{{.NumMembers}}</td> diff --git a/templates/admin/user/list.tmpl b/templates/admin/user/list.tmpl index b3e0caa169..7334828533 100644 --- a/templates/admin/user/list.tmpl +++ b/templates/admin/user/list.tmpl @@ -84,7 +84,13 @@ <td> <a href="{{$.Link}}/{{.ID}}">{{.Name}}</a> {{if .IsAdmin}} - <span class="ui basic label">{{$.locale.Tr "admin.users.admin"}}</span> + <span class="ui mini label">{{$.locale.Tr "admin.users.admin"}}</span> + {{else if eq 2 .Type}}{{/* Reserved user */}} + <span class="ui mini label">{{$.locale.Tr "admin.users.reserved"}}</span> + {{else if eq 4 .Type}}{{/* Bot "user" */}} + <span class="ui mini label">{{$.locale.Tr "admin.users.bot"}}</span> + {{else if eq 5 .Type}}{{/* Remote user */}} + <span class="ui mini label">{{$.locale.Tr "admin.users.remote"}}</span> {{end}} </td> <td class="gt-ellipsis gt-max-width-12rem">{{.Email}}</td> |