Added alphabetically listing the policies (#3556)

This commit is contained in:
agagancarczyk 2022-10-17 14:09:50 +01:00 committed by GitHub
parent 4b2a23b81d
commit c797f1f62f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -17,6 +17,8 @@ import {
import type PolicyProviderRepresentation from "@keycloak/keycloak-admin-client/lib/defs/policyProviderRepresentation";
import { isValidComponentType } from "./policy/PolicyDetails";
import { useMemo } from "react";
import useLocaleSort, { mapByKey } from "../../utils/useLocaleSort";
type NewPolicyDialogProps = {
policyProviders?: PolicyProviderRepresentation[];
@ -30,6 +32,13 @@ export const NewPolicyDialog = ({
toggleDialog,
}: NewPolicyDialogProps) => {
const { t } = useTranslation("clients");
const localeSort = useLocaleSort();
const sortedPolicies = useMemo(
() =>
policyProviders ? localeSort(policyProviders, mapByKey("name")) : [],
[policyProviders]
);
return (
<Modal
@ -52,7 +61,7 @@ export const NewPolicyDialog = ({
</Tr>
</Thead>
<Tbody>
{policyProviders?.map((provider) => (
{sortedPolicies.map((provider) => (
<Tr
key={provider.type}
data-testid={provider.type}