From 287cf6f0c79b9e74ade89a0b5e6dea0d49db1dbd Mon Sep 17 00:00:00 2001 From: Jens L Date: Sat, 5 Aug 2023 22:07:17 +0200 Subject: [PATCH] web/admin: fix user sorting by active field (#6485) * web/admin: fix user sorting by active field Signed-off-by: Jens Langhammer * web/admin: fix hide service account toggle Signed-off-by: Jens Langhammer --------- Signed-off-by: Jens Langhammer --- authentik/core/api/users.py | 14 ++++++++++---- schema.yml | 16 ++++++++++------ web/src/admin/groups/MemberSelectModal.ts | 2 +- web/src/admin/users/RelatedUserList.ts | 17 +++++++++++------ web/src/admin/users/UserListPage.ts | 2 +- 5 files changed, 33 insertions(+), 18 deletions(-) diff --git a/authentik/core/api/users.py b/authentik/core/api/users.py index c0046412e..5ddfcd2ef 100644 --- a/authentik/core/api/users.py +++ b/authentik/core/api/users.py @@ -15,7 +15,13 @@ from django.utils.http import urlencode 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 ( @@ -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", diff --git a/schema.yml b/schema.yml index ed4172c04..f6320501b 100644 --- a/schema.yml +++ b/schema.yml @@ -4587,17 +4587,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: diff --git a/web/src/admin/groups/MemberSelectModal.ts b/web/src/admin/groups/MemberSelectModal.ts index b45bb1510..1d5a53cc7 100644 --- a/web/src/admin/groups/MemberSelectModal.ts +++ b/web/src/admin/groups/MemberSelectModal.ts @@ -39,7 +39,7 @@ export class MemberSelectTable extends TableModal { 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"), ]; } diff --git a/web/src/admin/users/RelatedUserList.ts b/web/src/admin/users/RelatedUserList.ts index 7ebe77fad..7bd907bde 100644 --- a/web/src/admin/users/RelatedUserList.ts +++ b/web/src/admin/users/RelatedUserList.ts @@ -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[] }> { @@ -127,10 +134,8 @@ export class RelatedUserList extends Table { 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, }); } @@ -138,7 +143,7 @@ export class RelatedUserList extends Table { 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")), ]; diff --git a/web/src/admin/users/UserListPage.ts b/web/src/admin/users/UserListPage.ts index dc672be28..e135fff90 100644 --- a/web/src/admin/users/UserListPage.ts +++ b/web/src/admin/users/UserListPage.ts @@ -94,7 +94,7 @@ export class UserListPage extends TablePage { 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")), ];