Convert config strings into string[] (#3365)
This commit is contained in:
parent
2c1f62fea8
commit
22c653aa20
2 changed files with 14 additions and 4 deletions
|
@ -5,6 +5,7 @@ import { FormGroup } from "@patternfly/react-core";
|
||||||
import type { ComponentProps } from "./components";
|
import type { ComponentProps } from "./components";
|
||||||
import { HelpItem } from "../help-enabler/HelpItem";
|
import { HelpItem } from "../help-enabler/HelpItem";
|
||||||
import { PasswordInput } from "../password-input/PasswordInput";
|
import { PasswordInput } from "../password-input/PasswordInput";
|
||||||
|
import { convertToName } from "./DynamicComponents";
|
||||||
|
|
||||||
export const PasswordComponent = ({
|
export const PasswordComponent = ({
|
||||||
name,
|
name,
|
||||||
|
@ -29,7 +30,7 @@ export const PasswordComponent = ({
|
||||||
data-testid={name}
|
data-testid={name}
|
||||||
isDisabled={isDisabled}
|
isDisabled={isDisabled}
|
||||||
ref={register()}
|
ref={register()}
|
||||||
name={`config.${name}`}
|
name={convertToName(name!)}
|
||||||
defaultValue={defaultValue?.toString()}
|
defaultValue={defaultValue?.toString()}
|
||||||
/>
|
/>
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
|
|
|
@ -24,6 +24,7 @@ import { SettingsCache } from "../shared/SettingsCache";
|
||||||
import { ExtendedHeader } from "../shared/ExtendedHeader";
|
import { ExtendedHeader } from "../shared/ExtendedHeader";
|
||||||
import { useServerInfo } from "../../context/server-info/ServerInfoProvider";
|
import { useServerInfo } from "../../context/server-info/ServerInfoProvider";
|
||||||
import { DynamicComponents } from "../../components/dynamic/DynamicComponents";
|
import { DynamicComponents } from "../../components/dynamic/DynamicComponents";
|
||||||
|
import { convertFormValuesToObject, convertToFormValues } from "../../util";
|
||||||
|
|
||||||
import "./custom-provider-settings.css";
|
import "./custom-provider-settings.css";
|
||||||
|
|
||||||
|
@ -38,6 +39,7 @@ export default function CustomProviderSettings() {
|
||||||
register,
|
register,
|
||||||
errors,
|
errors,
|
||||||
reset,
|
reset,
|
||||||
|
setValue,
|
||||||
handleSubmit,
|
handleSubmit,
|
||||||
formState: { isDirty },
|
formState: { isDirty },
|
||||||
} = form;
|
} = form;
|
||||||
|
@ -62,7 +64,7 @@ export default function CustomProviderSettings() {
|
||||||
},
|
},
|
||||||
(fetchedComponent) => {
|
(fetchedComponent) => {
|
||||||
if (fetchedComponent) {
|
if (fetchedComponent) {
|
||||||
reset({ ...fetchedComponent });
|
convertToFormValues(fetchedComponent, setValue);
|
||||||
} else if (id) {
|
} else if (id) {
|
||||||
throw new Error(t("common:notFound"));
|
throw new Error(t("common:notFound"));
|
||||||
}
|
}
|
||||||
|
@ -80,12 +82,19 @@ export default function CustomProviderSettings() {
|
||||||
);
|
);
|
||||||
|
|
||||||
const save = async (component: ComponentRepresentation) => {
|
const save = async (component: ComponentRepresentation) => {
|
||||||
const saveComponent = {
|
const saveComponent = convertFormValuesToObject({
|
||||||
...component,
|
...component,
|
||||||
|
config: Object.fromEntries(
|
||||||
|
Object.entries(component.config || {}).map(([key, value]) => [
|
||||||
|
key,
|
||||||
|
Array.isArray(value) ? value : [value],
|
||||||
|
])
|
||||||
|
),
|
||||||
providerId,
|
providerId,
|
||||||
providerType: "org.keycloak.storage.UserStorageProvider",
|
providerType: "org.keycloak.storage.UserStorageProvider",
|
||||||
parentId,
|
parentId,
|
||||||
};
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!id) {
|
if (!id) {
|
||||||
await adminClient.components.create(saveComponent);
|
await adminClient.components.create(saveComponent);
|
||||||
|
|
Loading…
Reference in a new issue