mirror of
https://github.com/woodchen-ink/certimate.git
synced 2025-07-18 17:31:55 +08:00
refactor: clean code
This commit is contained in:
parent
350160833b
commit
6f1a375fee
@ -1,7 +1,6 @@
|
||||
import { useState } from "react";
|
||||
import { useEffect, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { UploadOutlined as UploadOutlinedIcon } from "@ant-design/icons";
|
||||
import { useDeepCompareEffect } from "ahooks";
|
||||
import { Button, Form, type FormInstance, Input, Upload, type UploadFile, type UploadProps } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
@ -37,9 +36,9 @@ const AccessEditFormKubernetesConfig = ({ form, formName, disabled, initialValue
|
||||
|
||||
const fieldKubeConfig = Form.useWatch("kubeConfig", form);
|
||||
const [fieldKubeFileList, setFieldKubeFileList] = useState<UploadFile[]>([]);
|
||||
useDeepCompareEffect(() => {
|
||||
useEffect(() => {
|
||||
setFieldKubeFileList(initialValues?.kubeConfig?.trim() ? [{ uid: "-1", name: "kubeconfig", status: "done" }] : []);
|
||||
}, [initialValues]);
|
||||
}, [initialValues?.kubeConfig]);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values as AccessEditFormKubernetesConfigFieldValues);
|
||||
|
@ -1,7 +1,6 @@
|
||||
import { useState } from "react";
|
||||
import { useEffect, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { UploadOutlined as UploadOutlinedIcon } from "@ant-design/icons";
|
||||
import { useDeepCompareEffect } from "ahooks";
|
||||
import { Button, Form, type FormInstance, Input, InputNumber, Upload, type UploadFile, type UploadProps } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
@ -62,9 +61,9 @@ const AccessEditFormSSHConfig = ({ form, formName, disabled, initialValues, onVa
|
||||
|
||||
const fieldKey = Form.useWatch("key", form);
|
||||
const [fieldKeyFileList, setFieldKeyFileList] = useState<UploadFile[]>([]);
|
||||
useDeepCompareEffect(() => {
|
||||
useEffect(() => {
|
||||
setFieldKeyFileList(initialValues?.key?.trim() ? [{ uid: "-1", name: "sshkey", status: "done" }] : []);
|
||||
}, [initialValues]);
|
||||
}, [initialValues?.key]);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values as AccessEditFormSSHConfigFieldValues);
|
||||
|
@ -1,7 +1,6 @@
|
||||
import { createContext, useContext, useEffect, useMemo, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { CheckCard } from "@ant-design/pro-components";
|
||||
import { useDeepCompareEffect } from "ahooks";
|
||||
import { Button, Form, Input, Skeleton, message, notification } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { produce } from "immer";
|
||||
@ -43,9 +42,9 @@ const SSLProviderEditFormLetsEncryptConfig = () => {
|
||||
});
|
||||
|
||||
const [formChanged, setFormChanged] = useState(false);
|
||||
useDeepCompareEffect(() => {
|
||||
useEffect(() => {
|
||||
setFormChanged(settings?.content?.provider !== SSLPROVIDERS.LETS_ENCRYPT);
|
||||
}, [settings]);
|
||||
}, [settings?.content?.provider]);
|
||||
|
||||
const handleFormChange = () => {
|
||||
setFormChanged(true);
|
||||
@ -95,9 +94,9 @@ const SSLProviderEditFormZeroSSLConfig = () => {
|
||||
});
|
||||
|
||||
const [formChanged, setFormChanged] = useState(false);
|
||||
useDeepCompareEffect(() => {
|
||||
useEffect(() => {
|
||||
setFormChanged(settings?.content?.provider !== SSLPROVIDERS.ZERO_SSL);
|
||||
}, [settings]);
|
||||
}, [settings?.content?.provider]);
|
||||
|
||||
const handleFormChange = () => {
|
||||
setFormChanged(true);
|
||||
@ -165,9 +164,9 @@ const SSLProviderEditFormGoogleTrustServicesConfig = () => {
|
||||
});
|
||||
|
||||
const [formChanged, setFormChanged] = useState(false);
|
||||
useDeepCompareEffect(() => {
|
||||
useEffect(() => {
|
||||
setFormChanged(settings?.content?.provider !== SSLPROVIDERS.GOOGLE_TRUST_SERVICES);
|
||||
}, [settings]);
|
||||
}, [settings?.content?.provider]);
|
||||
|
||||
const handleFormChange = () => {
|
||||
setFormChanged(true);
|
||||
|
@ -11,7 +11,6 @@ import {
|
||||
UndoOutlined as UndoOutlinedIcon,
|
||||
} from "@ant-design/icons";
|
||||
import { PageHeader } from "@ant-design/pro-components";
|
||||
import { useDeepCompareEffect } from "ahooks";
|
||||
import { Alert, Button, Card, Dropdown, Form, Input, Modal, Space, Tabs, Typography, message, notification } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { ClientResponseError } from "pocketbase";
|
||||
@ -58,7 +57,7 @@ const WorkflowDetail = () => {
|
||||
const [allowDiscard, setAllowDiscard] = useState(false);
|
||||
const [allowRelease, setAllowRelease] = useState(false);
|
||||
const [allowRun, setAllowRun] = useState(false);
|
||||
useDeepCompareEffect(() => {
|
||||
useEffect(() => {
|
||||
const hasReleased = !!workflow.content;
|
||||
const hasChanges = workflow.hasDraft! || !isEqual(workflow.draft, workflow.content);
|
||||
setAllowDiscard(!isRunning && hasReleased && hasChanges);
|
||||
|
Loading…
x
Reference in New Issue
Block a user