2021-11-08 09:46:03 +00:00
|
|
|
import React from "react";
|
|
|
|
import type { ConfigPropertyRepresentation } from "@keycloak/keycloak-admin-client/lib/defs/authenticatorConfigInfoRepresentation";
|
|
|
|
|
|
|
|
import { COMPONENTS, isValidComponentType } from "./components";
|
|
|
|
|
|
|
|
type DynamicComponentProps = {
|
|
|
|
properties: ConfigPropertyRepresentation[];
|
2021-11-09 18:27:25 +00:00
|
|
|
selectedValues?: string[];
|
|
|
|
parentCallback?: (data: string[]) => void;
|
2021-11-08 09:46:03 +00:00
|
|
|
};
|
|
|
|
|
2021-11-22 12:41:43 +00:00
|
|
|
export const DynamicComponents = ({ properties }: DynamicComponentProps) => (
|
2021-11-08 09:46:03 +00:00
|
|
|
<>
|
|
|
|
{properties.map((property) => {
|
|
|
|
const componentType = property.type!;
|
2021-11-24 16:19:28 +00:00
|
|
|
if (isValidComponentType(componentType) && property.name !== "scopes") {
|
2021-11-08 09:46:03 +00:00
|
|
|
const Component = COMPONENTS[componentType];
|
2021-11-22 12:41:43 +00:00
|
|
|
return <Component key={property.name} {...property} />;
|
2021-11-08 09:46:03 +00:00
|
|
|
} else {
|
|
|
|
console.warn(`There is no editor registered for ${componentType}`);
|
|
|
|
}
|
|
|
|
})}
|
|
|
|
</>
|
|
|
|
);
|