Skip to content

Display all user types and org types on admin management UI #27050

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

Merged
merged 6 commits into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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
16 changes: 15 additions & 1 deletion models/user/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
3 changes: 3 additions & 0 deletions options/locale/locale_en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions routers/web/admin/orgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down
1 change: 1 addition & 0 deletions routers/web/admin/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
3 changes: 3 additions & 0 deletions templates/admin/org/list.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
{{if .Visibility.IsPrivate}}
<span class="text gold">{{svg "octicon-lock"}}</span>
{{end}}
{{if eq .Type 3}}
<span class="ui mini label">{{$.locale.Tr "admin.users.reserved"}}</span>
{{end}}
</td>
<td>{{.NumTeams}}</td>
<td>{{.NumMembers}}</td>
Expand Down
8 changes: 7 additions & 1 deletion templates/admin/user/list.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
<span class="ui mini label">{{$.locale.Tr "admin.users.reserved"}}</span>
{{else if eq 4 .Type}}
<span class="ui mini label">{{$.locale.Tr "admin.users.bot"}}</span>
{{else if eq 5 .Type}}
<span class="ui mini label">{{$.locale.Tr "admin.users.remote"}}</span>
{{end}}
</td>
<td class="gt-ellipsis gt-max-width-12rem">{{.Email}}</td>
Expand Down