refactor: clean code

This commit is contained in:
Fu Diwei 2024-10-21 15:07:09 +08:00
parent 68b9171390
commit 908d33f186
6 changed files with 93 additions and 87 deletions

View File

@ -212,8 +212,8 @@ const AccessEditDialog = ({ trigger, op, data, className }: AccessEditProps) =>
</DialogHeader> </DialogHeader>
<ScrollArea className="max-h-[80vh]"> <ScrollArea className="max-h-[80vh]">
<div className="container py-3"> <div className="container py-3">
<div>
<Label>{t("access.authorization.form.type.label")}</Label> <Label>{t("access.authorization.form.type.label")}</Label>
<Select <Select
onValueChange={(val) => { onValueChange={(val) => {
setConfigType(val); setConfigType(val);
@ -237,6 +237,7 @@ const AccessEditDialog = ({ trigger, op, data, className }: AccessEditProps) =>
</SelectGroup> </SelectGroup>
</SelectContent> </SelectContent>
</Select> </Select>
</div>
<div className="mt-8">{form}</div> <div className="mt-8">{form}</div>
</div> </div>

View File

@ -477,7 +477,7 @@ const DeployToSSH = () => {
}, []); }, []);
return ( return (
<> <>
<div className="flex flex-col space-y-2"> <div className="flex flex-col space-y-8">
<div> <div>
<Label>{t("domain.deployment.form.ssh_cert_path.label")}</Label> <Label>{t("domain.deployment.form.ssh_cert_path.label")}</Label>
<Input <Input
@ -641,7 +641,7 @@ const DeployToOSS = () => {
}); });
return ( return (
<div className="flex flex-col space-y-2"> <div className="flex flex-col space-y-8">
<div> <div>
<Label>{t("domain.deployment.form.oss_endpoint.label")}</Label> <Label>{t("domain.deployment.form.oss_endpoint.label")}</Label>
@ -760,7 +760,7 @@ const DeployToCDN = () => {
}); });
return ( return (
<div className="flex flex-col space-y-2"> <div className="flex flex-col space-y-8">
<div> <div>
<Label>{t("domain.deployment.form.domain.label")}</Label> <Label>{t("domain.deployment.form.domain.label")}</Label>
<Input <Input
@ -824,7 +824,7 @@ const DeployToKubernetes = () => {
return ( return (
<> <>
<div className="flex flex-col space-y-2"> <div className="flex flex-col space-y-8">
<div> <div>
<Label>{t("domain.deployment.form.k8s_namespace.label")}</Label> <Label>{t("domain.deployment.form.k8s_namespace.label")}</Label>
<Input <Input
@ -840,6 +840,7 @@ const DeployToKubernetes = () => {
}} }}
/> />
</div> </div>
<div> <div>
<Label>{t("domain.deployment.form.k8s_secret_name.label")}</Label> <Label>{t("domain.deployment.form.k8s_secret_name.label")}</Label>
<Input <Input
@ -855,6 +856,7 @@ const DeployToKubernetes = () => {
}} }}
/> />
</div> </div>
<div> <div>
<Label>{t("domain.deployment.form.k8s_secret_data_key_for_crt.label")}</Label> <Label>{t("domain.deployment.form.k8s_secret_data_key_for_crt.label")}</Label>
<Input <Input
@ -870,6 +872,7 @@ const DeployToKubernetes = () => {
}} }}
/> />
</div> </div>
<div> <div>
<Label>{t("domain.deployment.form.k8s_secret_data_key_for_key.label")}</Label> <Label>{t("domain.deployment.form.k8s_secret_data_key_for_key.label")}</Label>
<Input <Input

View File

