Skip to content

Commit 9ca1349

Browse files
Fix for importing Public Key PEM (#37462)
* fix - wip Signed-off-by: Agnieszka Gancarczyk <[email protected]> * fix - wip Signed-off-by: Agnieszka Gancarczyk <[email protected]> * fix - wip Signed-off-by: Agnieszka Gancarczyk <[email protected]> * improvement Signed-off-by: Agnieszka Gancarczyk <[email protected]> * Improved Signed-off-by: Agnieszka Gancarczyk <[email protected]> --------- Signed-off-by: Agnieszka Gancarczyk <[email protected]>
1 parent 3a759b5 commit 9ca1349

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

js/apps/admin-ui/src/clients/keys/ImportKeyDialog.tsx

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
Text,
1111
TextContent,
1212
} from "@patternfly/react-core";
13+
import { useState } from "react";
1314
import { Controller, FormProvider, useForm, useWatch } from "react-hook-form";
1415
import { useTranslation } from "react-i18next";
1516
import { useServerInfo } from "../../context/server-info/ServerInfoProvider";
@@ -33,6 +34,7 @@ export const ImportKeyDialog = ({
3334
}: ImportKeyDialogProps) => {
3435
const { t } = useTranslation();
3536
const form = useForm<ImportFile>();
37+
const [file, setFile] = useState<string>("");
3638
const { control, handleSubmit } = form;
3739

3840
const baseFormats = useServerInfo().cryptoInfo?.supportedKeystoreTypes ?? [];
@@ -74,9 +76,7 @@ export const ImportKeyDialog = ({
7476
data-testid="cancel"
7577
key="cancel"
7678
variant={ButtonVariant.link}
77-
onClick={() => {
78-
toggleDialog();
79-
}}
79+
onClick={toggleDialog}
8080
>
8181
{t("cancel")}
8282
</Button>,
@@ -101,18 +101,22 @@ export const ImportKeyDialog = ({
101101
<Controller
102102
name="file"
103103
control={control}
104-
defaultValue={{ filename: "" }}
104+
defaultValue={{ value: "", filename: "" }}
105105
render={({ field }) => (
106106
<FileUpload
107107
id="importFile"
108108
value={field.value.value}
109-
filename={field.value.filename}
110-
onTextChange={(value) =>
111-
field.onChange({ ...field.value, value })
112-
}
113-
onFileInputChange={(_, file) =>
114-
field.onChange({ ...field.value, filename: file.name })
115-
}
109+
filename={file}
110+
hideDefaultPreview
111+
type="text"
112+
onDataChange={(_, value) => {
113+
field.onChange({
114+
value,
115+
});
116+
}}
117+
onFileInputChange={(_, file) => {
118+
setFile(file.name);
119+
}}
116120
/>
117121
)}
118122
/>

0 commit comments

Comments
 (0)