2021-09-20 15:31:05 +00:00
|
|
|
import type { FunctionComponent } from "react";
|
|
|
|
|
|
|
|
import type { ConfigPropertyRepresentation } from "@keycloak/keycloak-admin-client/lib/defs/authenticatorConfigInfoRepresentation";
|
|
|
|
import { StringComponent } from "./StringComponent";
|
|
|
|
import { BooleanComponent } from "./BooleanComponent";
|
|
|
|
import { ListComponent } from "./ListComponent";
|
|
|
|
import { RoleComponent } from "./RoleComponent";
|
2021-12-14 22:46:19 +00:00
|
|
|
import { MapComponent } from "./MapComponent";
|
2021-09-20 15:31:05 +00:00
|
|
|
import { ScriptComponent } from "./ScriptComponent";
|
2021-10-20 14:26:05 +00:00
|
|
|
import { ClientSelectComponent } from "./ClientSelectComponent";
|
2021-11-01 22:18:27 +00:00
|
|
|
import { MultiValuedStringComponent } from "./MultivaluedStringComponent";
|
2021-11-08 09:46:03 +00:00
|
|
|
import { MultiValuedListComponent } from "./MultivaluedListComponent";
|
2021-12-14 22:46:19 +00:00
|
|
|
import { GroupComponent } from "./GroupComponent";
|
2021-09-20 15:31:05 +00:00
|
|
|
|
2022-02-16 14:53:45 +00:00
|
|
|
export type ComponentProps = Omit<ConfigPropertyRepresentation, "type"> & {
|
|
|
|
isDisabled?: boolean;
|
|
|
|
};
|
|
|
|
|
2021-10-20 14:26:05 +00:00
|
|
|
const ComponentTypes = [
|
|
|
|
"String",
|
|
|
|
"boolean",
|
|
|
|
"List",
|
|
|
|
"Role",
|
|
|
|
"Script",
|
2021-12-14 22:46:19 +00:00
|
|
|
"Map",
|
|
|
|
"Group",
|
2021-10-26 20:16:19 +00:00
|
|
|
"MultivaluedList",
|
2021-10-20 14:26:05 +00:00
|
|
|
"ClientList",
|
2021-11-01 22:18:27 +00:00
|
|
|
"MultivaluedString",
|
2021-10-20 14:26:05 +00:00
|
|
|
] as const;
|
2021-09-20 15:31:05 +00:00
|
|
|
|
|
|
|
export type Components = typeof ComponentTypes[number];
|
|
|
|
|
|
|
|
export const COMPONENTS: {
|
|
|
|
[index in Components]: FunctionComponent<ComponentProps>;
|
|
|
|
} = {
|
|
|
|
String: StringComponent,
|
|
|
|
boolean: BooleanComponent,
|
|
|
|
List: ListComponent,
|
|
|
|
Role: RoleComponent,
|
|
|
|
Script: ScriptComponent,
|
2021-12-14 22:46:19 +00:00
|
|
|
Map: MapComponent,
|
|
|
|
Group: GroupComponent,
|
2021-10-20 14:26:05 +00:00
|
|
|
ClientList: ClientSelectComponent,
|
2021-11-08 09:46:03 +00:00
|
|
|
MultivaluedList: MultiValuedListComponent,
|
2021-11-01 22:18:27 +00:00
|
|
|
MultivaluedString: MultiValuedStringComponent,
|
2021-09-20 15:31:05 +00:00
|
|
|
} as const;
|
2021-10-26 20:16:19 +00:00
|
|
|
|
|
|
|
export const isValidComponentType = (value: string): value is Components =>
|
|
|
|
value in COMPONENTS;
|