From b01f27f2d3b453b3d1b8b889368d94c995f66264 Mon Sep 17 00:00:00 2001 From: whyour Date: Tue, 31 Jan 2023 23:52:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=9B=B4=E6=96=B0=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E5=90=8E=E5=88=B7=E6=96=B0=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/crontab/index.tsx | 23 ++--------------------- src/pages/env/index.tsx | 16 +--------------- 2 files changed, 3 insertions(+), 36 deletions(-) diff --git a/src/pages/crontab/index.tsx b/src/pages/crontab/index.tsx index 44ddda8f..48059071 100644 --- a/src/pages/crontab/index.tsx +++ b/src/pages/crontab/index.tsx @@ -721,34 +721,15 @@ const Crontab = () => { } }; - const handleCancel = (cron?: any) => { + const handleCancel = () => { setIsModalVisible(false); - if (cron) { - handleCrons(cron); - } + getCrons(); }; const onSearch = (value: string) => { setSearchText(value.trim()); }; - const handleCrons = (cron: any) => { - const index = value.findIndex((x) => x.id === cron.id); - const result = [...value]; - cron.nextRunTime = cron_parser - .parseExpression(cron.schedule) - .next() - .toDate(); - if (index === -1) { - result.unshift(cron); - } else { - result.splice(index, 1, { - ...cron, - }); - } - setValue(result); - }; - const getCronDetail = (cron: any) => { request .get(`${config.apiPrefix}crons/${cron.id}`) diff --git a/src/pages/env/index.tsx b/src/pages/env/index.tsx index 16cc2e5d..5b05b60e 100644 --- a/src/pages/env/index.tsx +++ b/src/pages/env/index.tsx @@ -323,7 +323,7 @@ const Env = () => { const handleCancel = (env?: any[]) => { setIsModalVisible(false); - env && handleEnv(env); + getEnvs(); }; const handleEditNameCancel = (env?: any[]) => { @@ -331,20 +331,6 @@ const Env = () => { getEnvs(); }; - const handleEnv = (env: any) => { - const result = [...value]; - const index = value.findIndex((x) => x.id === env.id); - if (index === -1) { - env = Array.isArray(env) ? env : [env]; - result.push(...env); - } else { - result.splice(index, 1, { - ...env, - }); - } - setValue(result); - }; - const vComponents = useMemo(() => { return VList({ height: tableScrollHeight!,