@ -88,7 +88,7 @@ const KVList = ({ variables, onValueChange }: KVListProps) => {
<Show <Show
when={!!locVariables?.length} when={!!locVariables?.length}
fallback={ fallback={
<div className="border rounded-md p-3 text-sm mt-2 flex flex-col items-center"> <div className="border rounded-md p-3 text-sm flex flex-col items-center">
<div className="text-muted-foreground">{t("domain.deployment.form.variables.empty")}</div> <div className="text-muted-foreground">{t("domain.deployment.form.variables.empty")}</div>
<KVEdit <KVEdit

View File

@ -6,7 +6,7 @@ import { Edit, Plus, Trash2 } from "lucide-react";
import Show from "@/components/Show"; import Show from "@/components/Show";
import { Button } from "@/components/ui/button"; import { Button } from "@/components/ui/button";
import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle, DialogTrigger } from "@/components/ui/dialog"; import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle, DialogTrigger } from "@/components/ui/dialog";
import { FormControl, FormLabel } from "@/components/ui/form"; import { FormControl, FormItem, FormLabel } from "@/components/ui/form";
import { Input } from "@/components/ui/input"; import { Input } from "@/components/ui/input";
import { cn } from "@/lib/utils"; import { cn } from "@/lib/utils";
@ -63,6 +63,7 @@ const StringList = ({ value, className, onValueChange, valueType = "domain" }: S
return ( return (
<> <>
<div className={cn(className)}> <div className={cn(className)}>
<FormItem>
<FormLabel className="flex justify-between items-center"> <FormLabel className="flex justify-between items-center">
<div>{t(titles[valueType])}</div> <div>{t(titles[valueType])}</div>
@ -88,14 +89,14 @@ const StringList = ({ value, className, onValueChange, valueType = "domain" }: S
<Show <Show
when={list.length > 0} when={list.length > 0}
fallback={ fallback={
<div className="border rounded-md p-3 text-sm mt-2 flex flex-col items-center"> <div className="border rounded-md p-3 text-sm flex flex-col items-center">
<div className="text-muted-foreground">{t("common.text." + valueType + ".empty")}</div> <div className="text-muted-foreground">{t("common.text." + valueType + ".empty")}</div>
<StringEdit value={""} trigger={t("common.add")} onValueChange={addVal} valueType={valueType} /> <StringEdit value={""} trigger={t("common.add")} onValueChange={addVal} valueType={valueType} />
</div> </div>
} }
> >
<div className="border rounded-md p-3 text-sm mt-2 text-gray-700 space-y-2 dark:text-white dark:border-stone-700 dark:bg-stone-950"> <div className="border rounded-md p-3 text-sm text-gray-700 space-y-2 dark:text-white dark:border-stone-700 dark:bg-stone-950">
{list.map((item, index) => ( {list.map((item, index) => (
<div key={index} className="flex justify-between items-center"> <div key={index} className="flex justify-between items-center">
<div>{item}</div> <div>{item}</div>
@ -122,6 +123,7 @@ const StringList = ({ value, className, onValueChange, valueType = "domain" }: S
</div> </div>
</Show> </Show>
</FormControl> </FormControl>
</FormItem>
</div> </div>
</> </>
); );

View File

@ -37,7 +37,7 @@
"domain.application.form.access.placeholder": "Please select DNS provider authorization configuration", "domain.application.form.access.placeholder": "Please select DNS provider authorization configuration",
"domain.application.form.access.list": "Provider Authorization Configurations", "domain.application.form.access.list": "Provider Authorization Configurations",
"domain.application.form.advanced_settings.label": "Advanced Settings", "domain.application.form.advanced_settings.label": "Advanced Settings",
"domain.application.form.key_algorithm.label": "Certificate Key Algorithm", "domain.application.form.key_algorithm.label": "Certificate Key Algorithm (Default: RSA2048)",
"domain.application.form.key_algorithm.placeholder": "Please select certificate key algorithm", "domain.application.form.key_algorithm.placeholder": "Please select certificate key algorithm",
"domain.application.form.timeout.label": "DNS Propagation Timeout (Seconds)", "domain.application.form.timeout.label": "DNS Propagation Timeout (Seconds)",
"domain.application.form.timeoue.placeholder": "Please enter maximum waiting time for DNS propagation", "domain.application.form.timeoue.placeholder": "Please enter maximum waiting time for DNS propagation",

View File

@ -37,7 +37,7 @@
"domain.application.form.access.placeholder": "请选择 DNS 服务商授权配置", "domain.application.form.access.placeholder": "请选择 DNS 服务商授权配置",
"domain.application.form.access.list": "DNS 服务商授权配置列表", "domain.application.form.access.list": "DNS 服务商授权配置列表",
"domain.application.form.advanced_settings.label": "高级设置", "domain.application.form.advanced_settings.label": "高级设置",
"domain.application.form.key_algorithm.label": "数字证书算法", "domain.application.form.key_algorithm.label": "数字证书算法默认RSA2048",
"domain.application.form.key_algorithm.placeholder": "请选择数字证书算法", "domain.application.form.key_algorithm.placeholder": "请选择数字证书算法",
"domain.application.form.timeout.label": "DNS 传播检查超时时间(单位:秒)", "domain.application.form.timeout.label": "DNS 传播检查超时时间(单位:秒)",
"domain.application.form.timeoue.placeholder": "请输入 DNS 传播检查超时时间", "domain.application.form.timeoue.placeholder": "请输入 DNS 传播检查超时时间",