Skip to content

Commit

Permalink
web/admin: fix user sorting by active field (#6485)
Browse files Browse the repository at this point in the history
* web/admin: fix user sorting by active field

Signed-off-by: Jens Langhammer <jens@goauthentik.io>

* web/admin: fix hide service account toggle

Signed-off-by: Jens Langhammer <jens@goauthentik.io>

---------

Signed-off-by: Jens Langhammer <jens@goauthentik.io>
  • Loading branch information
BeryJu committed Aug 7, 2023
1 parent 9ec1f8e commit 43d766c
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 18 deletions.
14 changes: 10 additions & 4 deletions authentik/core/api/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@
from django.utils.text import slugify
from django.utils.timezone import now
from django.utils.translation import gettext as _
from django_filters.filters import BooleanFilter, CharFilter, ModelMultipleChoiceFilter, UUIDFilter
from django_filters.filters import (
BooleanFilter,
CharFilter,
ModelMultipleChoiceFilter,
MultipleChoiceFilter,
UUIDFilter,
)
from django_filters.filterset import FilterSet
from drf_spectacular.types import OpenApiTypes
from drf_spectacular.utils import (
Expand Down Expand Up @@ -300,11 +306,11 @@ class UsersFilter(FilterSet):
is_superuser = BooleanFilter(field_name="ak_groups", lookup_expr="is_superuser")
uuid = UUIDFilter(field_name="uuid")

path = CharFilter(
field_name="path",
)
path = CharFilter(field_name="path")
path_startswith = CharFilter(field_name="path", lookup_expr="startswith")

type = MultipleChoiceFilter(field_name="type")

groups_by_name = ModelMultipleChoiceFilter(
field_name="ak_groups__name",
to_field_name="name",
Expand Down
16 changes: 10 additions & 6 deletions schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4620,17 +4620,21 @@ paths:
- in: query
name: type
schema:
type: string
enum:
- external
- internal
- internal_service_account
- service_account
type: array
items:
type: string
enum:
- external
- internal
- internal_service_account
- service_account
description: |-
* `internal` - Internal
* `external` - External
* `service_account` - Service Account
* `internal_service_account` - Internal Service Account
explode: true
style: form
- in: query
name: username
schema:
Expand Down
2 changes: 1 addition & 1 deletion web/src/admin/groups/MemberSelectModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class MemberSelectTable extends TableModal<User> {
columns(): TableColumn[] {
return [
new TableColumn(msg("Name"), "username"),
new TableColumn(msg("Active"), "active"),
new TableColumn(msg("Active"), "is_active"),
new TableColumn(msg("Last login"), "last_login"),
];
}
Expand Down
17 changes: 11 additions & 6 deletions web/src/admin/users/RelatedUserList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,14 @@ import PFAlert from "@patternfly/patternfly/components/Alert/alert.css";
import PFBanner from "@patternfly/patternfly/components/Banner/banner.css";
import PFDescriptionList from "@patternfly/patternfly/components/DescriptionList/description-list.css";

import { CapabilitiesEnum, CoreApi, Group, ResponseError, User } from "@goauthentik/api";
import {
CapabilitiesEnum,
CoreApi,
CoreUsersListTypeEnum,
Group,
ResponseError,
User,
} from "@goauthentik/api";

@customElement("ak-user-related-add")
export class RelatedUserAdd extends Form<{ users: number[] }> {
Expand Down Expand Up @@ -127,18 +134,16 @@ export class RelatedUserList extends Table<User> {
pageSize: (await uiConfig()).pagination.perPage,
search: this.search || "",
groupsByPk: this.targetGroup ? [this.targetGroup.pk] : [],
attributes: this.hideServiceAccounts
? JSON.stringify({
"goauthentik.io/user/service-account__isnull": true,
})
type: this.hideServiceAccounts
? [CoreUsersListTypeEnum.External, CoreUsersListTypeEnum.Internal]
: undefined,
});
}

columns(): TableColumn[] {
return [
new TableColumn(msg("Name"), "username"),
new TableColumn(msg("Active"), "active"),
new TableColumn(msg("Active"), "is_active"),
new TableColumn(msg("Last login"), "last_login"),
new TableColumn(msg("Actions")),
];
Expand Down
2 changes: 1 addition & 1 deletion web/src/admin/users/UserListPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export class UserListPage extends TablePage<User> {
columns(): TableColumn[] {
return [
new TableColumn(msg("Name"), "username"),
new TableColumn(msg("Active"), "active"),
new TableColumn(msg("Active"), "is_active"),
new TableColumn(msg("Last login"), "last_login"),
new TableColumn(msg("Actions")),
];
Expand Down

0 comments on commit 43d766c

Please sign in to comment.