diff --git a/ui/src/components/Show.tsx b/ui/src/components/Show.tsx index 282addc3..534fa26e 100644 --- a/ui/src/components/Show.tsx +++ b/ui/src/components/Show.tsx @@ -1,6 +1,12 @@ import React from "react"; -const Show = ({ when, children, fallback }: { when: boolean; children: React.ReactNode; fallback?: React.ReactNode }) => { +export type ShowProps = { + when: boolean; + children: React.ReactNode; + fallback?: React.ReactNode; +}; + +const Show = ({ when, children, fallback }: ShowProps) => { return when ? children : fallback; }; diff --git a/ui/src/components/access/AccessEditForm.tsx b/ui/src/components/access/AccessEditForm.tsx index 50522939..e8c5a3b8 100644 --- a/ui/src/components/access/AccessEditForm.tsx +++ b/ui/src/components/access/AccessEditForm.tsx @@ -27,14 +27,14 @@ import AccessEditFormVolcEngineConfig from "./AccessEditFormVolcEngineConfig"; import AccessEditFormWebhookConfig from "./AccessEditFormWebhookConfig"; type AccessEditFormModelType = Partial>; -type AccessEditFormModes = "add" | "edit"; +type AccessEditFormPresets = "add" | "edit"; export type AccessEditFormProps = { className?: string; style?: React.CSSProperties; disabled?: boolean; - mode: AccessEditFormModes; model?: AccessEditFormModelType; + preset: AccessEditFormPresets; onModelChange?: (model: AccessEditFormModelType) => void; }; @@ -44,7 +44,7 @@ export type AccessEditFormInstance = { validateFields: () => Promise; }; -const AccessEditForm = forwardRef(({ className, style, disabled, mode, model, onModelChange }, ref) => { +const AccessEditForm = forwardRef(({ className, style, disabled, model, preset, onModelChange }, ref) => { const { t } = useTranslation(); const formSchema = z.object({ @@ -160,7 +160,7 @@ const AccessEditForm = forwardRef(( rules={[formRule]} tooltip={} > - + diff --git a/ui/src/components/access/AccessEditModal.tsx b/ui/src/components/access/AccessEditModal.tsx index 7e06cfb6..f2d24c9e 100644 --- a/ui/src/components/access/AccessEditModal.tsx +++ b/ui/src/components/access/AccessEditModal.tsx @@ -11,13 +11,13 @@ import AccessEditForm, { type AccessEditFormInstance, type AccessEditFormProps } export type AccessEditModalProps = { data?: AccessEditFormProps["model"]; loading?: boolean; - mode: AccessEditFormProps["mode"]; open?: boolean; + preset: AccessEditFormProps["preset"]; trigger?: React.ReactElement; onOpenChange?: (open: boolean) => void; }; -const AccessEditModal = ({ data, loading, mode, trigger, ...props }: AccessEditModalProps) => { +const AccessEditModal = ({ data, loading, trigger, preset, ...props }: AccessEditModalProps) => { const { t } = useTranslation(); const [notificationApi, NotificationContextHolder] = notification.useNotification(); @@ -57,13 +57,13 @@ const AccessEditModal = ({ data, loading, mode, trigger, ...props }: AccessEditM } try { - if (mode === "add") { + if (preset === "add") { if (data?.id) { throw "Invalid props: `data`"; } await createAccess(formRef.current!.getFieldsValue() as AccessModel); - } else if (mode === "edit") { + } else if (preset === "edit") { if (!data?.id) { throw "Invalid props: `data`"; } @@ -100,14 +100,15 @@ const AccessEditModal = ({ data, loading, mode, trigger, ...props }: AccessEditM confirmLoading={formPending} destroyOnClose loading={loading} - okText={mode === "edit" ? t("common.button.save") : t("common.button.submit")} + okText={preset === "edit" ? t("common.button.save") : t("common.button.submit")} open={open} - title={t(`access.action.${mode}`)} + title={t(`access.action.${preset}`)} + width={480} onOk={handleClickOk} onCancel={handleClickCancel} >
- +
diff --git a/ui/src/components/notification/NotifyChannels.tsx b/ui/src/components/notification/NotifyChannels.tsx index 6e9c8d23..d382e207 100644 --- a/ui/src/components/notification/NotifyChannels.tsx +++ b/ui/src/components/notification/NotifyChannels.tsx @@ -3,6 +3,7 @@ import { useTranslation } from "react-i18next"; import { useDeepCompareMemo } from "@ant-design/pro-components"; import { Button, Collapse, message, notification, Skeleton, Space, Switch, type CollapseProps } from "antd"; +import Show from "@/components/Show"; import NotifyChannelEditForm, { type NotifyChannelEditFormInstance } from "./NotifyChannelEditForm"; import NotifyTestButton from "./NotifyTestButton"; import { notifyChannelsMap } from "@/domain/settings"; @@ -105,11 +106,9 @@ const NotifyChannels = ({ className, classNames, style, styles }: NotifyChannels return (
- {!loadedAtOnce ? ( - - ) : ( + }> - )} +
); }; diff --git a/ui/src/components/notification/NotifyTemplate.tsx b/ui/src/components/notification/NotifyTemplate.tsx index fc1862fd..506743ce 100644 --- a/ui/src/components/notification/NotifyTemplate.tsx +++ b/ui/src/components/notification/NotifyTemplate.tsx @@ -6,6 +6,7 @@ import { createSchemaFieldRule } from "antd-zod"; import { z } from "zod"; import { ClientResponseError } from "pocketbase"; +import Show from "@/components/Show"; import { defaultNotifyTemplate, SETTINGS_NAMES, type NotifyTemplatesSettingsContent } from "@/domain/settings"; import { get as getSettings, save as saveSettings } from "@/repository/settings"; import { getErrMsg } from "@/utils/error"; @@ -88,9 +89,7 @@ const NotifyTemplateForm = ({ className, style }: NotifyTemplateFormProps) => { {MessageContextHolder} {NotificationContextHolder} - {loading ? ( - - ) : ( + }>
{
- )} +
); }; diff --git a/ui/src/components/Version.tsx b/ui/src/components/ui/Version.tsx similarity index 100% rename from ui/src/components/Version.tsx rename to ui/src/components/ui/Version.tsx diff --git a/ui/src/components/workflow/ApplyForm.tsx b/ui/src/components/workflow/ApplyForm.tsx index 33217b98..399ea33a 100644 --- a/ui/src/components/workflow/ApplyForm.tsx +++ b/ui/src/components/workflow/ApplyForm.tsx @@ -161,7 +161,7 @@ const ApplyForm = ({ data }: ApplyFormProps) => {
{t("domain.application.form.access.label")}
diff --git a/ui/src/components/workflow/DeployToAliyunALB.tsx b/ui/src/components/workflow/DeployToAliyunALB.tsx index 8c14e8fe..374722a6 100644 --- a/ui/src/components/workflow/DeployToAliyunALB.tsx +++ b/ui/src/components/workflow/DeployToAliyunALB.tsx @@ -103,7 +103,7 @@ const DeployToAliyunALB = ({ data }: DeployFormProps) => { diff --git a/ui/src/components/workflow/DeployToAliyunCDN.tsx b/ui/src/components/workflow/DeployToAliyunCDN.tsx index 6bb794b3..070d9fb9 100644 --- a/ui/src/components/workflow/DeployToAliyunCDN.tsx +++ b/ui/src/components/workflow/DeployToAliyunCDN.tsx @@ -84,7 +84,7 @@ const DeployToAliyunCDN = ({ data }: DeployFormProps) => { diff --git a/ui/src/components/workflow/DeployToAliyunCLB.tsx b/ui/src/components/workflow/DeployToAliyunCLB.tsx index 83a0eb86..86da6577 100644 --- a/ui/src/components/workflow/DeployToAliyunCLB.tsx +++ b/ui/src/components/workflow/DeployToAliyunCLB.tsx @@ -103,7 +103,7 @@ const DeployToAliyunCLB = ({ data }: DeployFormProps) => { diff --git a/ui/src/components/workflow/DeployToAliyunOss.tsx b/ui/src/components/workflow/DeployToAliyunOss.tsx index f0cc90df..e5737534 100644 --- a/ui/src/components/workflow/DeployToAliyunOss.tsx +++ b/ui/src/components/workflow/DeployToAliyunOss.tsx @@ -93,7 +93,7 @@ const DeployToAliyunOSS = ({ data }: DeployFormProps) => { diff --git a/ui/src/components/workflow/DeployToBaiduCloudCDN.tsx b/ui/src/components/workflow/DeployToBaiduCloudCDN.tsx index ca01bc51..8df22301 100644 --- a/ui/src/components/workflow/DeployToBaiduCloudCDN.tsx +++ b/ui/src/components/workflow/DeployToBaiduCloudCDN.tsx @@ -83,7 +83,7 @@ const DeployToBaiduCloudCDN = ({ data }: DeployFormProps) => { diff --git a/ui/src/components/workflow/DeployToByteplusCDN.tsx b/ui/src/components/workflow/DeployToByteplusCDN.tsx index 99a57db1..f67e4a8a 100644 --- a/ui/src/components/workflow/DeployToByteplusCDN.tsx +++ b/ui/src/components/workflow/DeployToByteplusCDN.tsx @@ -83,7 +83,7 @@ const DeployToByteplusCDN = ({ data }: DeployFormProps) => { diff --git a/ui/src/components/workflow/DeployToDogeCloudCDN.tsx b/ui/src/components/workflow/DeployToDogeCloudCDN.tsx index f01a0dca..2d1ac117 100644 --- a/ui/src/components/workflow/DeployToDogeCloudCDN.tsx +++ b/ui/src/components/workflow/DeployToDogeCloudCDN.tsx @@ -85,7 +85,7 @@ const DeployToDogeCloudCDN = ({ data }: DeployFormProps) => { diff --git a/ui/src/components/workflow/DeployToHuaweiCloudCDN.tsx b/ui/src/components/workflow/DeployToHuaweiCloudCDN.tsx index 0a430422..59c0dce7 100644 --- a/ui/src/components/workflow/DeployToHuaweiCloudCDN.tsx +++ b/ui/src/components/workflow/DeployToHuaweiCloudCDN.tsx @@ -90,7 +90,7 @@ const DeployToHuaweiCloudCDN = ({ data }: DeployFormProps) => { diff --git a/ui/src/components/workflow/DeployToHuaweiCloudELB.tsx b/ui/src/components/workflow/DeployToHuaweiCloudELB.tsx index 30541463..b28caaa5 100644 --- a/ui/src/components/workflow/DeployToHuaweiCloudELB.tsx +++ b/ui/src/components/workflow/DeployToHuaweiCloudELB.tsx @@ -112,7 +112,7 @@ const DeployToHuaweiCloudELB = ({ data }: DeployFormProps) => { diff --git a/ui/src/components/workflow/DeployToKubernetesSecret.tsx b/ui/src/components/workflow/DeployToKubernetesSecret.tsx index 9ee37ff6..85ff20cb 100644 --- a/ui/src/components/workflow/DeployToKubernetesSecret.tsx +++ b/ui/src/components/workflow/DeployToKubernetesSecret.tsx @@ -99,7 +99,7 @@ const DeployToKubernetesSecret = ({ data }: DeployFormProps) => { diff --git a/ui/src/components/workflow/DeployToLocal.tsx b/ui/src/components/workflow/DeployToLocal.tsx index 96827afb..bfaa0aaf 100644 --- a/ui/src/components/workflow/DeployToLocal.tsx +++ b/ui/src/components/workflow/DeployToLocal.tsx @@ -32,11 +32,11 @@ const formSchema = z certPath: z .string() .min(1, t("domain.deployment.form.file_cert_path.placeholder")) - .max(255, t("common.errmsg.string_max", { max: 255 })), + .max(256, t("common.errmsg.string_max", { max: 256 })), keyPath: z .string() .min(0, t("domain.deployment.form.file_key_path.placeholder")) - .max(255, t("common.errmsg.string_max", { max: 255 })) + .max(256, t("common.errmsg.string_max", { max: 256 })) .nullish(), pfxPassword: z.string().nullish(), jksAlias: z.string().nullish(), @@ -209,7 +209,7 @@ Remove-Item -Path "$pfxPath" -Force diff --git a/ui/src/components/workflow/DeployToQiniuCDN.tsx b/ui/src/components/workflow/DeployToQiniuCDN.tsx index ce027aa1..65e7a7c8 100644 --- a/ui/src/components/workflow/DeployToQiniuCDN.tsx +++ b/ui/src/components/workflow/DeployToQiniuCDN.tsx @@ -85,7 +85,7 @@ const DeployToQiniuCDN = ({ data }: DeployFormProps) => { diff --git a/ui/src/components/workflow/DeployToSSH.tsx b/ui/src/components/workflow/DeployToSSH.tsx index 78bafc42..95d1d9f1 100644 --- a/ui/src/components/workflow/DeployToSSH.tsx +++ b/ui/src/components/workflow/DeployToSSH.tsx @@ -31,11 +31,11 @@ const formSchema = z certPath: z .string() .min(1, t("domain.deployment.form.file_cert_path.placeholder")) - .max(255, t("common.errmsg.string_max", { max: 255 })), + .max(256, t("common.errmsg.string_max", { max: 256 })), keyPath: z .string() .min(0, t("domain.deployment.form.file_key_path.placeholder")) - .max(255, t("common.errmsg.string_max", { max: 255 })) + .max(256, t("common.errmsg.string_max", { max: 256 })) .nullish(), pfxPassword: z.string().nullish(), jksAlias: z.string().nullish(), @@ -127,7 +127,7 @@ const DeployToSSH = ({ data }: DeployFormProps) => { diff --git a/ui/src/components/workflow/DeployToTencentCDN.tsx b/ui/src/components/workflow/DeployToTencentCDN.tsx index 7d2f723d..985cd783 100644 --- a/ui/src/components/workflow/DeployToTencentCDN.tsx +++ b/ui/src/components/workflow/DeployToTencentCDN.tsx @@ -83,7 +83,7 @@ const DeployToTencentCDN = ({ data }: DeployFormProps) => { diff --git a/ui/src/components/workflow/DeployToTencentCLB.tsx b/ui/src/components/workflow/DeployToTencentCLB.tsx index 05ad2e35..b01695e3 100644 --- a/ui/src/components/workflow/DeployToTencentCLB.tsx +++ b/ui/src/components/workflow/DeployToTencentCLB.tsx @@ -123,7 +123,7 @@ const DeployToTencentCLB = ({ data }: DeployFormProps) => { diff --git a/ui/src/components/workflow/DeployToTencentCOS.tsx b/ui/src/components/workflow/DeployToTencentCOS.tsx index 7a04c7ac..bcb089ef 100644 --- a/ui/src/components/workflow/DeployToTencentCOS.tsx +++ b/ui/src/components/workflow/DeployToTencentCOS.tsx @@ -89,7 +89,7 @@ const DeployToTencentCOS = ({ data }: DeployFormProps) => { diff --git a/ui/src/components/workflow/DeployToTencentTEO.tsx b/ui/src/components/workflow/DeployToTencentTEO.tsx index 95d27a5c..c0f3bce9 100644 --- a/ui/src/components/workflow/DeployToTencentTEO.tsx +++ b/ui/src/components/workflow/DeployToTencentTEO.tsx @@ -86,7 +86,7 @@ const DeployToTencentTEO = ({ data }: DeployFormProps) => { diff --git a/ui/src/components/workflow/DeployToVolcengineCDN.tsx b/ui/src/components/workflow/DeployToVolcengineCDN.tsx index ccb05267..55ecd5db 100644 --- a/ui/src/components/workflow/DeployToVolcengineCDN.tsx +++ b/ui/src/components/workflow/DeployToVolcengineCDN.tsx @@ -83,7 +83,7 @@ const DeployToVolcengineCDN = ({ data }: DeployFormProps) => { diff --git a/ui/src/components/workflow/DeployToVolcengineLive.tsx b/ui/src/components/workflow/DeployToVolcengineLive.tsx index b06309a7..9b29a6b5 100644 --- a/ui/src/components/workflow/DeployToVolcengineLive.tsx +++ b/ui/src/components/workflow/DeployToVolcengineLive.tsx @@ -83,7 +83,7 @@ const DeployToVolcengineLive = ({ data }: DeployFormProps) => { diff --git a/ui/src/components/workflow/DeployToWebhook.tsx b/ui/src/components/workflow/DeployToWebhook.tsx index cdb59ef2..c9d5c409 100644 --- a/ui/src/components/workflow/DeployToWebhook.tsx +++ b/ui/src/components/workflow/DeployToWebhook.tsx @@ -86,7 +86,7 @@ const DeployToWebhook = ({ data }: DeployFormProps) => { diff --git a/ui/src/components/workflow/WorkflowBaseInfoEditDialog.tsx b/ui/src/components/workflow/WorkflowBaseInfoEditDialog.tsx deleted file mode 100644 index 770f154a..00000000 --- a/ui/src/components/workflow/WorkflowBaseInfoEditDialog.tsx +++ /dev/null @@ -1,125 +0,0 @@ -import { z } from "zod"; -import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogTrigger } from "../ui/dialog"; -import { useWorkflowStore } from "@/stores/workflow"; -import { useZustandShallowSelector } from "@/hooks"; -import { useForm } from "react-hook-form"; -import { zodResolver } from "@hookform/resolvers/zod"; -import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from "../ui/form"; -import { Input } from "../ui/input"; -import { Button } from "../ui/button"; -import { useTranslation } from "react-i18next"; -import { memo, useEffect, useMemo, useState } from "react"; -import { Textarea } from "../ui/textarea"; - -type WorkflowNameEditDialogProps = { - trigger: React.ReactNode; -}; - -const formSchema = z.object({ - name: z.string(), - description: z.string(), -}); - -const WorkflowNameBaseInfoDialog = ({ trigger }: WorkflowNameEditDialogProps) => { - const { setBaseInfo, workflow } = useWorkflowStore(useZustandShallowSelector(["setBaseInfo", "workflow"])); - - const form = useForm>({ - resolver: zodResolver(formSchema), - }); - - const memoWorkflow = useMemo(() => workflow, [workflow]); - - useEffect(() => { - form.reset({ name: workflow.name, description: workflow.description }); - }, [memoWorkflow]); - - const { t } = useTranslation(); - - const [open, setOpen] = useState(false); - - const onSubmit = async (config: z.infer) => { - await setBaseInfo(config.name, config.description); - setOpen(false); - }; - - return ( - <> - { - setOpen(val); - }} - > - {trigger} - - - {t("workflow.baseinfo.title")} - -
-
- { - e.stopPropagation(); - form.handleSubmit(onSubmit)(e); - }} - className="space-y-8 dark:text-stone-200" - > - ( - - {t("workflow.props.name")} - - { - form.setValue("name", e.target.value); - }} - /> - - - - - )} - /> - - ( - - {t("workflow.props.description")} - -