keep imported json instead of only form fields (#988)
This commit is contained in:
parent
dbedd79883
commit
ba8f927453
1 changed files with 4 additions and 1 deletions
|
@ -7,7 +7,7 @@ import {
|
||||||
TextInput,
|
TextInput,
|
||||||
} from "@patternfly/react-core";
|
} from "@patternfly/react-core";
|
||||||
import type ClientRepresentation from "keycloak-admin/lib/defs/clientRepresentation";
|
import type ClientRepresentation from "keycloak-admin/lib/defs/clientRepresentation";
|
||||||
import React from "react";
|
import React, { useState } from "react";
|
||||||
import { FormProvider, useForm } from "react-hook-form";
|
import { FormProvider, useForm } from "react-hook-form";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { Link, useHistory } from "react-router-dom";
|
import { Link, useHistory } from "react-router-dom";
|
||||||
|
@ -30,6 +30,7 @@ export const ImportForm = () => {
|
||||||
const { realm } = useRealm();
|
const { realm } = useRealm();
|
||||||
const form = useForm<ClientRepresentation>();
|
const form = useForm<ClientRepresentation>();
|
||||||
const { register, handleSubmit, setValue } = form;
|
const { register, handleSubmit, setValue } = form;
|
||||||
|
const [imported, setImported] = useState<ClientRepresentation>({});
|
||||||
|
|
||||||
const { addAlert, addError } = useAlerts();
|
const { addAlert, addError } = useAlerts();
|
||||||
|
|
||||||
|
@ -48,11 +49,13 @@ export const ImportForm = () => {
|
||||||
setValue(entries[0], entries[1]);
|
setValue(entries[0], entries[1]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
setImported(obj || defaultClient);
|
||||||
};
|
};
|
||||||
|
|
||||||
const save = async (client: ClientRepresentation) => {
|
const save = async (client: ClientRepresentation) => {
|
||||||
try {
|
try {
|
||||||
const newClient = await adminClient.clients.create({
|
const newClient = await adminClient.clients.create({
|
||||||
|
...imported,
|
||||||
...client,
|
...client,
|
||||||
attributes: convertFormValuesToObject(client.attributes || {}),
|
attributes: convertFormValuesToObject(client.attributes || {}),
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue