fix(ui): couldn't save ssh key

This commit is contained in:
Fu Diwei 2024-12-22 19:35:05 +08:00
parent 01d30bb742
commit 09919cb3cb
2 changed files with 8 additions and 11 deletions

View File

@ -64,13 +64,13 @@ const AccessEditFormKubernetesConfig = ({ form, formName, disabled, loading, mod
return (
<Form form={form} disabled={loading || disabled} initialValues={initialValues} layout="vertical" name={formName} onValuesChange={handleFormChange}>
<Form.Item name="kubeConfig" noStyle rules={[formRule]}>
<Input.TextArea autoComplete="new-password" hidden placeholder={t("access.form.k8s_kubeconfig.placeholder")} value={form.getFieldValue("kubeConfig")} />
</Form.Item>
<Form.Item
name="kubeConfig"
label={t("access.form.k8s_kubeconfig.label")}
rules={[formRule]}
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.k8s_kubeconfig.tooltip") }}></span>}
>
<Input.TextArea hidden placeholder={t("access.form.k8s_kubeconfig.placeholder")} value={form.getFieldValue("kubeConfig")} />
<Upload beforeUpload={() => false} fileList={kubeFileList} maxCount={1} onChange={handleUploadChange}>
<Button icon={<UploadIcon size={16} />}>{t("access.form.k8s_kubeconfig.upload")}</Button>
</Upload>

View File

@ -87,10 +87,10 @@ const AccessEditFormSSHConfig = ({ form, formName, disabled, loading, model, onM
const handleUploadChange: UploadProps["onChange"] = async ({ file }) => {
if (file && file.status !== "removed") {
form.setFieldValue("kubeConfig", (await readFileContent(file.originFileObj ?? (file as unknown as File))).trim());
form.setFieldValue("key", (await readFileContent(file.originFileObj ?? (file as unknown as File))).trim());
setKeyFileList([file]);
} else {
form.setFieldValue("kubeConfig", "");
form.setFieldValue("key", "");
setKeyFileList([]);
}
@ -134,13 +134,10 @@ const AccessEditFormSSHConfig = ({ form, formName, disabled, loading, model, onM
<div className="flex space-x-2">
<div className="w-1/2">
<Form.Item
name="key"
label={t("access.form.ssh_key.label")}
rules={[formRule]}
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.ssh_key.tooltip") }}></span>}
>
<Form.Item name="key" noStyle rules={[formRule]}>
<Input.TextArea autoComplete="new-password" hidden placeholder={t("access.form.ssh_key.placeholder")} value={form.getFieldValue("key")} />
</Form.Item>
<Form.Item label={t("access.form.ssh_key.label")} tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.ssh_key.tooltip") }}></span>}>
<Upload beforeUpload={() => false} fileList={keyFileList} maxCount={1} onChange={handleUploadChange}>
<Button icon={<UploadIcon size={16} />}>{t("access.form.ssh_key.upload")}</Button>
</Upload>