keycloak-scim/src/clients/authorization/DetailDescription.tsx
Erik Jan de Wit 811131518e
Adds the permissions tab to the Authorization screen under clients (#1835)
* initial work on permissions

* search dropdown permissions

* permissions tab

* added empty state

* added new permssion detail route

* added detail screen

* fixed load

* added decision strategy

* added tests

* fixed class name and identeded the expandable table row
2022-01-12 11:01:54 -05:00

38 lines
982 B
TypeScript

import React from "react";
import { useTranslation } from "react-i18next";
import {
DescriptionListGroup,
DescriptionListTerm,
DescriptionListDescription,
} from "@patternfly/react-core";
type DetailDescriptionProps<T> = {
name: string;
array?: string[] | T[];
convert?: (obj: T) => string;
};
export function DetailDescription<T>({
name,
array,
convert,
}: DetailDescriptionProps<T>) {
const { t } = useTranslation("clients");
return (
<DescriptionListGroup>
<DescriptionListTerm>{t(name)}</DescriptionListTerm>
<DescriptionListDescription>
{array?.map((element) => {
const value =
typeof element === "string" ? element : convert!(element);
return (
<span key={value} className="pf-u-pr-sm">
{value}
</span>
);
})}
{array?.length === 0 && <i>{t("common:none")}</i>}
</DescriptionListDescription>
</DescriptionListGroup>
);
}