From bf09d72a8b24b4fee87b92db5184423a22d5da9c Mon Sep 17 00:00:00 2001
From: xinbinyan <404928130@qq.com>
Date: Mon, 22 Jan 2024 15:46:26 +0800
Subject: [PATCH 01/27] upgrade system title
---
.../src/page/System/GlobalSetting/index.tsx | 152 +++++++++---------
.../base/src/page/System/License/index.tsx | 58 ++++---
.../src/page/System/LoginConnection/index.tsx | 14 +-
.../page/System/PersonalizeSetting/index.tsx | 8 +-
.../page/System/ProcessConnection/index.tsx | 14 +-
.../page/System/PushNotification/index.tsx | 19 ++-
.../System/components/BasicTitle/index.tsx | 38 +++++
packages/base/src/page/System/index.tsx | 4 +-
8 files changed, 171 insertions(+), 136 deletions(-)
create mode 100644 packages/base/src/page/System/components/BasicTitle/index.tsx
diff --git a/packages/base/src/page/System/GlobalSetting/index.tsx b/packages/base/src/page/System/GlobalSetting/index.tsx
index 19c182a8a..5066f5a68 100644
--- a/packages/base/src/page/System/GlobalSetting/index.tsx
+++ b/packages/base/src/page/System/GlobalSetting/index.tsx
@@ -14,6 +14,7 @@ import { IUpdateSystemVariablesReqV1 } from '@actiontech/shared/lib/api/sqle/ser
import { integerValidate } from '@actiontech/shared/lib/utils/Common';
import useHideConfigInputNode from '../../../../../shared/lib/components/ConfigItem/hooks/useHideConfigInputNode';
import { ConfigFieldMapMeta } from '@actiontech/shared/lib/components/ConfigItem/index.type';
+import SystemBasicTitle from '../components/BasicTitle';
const GlobalSetting = () => {
const { t } = useTranslation();
@@ -121,80 +122,83 @@ const GlobalSetting = () => {
};
return (
-
-
- {t('dmsSystem.tabPaneTitle.globalConfiguration')}
-
-
- {messageContextHolder}
- {`${t('dmsSystem.global.orderExpiredHours')}(${t(
- 'common.time.hour'
- )})`}
- }
- descNode={String(globalConfig?.workflow_expired_hours ?? '-')}
- fieldVisible={orderExpiredHoursFieldVisible}
- showField={showOrderExpiredHoursField}
- hideField={hideOrderExpiredHoursField}
- inputNode={
- integerValidator(String(value))}
- hideField={hideOrderExpiredHoursField}
- onSubmit={(value: number) => {
- submitGlobalConfig(value, 'workflow_expired_hours');
- }}
- />
- }
- />
- {`${t(
- 'dmsSystem.global.operationRecordExpiredHours'
- )}(${t('common.time.hour')})`}
- }
- descNode={String(globalConfig?.operation_record_expired_hours ?? '-')}
- fieldVisible={operationRecordExpiredHoursField}
- showField={showOperationRecordExpiredHoursField}
- hideField={hideOperationRecordExpiredHoursField}
- inputNode={
- integerValidator(String(value))}
- hideField={hideOperationRecordExpiredHoursField}
- onSubmit={(value: number) => {
- submitGlobalConfig(value, 'operation_record_expired_hours');
- }}
- />
- }
- />
-
- {t('dmsSystem.global.urlAddressPrefix')}
-
- }
- descNode={!!globalConfig?.url ? globalConfig.url : '-'}
- fieldVisible={urlFieldVisible}
- showField={showUrlField}
- hideField={hideUrlField}
- inputNode={
- {
- submitGlobalConfig(value, 'url');
- }}
- />
- }
- />
-
-
+
+ <>
+
+ {messageContextHolder}
+ {`${t('dmsSystem.global.orderExpiredHours')}(${t(
+ 'common.time.hour'
+ )})`}
+ }
+ descNode={String(globalConfig?.workflow_expired_hours ?? '-')}
+ fieldVisible={orderExpiredHoursFieldVisible}
+ showField={showOrderExpiredHoursField}
+ hideField={hideOrderExpiredHoursField}
+ inputNode={
+ integerValidator(String(value))}
+ hideField={hideOrderExpiredHoursField}
+ onSubmit={(value: number) => {
+ submitGlobalConfig(value, 'workflow_expired_hours');
+ }}
+ />
+ }
+ />
+ {`${t(
+ 'dmsSystem.global.operationRecordExpiredHours'
+ )}(${t('common.time.hour')})`}
+ }
+ descNode={String(
+ globalConfig?.operation_record_expired_hours ?? '-'
+ )}
+ fieldVisible={operationRecordExpiredHoursField}
+ showField={showOperationRecordExpiredHoursField}
+ hideField={hideOperationRecordExpiredHoursField}
+ inputNode={
+ integerValidator(String(value))}
+ hideField={hideOperationRecordExpiredHoursField}
+ onSubmit={(value: number) => {
+ submitGlobalConfig(value, 'operation_record_expired_hours');
+ }}
+ />
+ }
+ />
+
+ {t('dmsSystem.global.urlAddressPrefix')}
+
+ }
+ descNode={!!globalConfig?.url ? globalConfig.url : '-'}
+ fieldVisible={urlFieldVisible}
+ showField={showUrlField}
+ hideField={hideUrlField}
+ inputNode={
+ {
+ submitGlobalConfig(value, 'url');
+ }}
+ />
+ }
+ />
+
+ >
+
);
};
diff --git a/packages/base/src/page/System/License/index.tsx b/packages/base/src/page/System/License/index.tsx
index 0fc3450ac..da5515a01 100644
--- a/packages/base/src/page/System/License/index.tsx
+++ b/packages/base/src/page/System/License/index.tsx
@@ -1,19 +1,20 @@
import { useBoolean, useRequest } from 'ahooks';
-import { Space } from 'antd';
import { useEffect } from 'react';
import { useTranslation } from 'react-i18next';
import { useDispatch } from 'react-redux';
-import EmitterKey from '../../../data/EmitterKey';
+
import { updateSystemModalStatus } from '../../../store/system';
+import dms from '@actiontech/shared/lib/api/base/service/dms';
import EventEmitter from '../../../utils/EventEmitter';
-import { Row } from 'antd';
-import { BasicButton, BasicToolTips } from '@actiontech/shared';
-import { LicenseColumn } from './index.data';
-import { IconTipGray } from '@actiontech/shared/lib/Icon';
-import { ActiontechTable } from '@actiontech/shared/lib/components/ActiontechTable';
+import EmitterKey from '../../../data/EmitterKey';
+
+import { Space } from 'antd';
+import { BasicButton } from '@actiontech/shared';
import { ModalName } from '../../../data/ModalName';
+import SystemBasicTitle from '../components/BasicTitle';
import ImportLicense from './Modal/ImportLicense';
-import dms from '@actiontech/shared/lib/api/base/service/dms';
+import { LicenseColumn } from './index.data';
+import { ActiontechTable } from '@actiontech/shared/lib/components/ActiontechTable';
const License = () => {
const { t } = useTranslation();
@@ -54,19 +55,11 @@ const License = () => {
}, [refreshLicenseList]);
return (
-
-
-
- {t('dmsSystem.tabPaneTitle.license')}
- {/* todo: 此处提示语待产品给出后调整 */}
-
-
-
-
+
{
{t('dmsSystem.license.import')}
-
-
-
-
+ }
+ >
+ <>
+
+
+ >
+
);
};
diff --git a/packages/base/src/page/System/LoginConnection/index.tsx b/packages/base/src/page/System/LoginConnection/index.tsx
index 249c252bc..c3ac94b2d 100644
--- a/packages/base/src/page/System/LoginConnection/index.tsx
+++ b/packages/base/src/page/System/LoginConnection/index.tsx
@@ -1,18 +1,18 @@
import { useTranslation } from 'react-i18next';
import LDAPSetting from './LDAPSetting';
import Oauth from './Oauth';
+import SystemBasicTitle from '../components/BasicTitle';
const LoginConnection = () => {
const { t } = useTranslation();
return (
-
-
- {t('dmsSystem.tabPaneTitle.loginConnection')}
-
-
-
-
+
+ <>
+
+
+ >
+
);
};
diff --git a/packages/base/src/page/System/PersonalizeSetting/index.tsx b/packages/base/src/page/System/PersonalizeSetting/index.tsx
index cc6fd8379..0e23c6197 100644
--- a/packages/base/src/page/System/PersonalizeSetting/index.tsx
+++ b/packages/base/src/page/System/PersonalizeSetting/index.tsx
@@ -18,6 +18,7 @@ import { useMemo } from 'react';
import { ConfigFieldMapMeta } from '@actiontech/shared/lib/components/ConfigItem/index.type';
import useHideConfigInputNode from '@actiontech/shared/lib/components/ConfigItem/hooks/useHideConfigInputNode';
import useSystemConfig from '../../../hooks/useSystemConfig';
+import SystemBasicTitle from '../components/BasicTitle';
const PersonalizeSetting: React.FC = () => {
const { t } = useTranslation();
@@ -87,10 +88,7 @@ const PersonalizeSetting: React.FC = () => {
};
return (
-
-
- {t('dmsSystem.tabPaneTitle.personalize')}
-
+
{
}
/>
-
+
);
};
diff --git a/packages/base/src/page/System/ProcessConnection/index.tsx b/packages/base/src/page/System/ProcessConnection/index.tsx
index e9880e612..2b3522ab2 100644
--- a/packages/base/src/page/System/ProcessConnection/index.tsx
+++ b/packages/base/src/page/System/ProcessConnection/index.tsx
@@ -1,18 +1,18 @@
import { useTranslation } from 'react-i18next';
import DingTalkSetting from './DingTalkSetting';
import LarkAuditSetting from './LarkAuditSetting';
+import SystemBasicTitle from '../components/BasicTitle';
const ProcessConnection = () => {
const { t } = useTranslation();
return (
-
-
- {t('dmsSystem.tabPaneTitle.processConnection')}
-
-
-
-
+
+ <>
+
+
+ >
+
);
};
diff --git a/packages/base/src/page/System/PushNotification/index.tsx b/packages/base/src/page/System/PushNotification/index.tsx
index 487b5cf5d..4858aaeb2 100644
--- a/packages/base/src/page/System/PushNotification/index.tsx
+++ b/packages/base/src/page/System/PushNotification/index.tsx
@@ -3,21 +3,20 @@ import SMTPSetting from './SMTPSetting';
import Wechat from './Wechat';
import LarkSetting from './LarkSetting';
import WebHook from './WebhookSetting';
+import SystemBasicTitle from '../components/BasicTitle';
const PushNotification = () => {
const { t } = useTranslation();
return (
-
-
- {t('dmsSystem.tabPaneTitle.pushNotification')}
-
-
-
-
-
-
-
+
+ <>
+
+
+
+
+ >
+
);
};
diff --git a/packages/base/src/page/System/components/BasicTitle/index.tsx b/packages/base/src/page/System/components/BasicTitle/index.tsx
new file mode 100644
index 000000000..73ae01a90
--- /dev/null
+++ b/packages/base/src/page/System/components/BasicTitle/index.tsx
@@ -0,0 +1,38 @@
+import { ReactNode } from 'react';
+import { Space, Row } from 'antd';
+import { BasicToolTips } from '@actiontech/shared';
+import { IconTipGray } from '@actiontech/shared/lib/Icon';
+
+export type SystemBasicTitleProps = {
+ title: ReactNode | string;
+ titleTip?: ReactNode | string;
+ titleExtra?: ReactNode | string;
+ children: ReactNode | string;
+};
+
+const SystemBasicTitle = (props: SystemBasicTitleProps) => {
+ const { title, children, titleTip, titleExtra } = props;
+
+ return (
+
+
+
+ {title}
+ {titleTip && (
+
+
+
+ )}
+
+ {titleExtra}
+
+ {children}
+
+ );
+};
+
+export default SystemBasicTitle;
diff --git a/packages/base/src/page/System/index.tsx b/packages/base/src/page/System/index.tsx
index e54790fad..911ecd88c 100644
--- a/packages/base/src/page/System/index.tsx
+++ b/packages/base/src/page/System/index.tsx
@@ -4,8 +4,8 @@ import { useTranslation } from 'react-i18next';
import { Row } from 'antd';
import { BasicSegmented, PageHeader } from '@actiontech/shared';
import { ModalName } from '../../data/ModalName';
-import { initSystemModalStatus } from '../../store/system';
import { SystemStyleWrapper } from './style';
+import { initSystemModalStatus } from '../../store/system';
// #if [sqle]
import PushNotification from './PushNotification';
@@ -86,7 +86,7 @@ const System = () => {
return options.find((item) => item.value === activeTabKey)?.components;
}, [activeTabKey, options]);
- // #if [sqle]
+ // #if [ee]
useEffect(() => {
dispatch(
initSystemModalStatus({
From 34ed5f6b0a80c510680d58887ee8165b8d72a064 Mon Sep 17 00:00:00 2001
From: xinbinyan <404928130@qq.com>
Date: Mon, 22 Jan 2024 18:25:16 +0800
Subject: [PATCH 02/27] upgrade tab pushNotification
---
.../conponents/ConfigExtraButtons.tsx | 197 +++++++++
.../LarkSetting/conponents/ConfigField.tsx | 39 ++
.../LarkSetting/index copy.tsx | 395 +++++++++++++++++
.../PushNotification/LarkSetting/index.tsx | 255 +----------
.../components/ConfigExtraButtons.tsx | 134 ++++++
.../SMTPSetting/components/ConfigField.tsx | 109 +++++
.../PushNotification/SMTPSetting/index.tsx | 400 +++++-------------
.../components/ConfigExtraButtons.tsx | 86 ++++
.../WebhookSetting/components/ConfigField.tsx | 55 +++
.../PushNotification/WebhookSetting/index.tsx | 157 ++-----
.../Wechat/components/ConfigExtraButtons.tsx | 126 ++++++
.../Wechat/components/ConfigField.tsx | 64 +++
.../System/PushNotification/Wechat/index.tsx | 218 ++--------
.../page/System/PushNotification/index.tsx | 3 +-
.../components/ConfigModifyBtn/index.tsx | 3 +-
.../ConfigSubmitButtonField/index.tsx | 38 ++
.../System/components/ConfigTestBtn/index.tsx | 2 +-
.../src/page/System/hooks/useConfigRender.tsx | 1 +
packages/base/src/page/System/index.tsx | 3 +-
19 files changed, 1426 insertions(+), 859 deletions(-)
create mode 100644 packages/base/src/page/System/PushNotification/LarkSetting/conponents/ConfigExtraButtons.tsx
create mode 100644 packages/base/src/page/System/PushNotification/LarkSetting/conponents/ConfigField.tsx
create mode 100644 packages/base/src/page/System/PushNotification/LarkSetting/index copy.tsx
create mode 100644 packages/base/src/page/System/PushNotification/SMTPSetting/components/ConfigExtraButtons.tsx
create mode 100644 packages/base/src/page/System/PushNotification/SMTPSetting/components/ConfigField.tsx
create mode 100644 packages/base/src/page/System/PushNotification/WebhookSetting/components/ConfigExtraButtons.tsx
create mode 100644 packages/base/src/page/System/PushNotification/WebhookSetting/components/ConfigField.tsx
create mode 100644 packages/base/src/page/System/PushNotification/Wechat/components/ConfigExtraButtons.tsx
create mode 100644 packages/base/src/page/System/PushNotification/Wechat/components/ConfigField.tsx
create mode 100644 packages/base/src/page/System/components/ConfigSubmitButtonField/index.tsx
diff --git a/packages/base/src/page/System/PushNotification/LarkSetting/conponents/ConfigExtraButtons.tsx b/packages/base/src/page/System/PushNotification/LarkSetting/conponents/ConfigExtraButtons.tsx
new file mode 100644
index 000000000..9da13b4e2
--- /dev/null
+++ b/packages/base/src/page/System/PushNotification/LarkSetting/conponents/ConfigExtraButtons.tsx
@@ -0,0 +1,197 @@
+import { useTranslation } from 'react-i18next';
+
+import { useRef, useState } from 'react';
+import { Form, message, Radio, RadioGroupProps, Space } from 'antd';
+import { useForm } from 'antd/es/form/Form';
+import { formItemLayout } from '@actiontech/shared/lib/components/FormCom/style';
+import {
+ FormItemLabel,
+ FormItemNoLabel
+} from '@actiontech/shared/lib/components/FormCom';
+import { BasicInput, EmptyBox } from '@actiontech/shared';
+import { phoneRule } from '@actiontech/shared/lib/utils/FormRule';
+
+import ConfigTestBtn from '../../../components/ConfigTestBtn';
+import ConfigTestPopoverForm from '../../../components/ConfigTestPopoverForm';
+import ConfigModifyBtn from '../../../components/ConfigModifyBtn';
+
+import dms from '@actiontech/shared/lib/api/base/service/dms';
+import { ResponseCode } from '@actiontech/shared/lib/enum';
+import { TestFormFields } from '../index.type';
+import { TestFeishuConfigurationAccountTypeEnum } from '@actiontech/shared/lib/api/base/service/common.enum';
+
+interface ConfigExtraButtonsProps {
+ enabled: string | boolean;
+ isConfigClosed: boolean;
+ extraButtonsVisible: boolean;
+ handleClickModify: () => void;
+}
+
+const ConfigExtraButtons = ({
+ enabled,
+ isConfigClosed,
+ extraButtonsVisible,
+ handleClickModify
+}: ConfigExtraButtonsProps) => {
+ const { t } = useTranslation();
+ const [messageApi, messageContextHolder] = message.useMessage();
+
+ const [testPopoverVisible, toggleTestPopoverVisible] = useState(false);
+ const [testForm] = useForm();
+ const [receiveType, setReceiveType] =
+ useState(
+ TestFeishuConfigurationAccountTypeEnum.email
+ );
+
+ const testing = useRef(false);
+ const testLarkConfiguration = async () => {
+ if (testing.current) {
+ return;
+ }
+ const values = await testForm.validateFields();
+ testing.current = true;
+ toggleTestPopoverVisible(false);
+ const hide = messageApi.loading(t('dmsSystem.lark.testing'), 0);
+ dms
+ .TestFeishuConfiguration({
+ test_feishu_configuration: {
+ account:
+ receiveType === TestFeishuConfigurationAccountTypeEnum.email
+ ? values.receiveEmail
+ : values.receivePhone,
+ account_type: values.receiveType
+ }
+ })
+ .then((res) => {
+ if (res.data.code === ResponseCode.SUCCESS) {
+ const resData = res.data?.data;
+ if (resData?.is_message_sent_normally) {
+ messageApi.success(t('dmsSystem.lark.testSuccess'));
+ } else {
+ messageApi.error(
+ resData?.error_message ?? t('common.unknownError')
+ );
+ }
+ }
+ })
+ .finally(() => {
+ hide();
+ testing.current = false;
+ testForm.resetFields();
+ setReceiveType(TestFeishuConfigurationAccountTypeEnum.email);
+ });
+ };
+
+ const onTestPopoverOpen = (open: boolean) => {
+ if (!enabled) {
+ return;
+ }
+ if (!open) {
+ testForm.resetFields();
+ setReceiveType(TestFeishuConfigurationAccountTypeEnum.email);
+ }
+ toggleTestPopoverVisible(open);
+ };
+
+ const handleChangeReceiveType: RadioGroupProps['onChange'] = (e) => {
+ const receiveType = e.target.value;
+ setReceiveType(receiveType);
+
+ if (receiveType === TestFeishuConfigurationAccountTypeEnum.email) {
+ testForm.resetFields(['receivePhone']);
+ } else {
+ testForm.resetFields(['receiveEmail']);
+ }
+ };
+ return (
+ <>
+ {messageContextHolder}
+
+ toggleTestPopoverVisible(false)}
+ >
+
+
+ }
+ />
+
+
+ >
+ );
+};
+
+export default ConfigExtraButtons;
diff --git a/packages/base/src/page/System/PushNotification/LarkSetting/conponents/ConfigField.tsx b/packages/base/src/page/System/PushNotification/LarkSetting/conponents/ConfigField.tsx
new file mode 100644
index 000000000..ae03716e5
--- /dev/null
+++ b/packages/base/src/page/System/PushNotification/LarkSetting/conponents/ConfigField.tsx
@@ -0,0 +1,39 @@
+import { useTranslation } from 'react-i18next';
+
+import { FormItemLabel } from '@actiontech/shared/lib/components/FormCom';
+import { BasicInput } from '@actiontech/shared';
+
+const ConfigField = () => {
+ const { t } = useTranslation();
+
+ return (
+ <>
+
+
+
+
+
+
+ >
+ );
+};
+
+export default ConfigField;
diff --git a/packages/base/src/page/System/PushNotification/LarkSetting/index copy.tsx b/packages/base/src/page/System/PushNotification/LarkSetting/index copy.tsx
new file mode 100644
index 000000000..b6d714d35
--- /dev/null
+++ b/packages/base/src/page/System/PushNotification/LarkSetting/index copy.tsx
@@ -0,0 +1,395 @@
+import { useBoolean, useRequest } from 'ahooks';
+import {
+ Form,
+ message,
+ Radio,
+ RadioGroupProps,
+ Space,
+ Spin,
+ Typography
+} from 'antd';
+import { useForm } from 'antd/es/form/Form';
+import { useCallback, useMemo, useRef, useState } from 'react';
+import { useTranslation } from 'react-i18next';
+import { FormFields, TestFormFields } from './index.type';
+import { BasicButton, BasicInput, EmptyBox } from '@actiontech/shared';
+import { phoneRule } from '@actiontech/shared/lib/utils/FormRule';
+import { ResponseCode } from '@actiontech/shared/lib/enum';
+import { TestFeishuConfigurationAccountTypeEnum } from '@actiontech/shared/lib/api/base/service/common.enum';
+import useConfigSwitch from '../../hooks/useConfigSwitch';
+import useConfigRender, {
+ ReadOnlyConfigColumnsType
+} from '../../hooks/useConfigRender';
+import ConfigTestBtn from '../../components/ConfigTestBtn';
+import ConfigTestPopoverForm from '../../components/ConfigTestPopoverForm';
+import ConfigModifyBtn from '../../components/ConfigModifyBtn';
+import ConfigSwitch from '../../components/ConfigSwitch';
+import {
+ FormItemLabel,
+ FormItemNoLabel
+} from '@actiontech/shared/lib/components/FormCom';
+import { formItemLayout } from '@actiontech/shared/lib/components/FormCom/style';
+import dms from '@actiontech/shared/lib/api/base/service/dms';
+import { IFeishuConfigurationResData } from '@actiontech/shared/lib/api/base/service/common';
+import { switchFieldName } from './index.data';
+
+const LarkSetting: React.FC = () => {
+ const { t } = useTranslation();
+ const [messageApi, messageContextHolder] = message.useMessage();
+
+ const {
+ form,
+ renderConfigForm,
+ startModify,
+ modifyFinish,
+ modifyFlag,
+ extraButtonsVisible,
+ enabled
+ } = useConfigRender({
+ switchFieldName,
+ switchFieldLabel: t('dmsSystem.lark.enable')
+ });
+
+ const [submitLoading, { setTrue: startSubmit, setFalse: submitFinish }] =
+ useBoolean();
+
+ const {
+ data: larkInfo,
+ loading,
+ refresh: refreshLarkInfo
+ } = useRequest(
+ () => dms.GetFeishuConfiguration().then((res) => res.data?.data ?? {}),
+ {
+ onSuccess(res) {
+ if (res) {
+ form.setFieldsValue({
+ enabled: !!res.is_feishu_notification_enabled
+ });
+ }
+ }
+ }
+ );
+ const isConfigClosed = useMemo(() => {
+ return !larkInfo?.is_feishu_notification_enabled;
+ }, [larkInfo]);
+
+ const setFormDefaultValue = useCallback(() => {
+ form.setFieldsValue({
+ appKey: larkInfo?.app_id,
+ appSecret: undefined
+ });
+ }, [form, larkInfo]);
+
+ const handleClickModify = () => {
+ setFormDefaultValue();
+ startModify();
+ };
+ const handleClickCancel = () => {
+ if (isConfigClosed) form.setFieldsValue({ [switchFieldName]: false });
+ setFormDefaultValue();
+ modifyFinish();
+ };
+ const handleToggleSwitch = (open: boolean) => {
+ form.setFieldValue(switchFieldName, open);
+ };
+
+ const submitLarkConfig = (values: FormFields) => {
+ startSubmit();
+ dms
+ .UpdateFeishuConfiguration({
+ update_feishu_configuration: {
+ is_feishu_notification_enabled: values.enabled,
+ app_id: values.appKey,
+ app_secret: values.appSecret
+ }
+ })
+ .then((res) => {
+ if (res.data.code === ResponseCode.SUCCESS) {
+ modifyFinish();
+ refreshLarkInfo();
+ form.resetFields();
+ }
+ })
+ .finally(() => {
+ submitFinish();
+ });
+ };
+
+ const switchOpen = Form.useWatch(switchFieldName, form);
+
+ const {
+ configSwitchPopoverVisible,
+ onConfigSwitchPopoverOpen,
+ onConfigSwitchPopoverConfirm,
+ onConfigSwitchChange
+ } = useConfigSwitch({
+ isConfigClosed,
+ switchOpen,
+ modifyFlag,
+ startSubmit,
+ submitFinish,
+ handleClickModify,
+ handleUpdateConfig: () =>
+ dms.UpdateFeishuConfiguration({
+ update_feishu_configuration: {
+ ...larkInfo,
+ is_feishu_notification_enabled: false
+ }
+ }),
+ handleClickCancel,
+ refreshConfig: refreshLarkInfo,
+ handleToggleSwitch
+ });
+
+ const [testPopoverVisible, toggleTestPopoverVisible] = useState(false);
+ const [testForm] = useForm();
+ const [receiveType, setReceiveType] =
+ useState(
+ TestFeishuConfigurationAccountTypeEnum.email
+ );
+ const testing = useRef(false);
+ const testLarkConfiguration = async () => {
+ if (testing.current) {
+ return;
+ }
+ const values = await testForm.validateFields();
+ testing.current = true;
+ toggleTestPopoverVisible(false);
+ const hide = messageApi.loading(t('dmsSystem.lark.testing'), 0);
+ dms
+ .TestFeishuConfiguration({
+ test_feishu_configuration: {
+ account:
+ receiveType === TestFeishuConfigurationAccountTypeEnum.email
+ ? values.receiveEmail
+ : values.receivePhone,
+ account_type: values.receiveType
+ }
+ })
+ .then((res) => {
+ if (res.data.code === ResponseCode.SUCCESS) {
+ const resData = res.data?.data;
+ if (resData?.is_message_sent_normally) {
+ messageApi.success(t('dmsSystem.lark.testSuccess'));
+ } else {
+ messageApi.error(
+ resData?.error_message ?? t('common.unknownError')
+ );
+ }
+ }
+ })
+ .finally(() => {
+ hide();
+ testing.current = false;
+ testForm.resetFields();
+ setReceiveType(TestFeishuConfigurationAccountTypeEnum.email);
+ });
+ };
+ const onTestPopoverOpen = (open: boolean) => {
+ if (!enabled) {
+ return;
+ }
+ if (!open) {
+ testForm.resetFields();
+ setReceiveType(TestFeishuConfigurationAccountTypeEnum.email);
+ }
+ toggleTestPopoverVisible(open);
+ };
+
+ const handleChangeReceiveType: RadioGroupProps['onChange'] = (e) => {
+ const receiveType = e.target.value;
+ setReceiveType(receiveType);
+
+ if (receiveType === TestFeishuConfigurationAccountTypeEnum.email) {
+ testForm.resetFields(['receivePhone']);
+ } else {
+ testForm.resetFields(['receiveEmail']);
+ }
+ };
+
+ const readonlyColumnsConfig: ReadOnlyConfigColumnsType =
+ useMemo(() => {
+ return [
+ {
+ label: 'App ID',
+ span: 3,
+ dataIndex: 'app_id',
+ hidden: !larkInfo?.is_feishu_notification_enabled,
+ render: (val) => (
+ {val || '--'}
+ )
+ }
+ ];
+ }, [larkInfo]);
+
+ return (
+
+
+ {messageContextHolder}
+
+ {renderConfigForm({
+ data: larkInfo ?? {},
+ columns: readonlyColumnsConfig,
+ configExtraButtons: (
+
+ toggleTestPopoverVisible(false)}
+ >
+
+
+ }
+ />
+
+
+ ),
+ configSwitchNode: (
+
+ ),
+ configField: (
+ <>
+
+
+
+
+
+
+ >
+ ),
+ submitButtonField: (
+
+
+
+ {t('common.cancel')}
+
+
+ {t('common.submit')}
+
+
+
+ ),
+ submit: submitLarkConfig
+ })}
+
+
+ );
+};
+
+export default LarkSetting;
diff --git a/packages/base/src/page/System/PushNotification/LarkSetting/index.tsx b/packages/base/src/page/System/PushNotification/LarkSetting/index.tsx
index b6d714d35..84be73399 100644
--- a/packages/base/src/page/System/PushNotification/LarkSetting/index.tsx
+++ b/packages/base/src/page/System/PushNotification/LarkSetting/index.tsx
@@ -1,41 +1,26 @@
-import { useBoolean, useRequest } from 'ahooks';
-import {
- Form,
- message,
- Radio,
- RadioGroupProps,
- Space,
- Spin,
- Typography
-} from 'antd';
-import { useForm } from 'antd/es/form/Form';
-import { useCallback, useMemo, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
-import { FormFields, TestFormFields } from './index.type';
-import { BasicButton, BasicInput, EmptyBox } from '@actiontech/shared';
-import { phoneRule } from '@actiontech/shared/lib/utils/FormRule';
-import { ResponseCode } from '@actiontech/shared/lib/enum';
-import { TestFeishuConfigurationAccountTypeEnum } from '@actiontech/shared/lib/api/base/service/common.enum';
+import { useBoolean, useRequest } from 'ahooks';
+import { useCallback, useMemo } from 'react';
+import { Form, Spin, Typography } from 'antd';
+import { FormFields } from './index.type';
+
import useConfigSwitch from '../../hooks/useConfigSwitch';
import useConfigRender, {
ReadOnlyConfigColumnsType
} from '../../hooks/useConfigRender';
-import ConfigTestBtn from '../../components/ConfigTestBtn';
-import ConfigTestPopoverForm from '../../components/ConfigTestPopoverForm';
-import ConfigModifyBtn from '../../components/ConfigModifyBtn';
import ConfigSwitch from '../../components/ConfigSwitch';
-import {
- FormItemLabel,
- FormItemNoLabel
-} from '@actiontech/shared/lib/components/FormCom';
-import { formItemLayout } from '@actiontech/shared/lib/components/FormCom/style';
+
+import ConfigSubmitButtonField from '../../components/ConfigSubmitButtonField';
+import ConfigExtraButtons from './conponents/ConfigExtraButtons';
+import ConfigField from './conponents/ConfigField';
+
import dms from '@actiontech/shared/lib/api/base/service/dms';
+import { ResponseCode } from '@actiontech/shared/lib/enum';
import { IFeishuConfigurationResData } from '@actiontech/shared/lib/api/base/service/common';
import { switchFieldName } from './index.data';
const LarkSetting: React.FC = () => {
const { t } = useTranslation();
- const [messageApi, messageContextHolder] = message.useMessage();
const {
form,
@@ -141,72 +126,6 @@ const LarkSetting: React.FC = () => {
handleToggleSwitch
});
- const [testPopoverVisible, toggleTestPopoverVisible] = useState(false);
- const [testForm] = useForm();
- const [receiveType, setReceiveType] =
- useState(
- TestFeishuConfigurationAccountTypeEnum.email
- );
- const testing = useRef(false);
- const testLarkConfiguration = async () => {
- if (testing.current) {
- return;
- }
- const values = await testForm.validateFields();
- testing.current = true;
- toggleTestPopoverVisible(false);
- const hide = messageApi.loading(t('dmsSystem.lark.testing'), 0);
- dms
- .TestFeishuConfiguration({
- test_feishu_configuration: {
- account:
- receiveType === TestFeishuConfigurationAccountTypeEnum.email
- ? values.receiveEmail
- : values.receivePhone,
- account_type: values.receiveType
- }
- })
- .then((res) => {
- if (res.data.code === ResponseCode.SUCCESS) {
- const resData = res.data?.data;
- if (resData?.is_message_sent_normally) {
- messageApi.success(t('dmsSystem.lark.testSuccess'));
- } else {
- messageApi.error(
- resData?.error_message ?? t('common.unknownError')
- );
- }
- }
- })
- .finally(() => {
- hide();
- testing.current = false;
- testForm.resetFields();
- setReceiveType(TestFeishuConfigurationAccountTypeEnum.email);
- });
- };
- const onTestPopoverOpen = (open: boolean) => {
- if (!enabled) {
- return;
- }
- if (!open) {
- testForm.resetFields();
- setReceiveType(TestFeishuConfigurationAccountTypeEnum.email);
- }
- toggleTestPopoverVisible(open);
- };
-
- const handleChangeReceiveType: RadioGroupProps['onChange'] = (e) => {
- const receiveType = e.target.value;
- setReceiveType(receiveType);
-
- if (receiveType === TestFeishuConfigurationAccountTypeEnum.email) {
- testForm.resetFields(['receivePhone']);
- } else {
- testForm.resetFields(['receiveEmail']);
- }
- };
-
const readonlyColumnsConfig: ReadOnlyConfigColumnsType =
useMemo(() => {
return [
@@ -225,106 +144,16 @@ const LarkSetting: React.FC = () => {
return (
- {messageContextHolder}
-
{renderConfigForm({
data: larkInfo ?? {},
columns: readonlyColumnsConfig,
configExtraButtons: (
-
- toggleTestPopoverVisible(false)}
- >
-
-
- }
- />
-
-
+
),
configSwitchNode: (
{
onSwitchPopoverOpen={onConfigSwitchPopoverOpen}
/>
),
- configField: (
- <>
-
-
-
-
-
-
- >
- ),
+ configField: ,
submitButtonField: (
-
-
-
- {t('common.cancel')}
-
-
- {t('common.submit')}
-
-
-
+
),
submit: submitLarkConfig
})}
diff --git a/packages/base/src/page/System/PushNotification/SMTPSetting/components/ConfigExtraButtons.tsx b/packages/base/src/page/System/PushNotification/SMTPSetting/components/ConfigExtraButtons.tsx
new file mode 100644
index 000000000..57651a481
--- /dev/null
+++ b/packages/base/src/page/System/PushNotification/SMTPSetting/components/ConfigExtraButtons.tsx
@@ -0,0 +1,134 @@
+import { Form, message, Space } from 'antd';
+import { useTranslation } from 'react-i18next';
+import { useMemo, useRef, useState } from 'react';
+
+import { useForm } from 'antd/es/form/Form';
+import { formItemLayout } from '@actiontech/shared/lib/components/FormCom/style';
+import { FormItemLabel } from '@actiontech/shared/lib/components/FormCom';
+import { BasicInput } from '@actiontech/shared';
+import ConfigTestBtn from '../../../components/ConfigTestBtn';
+import ConfigTestPopoverForm from '../../../components/ConfigTestPopoverForm';
+import ConfigModifyBtn from '../../../components/ConfigModifyBtn';
+
+import dms from '@actiontech/shared/lib/api/base/service/dms';
+import { ResponseCode } from '@actiontech/shared/lib/enum';
+import { ISMTPConfigurationResData } from '@actiontech/shared/lib/api/base/service/common';
+
+type typeConfigExtraButtons = {
+ smtpInfo: ISMTPConfigurationResData | undefined;
+ enabled: string | number | boolean;
+ extraButtonsVisible: boolean;
+ handleClickModify: () => void;
+};
+
+const ConfigExtraButtons = ({
+ smtpInfo,
+ enabled,
+ extraButtonsVisible,
+ handleClickModify
+}: typeConfigExtraButtons) => {
+ const { t } = useTranslation();
+
+ const [messageApi, messageContextHolder] = message.useMessage();
+ const [testForm] = useForm<{ receiveEmail?: string }>();
+
+ const [testPopoverVisible, toggleTestPopoverVisible] = useState(false);
+
+ const isConfigClosed = useMemo(() => {
+ return !smtpInfo?.enable_smtp_notify;
+ }, [smtpInfo]);
+
+ const testTing = useRef(false);
+
+ const onTestPopoverOpen = (open: boolean) => {
+ if (!enabled) {
+ return;
+ }
+ if (!open) {
+ testForm.resetFields();
+ }
+ toggleTestPopoverVisible(open);
+ };
+
+ const test = async () => {
+ if (testTing.current) {
+ return;
+ }
+ const values = await testForm.validateFields();
+ testTing.current = true;
+ toggleTestPopoverVisible(false);
+ const hide = messageApi.loading(
+ t('dmsSystem.smtp.testing', {
+ email: values.receiveEmail
+ }),
+ 0
+ );
+ dms
+ .TestSMTPConfiguration({
+ test_smtp_configuration: {
+ recipient_addr: values.receiveEmail
+ }
+ })
+ .then((res) => {
+ if (res.data.code === ResponseCode.SUCCESS) {
+ const resData = res.data?.data;
+ if (resData?.is_smtp_send_normal) {
+ messageApi.success(
+ t('dmsSystem.smtp.testSuccess', { email: values.receiveEmail })
+ );
+ testForm.resetFields();
+ } else {
+ messageApi.error(
+ resData?.send_error_message ?? t('common.unknownError')
+ );
+ }
+ }
+ })
+ .finally(() => {
+ hide();
+ testTing.current = false;
+ testForm.resetFields();
+ });
+ };
+
+ return (
+ <>
+ {messageContextHolder}
+
+ toggleTestPopoverVisible(false)}
+ >
+
+
+ }
+ />
+
+
+ >
+ );
+};
+
+export default ConfigExtraButtons;
diff --git a/packages/base/src/page/System/PushNotification/SMTPSetting/components/ConfigField.tsx b/packages/base/src/page/System/PushNotification/SMTPSetting/components/ConfigField.tsx
new file mode 100644
index 000000000..6004d9a51
--- /dev/null
+++ b/packages/base/src/page/System/PushNotification/SMTPSetting/components/ConfigField.tsx
@@ -0,0 +1,109 @@
+import { useTranslation } from 'react-i18next';
+import { BasicInput, BasicSwitch } from '@actiontech/shared';
+import {
+ CustomLabelContent,
+ FormItemLabel
+} from '@actiontech/shared/lib/components/FormCom';
+import { validatorPort } from '@actiontech/shared/lib/utils/FormRule';
+
+const ConfigField = () => {
+ const { t } = useTranslation();
+
+ return (
+ <>
+
+ }
+ name="isSkipVerify"
+ valuePropName="checked"
+ >
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ({
+ validator(_, value) {
+ if (!value || getFieldValue('password') === value) {
+ return Promise.resolve();
+ }
+ return Promise.reject(
+ new Error(t('common.form.rule.passwordNotMatch'))
+ );
+ }
+ })
+ ]}
+ >
+
+
+ >
+ );
+};
+
+export default ConfigField;
diff --git a/packages/base/src/page/System/PushNotification/SMTPSetting/index.tsx b/packages/base/src/page/System/PushNotification/SMTPSetting/index.tsx
index 1e835e8af..c10cc957d 100644
--- a/packages/base/src/page/System/PushNotification/SMTPSetting/index.tsx
+++ b/packages/base/src/page/System/PushNotification/SMTPSetting/index.tsx
@@ -1,39 +1,30 @@
-import { useCallback, useMemo, useRef, useState } from 'react';
-import { useBoolean, useRequest } from 'ahooks';
-import { Form, message, Space, Spin } from 'antd';
-import { useForm } from 'antd/es/form/Form';
import { useTranslation } from 'react-i18next';
-import { ResponseCode } from '@actiontech/shared/lib/enum';
-import { SMTPSettingFormFields } from './index.type';
-import {
- BasicButton,
- BasicInput,
- BasicSwitch,
- BasicToolTips
-} from '@actiontech/shared';
-import { IconTipGray } from '@actiontech/shared/lib/Icon';
-import { validatorPort } from '@actiontech/shared/lib/utils/FormRule';
-import {
- CustomLabelContent,
- FormItemLabel,
- FormItemNoLabel
-} from '@actiontech/shared/lib/components/FormCom';
-import { ISMTPConfigurationResData } from '@actiontech/shared/lib/api/base/service/common';
-import dms from '@actiontech/shared/lib/api/base/service/dms';
+import { useCallback, useMemo } from 'react';
+import { useBoolean, useRequest } from 'ahooks';
+import { Form, Spin } from 'antd';
+
import useConfigRender, {
ReadOnlyConfigColumnsType
} from '../../hooks/useConfigRender';
+import { SMTPSettingFormFields } from './index.type';
import { switchFieldName } from './index.data';
-import ConfigModifyBtn from '../../components/ConfigModifyBtn';
-import ConfigTestBtn from '../../components/ConfigTestBtn';
-import ConfigSwitch from '../../components/ConfigSwitch';
+
+import { ISMTPConfigurationResData } from '@actiontech/shared/lib/api/base/service/common';
+import { BasicToolTips } from '@actiontech/shared';
+import { IconTipGray } from '@actiontech/shared/lib/Icon';
+
import useConfigSwitch from '../../hooks/useConfigSwitch';
-import ConfigTestPopoverForm from '../../components/ConfigTestPopoverForm';
-import { formItemLayout } from '@actiontech/shared/lib/components/FormCom/style';
+import ConfigSwitch from '../../components/ConfigSwitch';
+
+import ConfigField from './components/ConfigField';
+import ConfigExtraButtons from './components/ConfigExtraButtons';
+
+import dms from '@actiontech/shared/lib/api/base/service/dms';
+import { ResponseCode } from '@actiontech/shared/lib/enum';
+import ConfigSubmitButtonField from '../../components/ConfigSubmitButtonField';
const SMTPSetting = () => {
const { t } = useTranslation();
- const [messageApi, messageContextHolder] = message.useMessage();
const {
form,
@@ -65,6 +56,74 @@ const SMTPSetting = () => {
}
);
+ const switchOpen = Form.useWatch(switchFieldName, form);
+
+ const readonlyColumnsConfig: ReadOnlyConfigColumnsType =
+ useMemo(() => {
+ return [
+ {
+ label: t('dmsSystem.smtp.host'),
+ span: 3,
+ dataIndex: 'smtp_host',
+ hidden: !smtpInfo?.enable_smtp_notify
+ },
+ {
+ label: t('dmsSystem.smtp.port'),
+ span: 3,
+ dataIndex: 'smtp_port',
+ hidden: !smtpInfo?.enable_smtp_notify
+ },
+ {
+ label: t('dmsSystem.smtp.username'),
+ span: 3,
+ dataIndex: 'smtp_username',
+ hidden: !smtpInfo?.enable_smtp_notify
+ },
+ {
+ label: (
+ }
+ >
+ {t('dmsSystem.smtp.isSkipVerify')}
+
+ ),
+ span: 3,
+ dataIndex: 'is_skip_verify',
+ hidden: !smtpInfo?.enable_smtp_notify,
+ render: (val) => <>{!!val ? t('common.true') : t('common.false')}>
+ }
+ ];
+ }, [t, smtpInfo]);
+
+ const [submitLoading, { setTrue: startSubmit, setFalse: submitFinish }] =
+ useBoolean();
+
+ const submit = (values: SMTPSettingFormFields) => {
+ startSubmit();
+ dms
+ .UpdateSMTPConfiguration({
+ smtp_configuration: {
+ enable_smtp_notify: values.enable,
+ is_skip_verify: values.isSkipVerify,
+ smtp_host: values.host,
+ smtp_password: values.password,
+ smtp_port: `${values.port}`,
+ smtp_username: values.username
+ }
+ })
+ .then((res) => {
+ if (res.data.code === ResponseCode.SUCCESS) {
+ modifyFinish();
+ refreshSMTPInfo();
+ form.resetFields();
+ }
+ })
+ .finally(() => {
+ submitFinish();
+ });
+ };
+
const isConfigClosed = useMemo(() => {
return !smtpInfo?.enable_smtp_notify;
}, [smtpInfo]);
@@ -86,6 +145,7 @@ const SMTPSetting = () => {
setFormDefaultValue();
startModify();
}, [startModify, setFormDefaultValue]);
+
const handleClickCancel = () => {
if (isConfigClosed) form.setFieldValue(switchFieldName, false);
setFormDefaultValue();
@@ -96,35 +156,6 @@ const SMTPSetting = () => {
form.setFieldValue(switchFieldName, open);
};
- const [submitLoading, { setTrue: startSubmit, setFalse: submitFinish }] =
- useBoolean();
- const submit = (values: SMTPSettingFormFields) => {
- startSubmit();
- dms
- .UpdateSMTPConfiguration({
- smtp_configuration: {
- enable_smtp_notify: values.enable,
- is_skip_verify: values.isSkipVerify,
- smtp_host: values.host,
- smtp_password: values.password,
- smtp_port: `${values.port}`,
- smtp_username: values.username
- }
- })
- .then((res) => {
- if (res.data.code === ResponseCode.SUCCESS) {
- modifyFinish();
- refreshSMTPInfo();
- form.resetFields();
- }
- })
- .finally(() => {
- submitFinish();
- });
- };
-
- const switchOpen = Form.useWatch(switchFieldName, form);
-
const {
configSwitchPopoverVisible,
onConfigSwitchPopoverOpen,
@@ -149,143 +180,19 @@ const SMTPSetting = () => {
handleToggleSwitch
});
- const [testPopoverVisible, toggleTestPopoverVisible] = useState(false);
- const [testForm] = useForm<{ receiveEmail?: string }>();
- const testTing = useRef(false);
- const test = async () => {
- if (testTing.current) {
- return;
- }
- const values = await testForm.validateFields();
- testTing.current = true;
- toggleTestPopoverVisible(false);
- const hide = messageApi.loading(
- t('dmsSystem.smtp.testing', {
- email: values.receiveEmail
- }),
- 0
- );
- dms
- .TestSMTPConfiguration({
- test_smtp_configuration: {
- recipient_addr: values.receiveEmail
- }
- })
- .then((res) => {
- if (res.data.code === ResponseCode.SUCCESS) {
- const resData = res.data?.data;
- if (resData?.is_smtp_send_normal) {
- messageApi.success(
- t('dmsSystem.smtp.testSuccess', { email: values.receiveEmail })
- );
- testForm.resetFields();
- } else {
- messageApi.error(
- resData?.send_error_message ?? t('common.unknownError')
- );
- }
- }
- })
- .finally(() => {
- hide();
- testTing.current = false;
- testForm.resetFields();
- });
- };
- const onTestPopoverOpen = (open: boolean) => {
- if (!enabled) {
- return;
- }
- if (!open) {
- testForm.resetFields();
- }
- toggleTestPopoverVisible(open);
- };
-
- const readonlyColumnsConfig: ReadOnlyConfigColumnsType =
- useMemo(() => {
- return [
- {
- label: t('dmsSystem.smtp.host'),
- span: 3,
- dataIndex: 'smtp_host',
- hidden: !smtpInfo?.enable_smtp_notify
- },
- {
- label: t('dmsSystem.smtp.port'),
- span: 3,
- dataIndex: 'smtp_port',
- hidden: !smtpInfo?.enable_smtp_notify
- },
- {
- label: t('dmsSystem.smtp.username'),
- span: 3,
- dataIndex: 'smtp_username',
- hidden: !smtpInfo?.enable_smtp_notify
- },
- {
- label: (
- }
- >
- {t('dmsSystem.smtp.isSkipVerify')}
-
- ),
- span: 3,
- dataIndex: 'is_skip_verify',
- hidden: !smtpInfo?.enable_smtp_notify,
- render: (val) => <>{!!val ? t('common.true') : t('common.false')}>
- }
- ];
- }, [t, smtpInfo]);
-
return (
- {messageContextHolder}
-
{renderConfigForm({
data: smtpInfo ?? {},
columns: readonlyColumnsConfig,
configExtraButtons: (
-
- toggleTestPopoverVisible(false)}
- >
-
-
- }
- />
-
-
+
),
configSwitchNode: (
{
onSwitchPopoverOpen={onConfigSwitchPopoverOpen}
/>
),
- configField: (
- <>
-
- }
- name="isSkipVerify"
- valuePropName="checked"
- >
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ({
- validator(_, value) {
- if (!value || getFieldValue('password') === value) {
- return Promise.resolve();
- }
- return Promise.reject(
- new Error(t('common.form.rule.passwordNotMatch'))
- );
- }
- })
- ]}
- >
-
-
- >
- ),
+ configField: ,
submitButtonField: (
-
-
-
- {t('common.cancel')}
-
-
- {t('common.submit')}
-
-
-
+
),
submit
})}
diff --git a/packages/base/src/page/System/PushNotification/WebhookSetting/components/ConfigExtraButtons.tsx b/packages/base/src/page/System/PushNotification/WebhookSetting/components/ConfigExtraButtons.tsx
new file mode 100644
index 000000000..63d9c6c9b
--- /dev/null
+++ b/packages/base/src/page/System/PushNotification/WebhookSetting/components/ConfigExtraButtons.tsx
@@ -0,0 +1,86 @@
+import { useTranslation } from 'react-i18next';
+import { useRef } from 'react';
+import { message, Space } from 'antd';
+
+import ConfigModifyBtn from '../../../components/ConfigModifyBtn';
+import { BasicButton, BasicToolTips } from '@actiontech/shared';
+import { IconTest } from '../../../../../icon/system';
+
+import dms from '@actiontech/shared/lib/api/base/service/dms';
+import { ResponseCode } from '@actiontech/shared/lib/enum';
+
+interface ConfigExtraButtonsProps {
+ enabled: string | number | boolean;
+ isConfigClosed: boolean;
+ extraButtonsVisible: boolean;
+ handleClickModify: () => void;
+ msgUrl: string;
+}
+
+const ConfigExtraButtons = ({
+ enabled,
+ isConfigClosed,
+ extraButtonsVisible,
+ handleClickModify,
+ msgUrl
+}: ConfigExtraButtonsProps) => {
+ const { t } = useTranslation();
+ const [messageApi, messageContextHolder] = message.useMessage();
+
+ const testTing = useRef(false);
+ const test = () => {
+ if (testTing.current) {
+ return;
+ }
+
+ testTing.current = true;
+ const hide = messageApi.loading(
+ t('dmsSystem.webhook.testing', { url: msgUrl }),
+ 0
+ );
+ dms
+ .TestWebHookConfiguration()
+ .then((res) => {
+ if (res.data.code === ResponseCode.SUCCESS) {
+ const resData = res.data?.data;
+
+ if (resData?.is_message_sent_normally) {
+ messageApi.success(t('dmsSystem.webhook.testSuccess'));
+ } else {
+ messageApi.error(
+ resData?.send_error_message ?? t('common.unknownError')
+ );
+ }
+ }
+ })
+ .finally(() => {
+ hide();
+ testTing.current = false;
+ });
+ };
+
+ return (
+ <>
+ {messageContextHolder}
+
+
+ }
+ onClick={() => {
+ if (!enabled) return;
+ test();
+ }}
+ />
+
+
+
+ >
+ );
+};
+
+export default ConfigExtraButtons;
diff --git a/packages/base/src/page/System/PushNotification/WebhookSetting/components/ConfigField.tsx b/packages/base/src/page/System/PushNotification/WebhookSetting/components/ConfigField.tsx
new file mode 100644
index 000000000..1b835d447
--- /dev/null
+++ b/packages/base/src/page/System/PushNotification/WebhookSetting/components/ConfigField.tsx
@@ -0,0 +1,55 @@
+import { useTranslation } from 'react-i18next';
+
+import { BasicInput, BasicInputNumber } from '@actiontech/shared';
+import { FormItemLabel } from '@actiontech/shared/lib/components/FormCom';
+
+const ConfigField = () => {
+ const { t } = useTranslation();
+
+ return (
+ <>
+
+
+
+
+
+
+
+
+
+
+
+
+ >
+ );
+};
+
+export default ConfigField;
diff --git a/packages/base/src/page/System/PushNotification/WebhookSetting/index.tsx b/packages/base/src/page/System/PushNotification/WebhookSetting/index.tsx
index cdabea43d..769028ffa 100644
--- a/packages/base/src/page/System/PushNotification/WebhookSetting/index.tsx
+++ b/packages/base/src/page/System/PushNotification/WebhookSetting/index.tsx
@@ -1,34 +1,27 @@
-import { useBoolean, useRequest } from 'ahooks';
-import { Form, message, Space, Spin } from 'antd';
-import { useCallback, useMemo, useRef } from 'react';
import { useTranslation } from 'react-i18next';
+import { useBoolean, useRequest } from 'ahooks';
+import { useCallback, useMemo } from 'react';
+import { Form, Spin } from 'antd';
import { Link } from 'react-router-dom';
-import { ResponseCode } from '@actiontech/shared/lib/enum';
-import { WebhookFormFields } from './index.type';
-import dms from '@actiontech/shared/lib/api/base/service/dms';
-import { IWebHookConfigurationData } from '@actiontech/shared/lib/api/base/service/common';
+
import { DEFAULT_CONSTANT, switchFieldName } from './index.data';
import useConfigRender, {
ReadOnlyConfigColumnsType
} from '../../hooks/useConfigRender';
import useConfigSwitch from '../../hooks/useConfigSwitch';
+
import ConfigSwitch from '../../components/ConfigSwitch';
-import ConfigModifyBtn from '../../components/ConfigModifyBtn';
-import {
- BasicButton,
- BasicInput,
- BasicInputNumber,
- BasicToolTips
-} from '@actiontech/shared';
-import { IconTest } from '../../../../icon/system';
-import {
- FormItemLabel,
- FormItemNoLabel
-} from '@actiontech/shared/lib/components/FormCom';
+import ConfigExtraButtons from './components/ConfigExtraButtons';
+import ConfigField from './components/ConfigField';
+import ConfigSubmitButtonField from '../../components/ConfigSubmitButtonField';
+
+import dms from '@actiontech/shared/lib/api/base/service/dms';
+import { IWebHookConfigurationData } from '@actiontech/shared/lib/api/base/service/common';
+import { WebhookFormFields } from './index.type';
+import { ResponseCode } from '@actiontech/shared/lib/enum';
const WebHook: React.FC = () => {
const { t } = useTranslation();
- const [messageApi, messageContextHolder] = message.useMessage();
const {
form,
@@ -157,38 +150,6 @@ const WebHook: React.FC = () => {
handleToggleSwitch
});
- const testTing = useRef(false);
- const test = () => {
- if (testTing.current) {
- return;
- }
-
- testTing.current = true;
- const hide = messageApi.loading(
- t('dmsSystem.webhook.testing', { url: webhookConfig?.url ?? '' }),
- 0
- );
- dms
- .TestWebHookConfiguration()
- .then((res) => {
- if (res.data.code === ResponseCode.SUCCESS) {
- const resData = res.data?.data;
-
- if (resData?.is_message_sent_normally) {
- messageApi.success(t('dmsSystem.webhook.testSuccess'));
- } else {
- messageApi.error(
- resData?.send_error_message ?? t('common.unknownError')
- );
- }
- }
- })
- .finally(() => {
- hide();
- testTing.current = false;
- });
- };
-
const readonlyColumnsConfig: ReadOnlyConfigColumnsType =
useMemo(() => {
return [
@@ -204,29 +165,17 @@ const WebHook: React.FC = () => {
return (
- {messageContextHolder}
-
{renderConfigForm({
data: webhookConfig ?? {},
columns: readonlyColumnsConfig,
configExtraButtons: (
-
-
- }
- onClick={() => {
- if (!enabled) return;
- test();
- }}
- />
-
-
-
+
),
configSwitchNode: (
{
onSwitchPopoverOpen={onConfigSwitchPopoverOpen}
/>
),
- configField: (
- <>
-
-
-
-
-
-
-
-
-
-
-
-
- >
- ),
+ configField: ,
submitButtonField: (
-
-
-
- {t('common.cancel')}
-
-
- {t('common.submit')}
-
-
-
+
),
submit
})}
diff --git a/packages/base/src/page/System/PushNotification/Wechat/components/ConfigExtraButtons.tsx b/packages/base/src/page/System/PushNotification/Wechat/components/ConfigExtraButtons.tsx
new file mode 100644
index 000000000..825e405ad
--- /dev/null
+++ b/packages/base/src/page/System/PushNotification/Wechat/components/ConfigExtraButtons.tsx
@@ -0,0 +1,126 @@
+import { useTranslation } from 'react-i18next';
+import { useRef, useState } from 'react';
+
+import { Form, message, Space } from 'antd';
+import { formItemLayout } from '@actiontech/shared/lib/components/FormCom/style';
+import {
+ CustomLabelContent,
+ FormItemLabel
+} from '@actiontech/shared/lib/components/FormCom';
+import ConfigModifyBtn from '../../../components/ConfigModifyBtn';
+import ConfigTestBtn from '../../../components/ConfigTestBtn';
+import ConfigTestPopoverForm from '../../../components/ConfigTestPopoverForm';
+import { BasicInput } from '@actiontech/shared';
+
+import dms from '@actiontech/shared/lib/api/base/service/dms';
+
+type typeConfigExtraButtons = {
+ extraButtonsVisible: boolean;
+ isConfigClosed: boolean;
+ enabled: string | boolean | undefined;
+ handleClickModify: () => void;
+};
+
+const ConfigExtraButtons = ({
+ extraButtonsVisible,
+ isConfigClosed,
+ enabled,
+ handleClickModify
+}: typeConfigExtraButtons) => {
+ const { t } = useTranslation();
+ const [messageApi, messageContextHolder] = message.useMessage();
+ const [testForm] = Form.useForm<{ receiveId?: string }>();
+
+ const [testPopoverVisible, toggleTestPopoverVisible] = useState(false);
+ const testTing = useRef(false);
+ const test = async () => {
+ if (testTing.current) {
+ return;
+ }
+ const values = await testForm.validateFields();
+
+ testTing.current = true;
+ toggleTestPopoverVisible(false);
+ const hide = messageApi.loading(
+ t('dmsSystem.wechat.testing', { id: values.receiveId }),
+ 0
+ );
+ dms
+ .TestWeChatConfiguration({
+ test_wechat_configuration: {
+ recipient_id: values.receiveId
+ }
+ })
+ .then((res) => {
+ const resData = res.data?.data;
+ if (resData?.is_wechat_send_normal) {
+ messageApi.success(t('dmsSystem.wechat.testSuccess'));
+ } else {
+ messageApi.error(
+ resData?.send_error_message ?? t('common.unknownError')
+ );
+ }
+ })
+ .finally(() => {
+ hide();
+ testTing.current = false;
+ testForm.resetFields();
+ });
+ };
+
+ const onTestPopoverOpen = (open: boolean) => {
+ if (!enabled) {
+ return;
+ }
+ if (!open) {
+ testForm.resetFields();
+ }
+ toggleTestPopoverVisible(open);
+ };
+
+ return (
+ <>
+ {messageContextHolder}
+
+ toggleTestPopoverVisible(false)}
+ >
+
+
+ }
+ testingRef={testTing}
+ />
+
+
+ >
+ );
+};
+
+export default ConfigExtraButtons;
diff --git a/packages/base/src/page/System/PushNotification/Wechat/components/ConfigField.tsx b/packages/base/src/page/System/PushNotification/Wechat/components/ConfigField.tsx
new file mode 100644
index 000000000..feed8607e
--- /dev/null
+++ b/packages/base/src/page/System/PushNotification/Wechat/components/ConfigField.tsx
@@ -0,0 +1,64 @@
+import { useTranslation } from 'react-i18next';
+
+import { BasicInput, BasicSwitch } from '@actiontech/shared';
+import { FormItemLabel } from '@actiontech/shared/lib/components/FormCom';
+
+const ConfigField = () => {
+ const { t } = useTranslation();
+
+ return (
+ <>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ >
+ );
+};
+
+export default ConfigField;
diff --git a/packages/base/src/page/System/PushNotification/Wechat/index.tsx b/packages/base/src/page/System/PushNotification/Wechat/index.tsx
index 6bbc27e9b..0ccb7297a 100644
--- a/packages/base/src/page/System/PushNotification/Wechat/index.tsx
+++ b/packages/base/src/page/System/PushNotification/Wechat/index.tsx
@@ -1,32 +1,27 @@
-import { useCallback, useMemo, useRef, useState } from 'react';
-import { useBoolean, useRequest } from 'ahooks';
-import { Form, message, Space, Spin } from 'antd';
import { useTranslation } from 'react-i18next';
-import { ResponseCode } from '@actiontech/shared/lib/enum';
-import { WechatFormFields } from './index.type';
+import { useCallback, useMemo } from 'react';
+
+import { useBoolean, useRequest } from 'ahooks';
+
+import { switchFieldName } from './index.data';
+import { Form, Spin } from 'antd';
+import ConfigSwitch from '../../components/ConfigSwitch';
+import useConfigSwitch from '../../hooks/useConfigSwitch';
import useConfigRender, {
ReadOnlyConfigColumnsType
} from '../../hooks/useConfigRender';
+
+import ConfigExtraButtons from './components/ConfigExtraButtons';
+import ConfigField from './components/ConfigField';
+import ConfigSubmitButtonField from '../../components/ConfigSubmitButtonField';
+
import dms from '@actiontech/shared/lib/api/base/service/dms';
+import { ResponseCode } from '@actiontech/shared/lib/enum';
+import { WechatFormFields } from './index.type';
import { IWeChatConfigurationResData } from '@actiontech/shared/lib/api/base/service/common';
-import { BasicButton, BasicInput, BasicSwitch } from '@actiontech/shared';
-import { switchFieldName } from './index.data';
-import {
- CustomLabelContent,
- FormItemLabel,
- FormItemNoLabel
-} from '@actiontech/shared/lib/components/FormCom';
-import ConfigSwitch from '../../components/ConfigSwitch';
-import ConfigModifyBtn from '../../components/ConfigModifyBtn';
-import ConfigTestBtn from '../../components/ConfigTestBtn';
-import useConfigSwitch from '../../hooks/useConfigSwitch';
-import ConfigTestPopoverForm from '../../components/ConfigTestPopoverForm';
-import { formItemLayout } from '@actiontech/shared/lib/components/FormCom/style';
const Wechat = () => {
const { t } = useTranslation();
- const [testForm] = Form.useForm<{ receiveId?: string }>();
- const [messageApi, messageContextHolder] = message.useMessage();
const {
data: wechatConfig,
@@ -58,10 +53,6 @@ const Wechat = () => {
switchFieldLabel: t('dmsSystem.wechat.enable_wechat_notify')
});
- const isConfigClosed = useMemo(() => {
- return !wechatConfig?.enable_wechat_notify;
- }, [wechatConfig]);
-
const [submitLoading, { setTrue: startSubmit, setFalse: submitFinish }] =
useBoolean();
const submit = (values: WechatFormFields) => {
@@ -105,6 +96,10 @@ const Wechat = () => {
setFormDefaultValue();
startModify();
};
+ const isConfigClosed = useMemo(() => {
+ return !wechatConfig?.enable_wechat_notify;
+ }, [wechatConfig]);
+
const handleClickCancel = () => {
if (isConfigClosed) form.setFieldsValue({ [switchFieldName]: false });
setFormDefaultValue();
@@ -141,53 +136,6 @@ const Wechat = () => {
handleToggleSwitch
});
- const [testPopoverVisible, toggleTestPopoverVisible] = useState(false);
- const testTing = useRef(false);
- const test = async () => {
- if (testTing.current) {
- return;
- }
- const values = await testForm.validateFields();
-
- testTing.current = true;
- toggleTestPopoverVisible(false);
- const hide = messageApi.loading(
- t('dmsSystem.wechat.testing', { id: values.receiveId }),
- 0
- );
- dms
- .TestWeChatConfiguration({
- test_wechat_configuration: {
- recipient_id: values.receiveId
- }
- })
- .then((res) => {
- const resData = res.data?.data;
- if (resData?.is_wechat_send_normal) {
- messageApi.success(t('dmsSystem.wechat.testSuccess'));
- } else {
- messageApi.error(
- resData?.send_error_message ?? t('common.unknownError')
- );
- }
- })
- .finally(() => {
- hide();
- testTing.current = false;
- testForm.resetFields();
- });
- };
-
- const onTestPopoverOpen = (open: boolean) => {
- if (!enabled) {
- return;
- }
- if (!open) {
- testForm.resetFields();
- }
- toggleTestPopoverVisible(open);
- };
-
const readonlyColumnsConfig: ReadOnlyConfigColumnsType =
useMemo(() => {
return [
@@ -222,53 +170,16 @@ const Wechat = () => {
return (
- {messageContextHolder}
{renderConfigForm({
data: wechatConfig ?? {},
columns: readonlyColumnsConfig,
configExtraButtons: (
-
- toggleTestPopoverVisible(false)}
- >
-
-
- }
- testingRef={testTing}
- />
-
-
+
),
configSwitchNode: (
{
onSwitchPopoverOpen={onConfigSwitchPopoverOpen}
/>
),
- configField: (
- <>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- >
- ),
+ configField: ,
submitButtonField: (
-
-
-
- {t('common.cancel')}
-
-
- {t('common.submit')}
-
-
-
+
),
submit
})}
diff --git a/packages/base/src/page/System/PushNotification/index.tsx b/packages/base/src/page/System/PushNotification/index.tsx
index 4858aaeb2..7104b943e 100644
--- a/packages/base/src/page/System/PushNotification/index.tsx
+++ b/packages/base/src/page/System/PushNotification/index.tsx
@@ -1,9 +1,10 @@
import { useTranslation } from 'react-i18next';
+
+import SystemBasicTitle from '../components/BasicTitle';
import SMTPSetting from './SMTPSetting';
import Wechat from './Wechat';
import LarkSetting from './LarkSetting';
import WebHook from './WebhookSetting';
-import SystemBasicTitle from '../components/BasicTitle';
const PushNotification = () => {
const { t } = useTranslation();
diff --git a/packages/base/src/page/System/components/ConfigModifyBtn/index.tsx b/packages/base/src/page/System/components/ConfigModifyBtn/index.tsx
index dcfb9d609..f8aed8f7c 100644
--- a/packages/base/src/page/System/components/ConfigModifyBtn/index.tsx
+++ b/packages/base/src/page/System/components/ConfigModifyBtn/index.tsx
@@ -1,9 +1,10 @@
+import { useTranslation } from 'react-i18next';
import { BasicButton, BasicToolTips } from '@actiontech/shared';
import { IconModify } from '../../../../icon/system';
-import { useTranslation } from 'react-i18next';
const ConfigModifyBtn: React.FC<{ onClick: () => void }> = ({ onClick }) => {
const { t } = useTranslation();
+
return (
void;
+}
+
+const ConfigSubmitButtonField = ({
+ submitLoading,
+ handleClickCancel
+}: ConfigSubmitButtonFieldProps) => {
+ const { t } = useTranslation();
+ return (
+ <>
+
+
+
+ {t('common.cancel')}
+
+
+ {t('common.submit')}
+
+
+
+ >
+ );
+};
+
+export default ConfigSubmitButtonField;
diff --git a/packages/base/src/page/System/components/ConfigTestBtn/index.tsx b/packages/base/src/page/System/components/ConfigTestBtn/index.tsx
index 6adea73a6..fc6c685b8 100644
--- a/packages/base/src/page/System/components/ConfigTestBtn/index.tsx
+++ b/packages/base/src/page/System/components/ConfigTestBtn/index.tsx
@@ -1,6 +1,6 @@
+import { useTranslation } from 'react-i18next';
import { MutableRefObject } from 'react';
import { Popover } from 'antd';
-import { useTranslation } from 'react-i18next';
import { BasicButton, BasicToolTips } from '@actiontech/shared';
import { IconTest } from '../../../../icon/system';
diff --git a/packages/base/src/page/System/hooks/useConfigRender.tsx b/packages/base/src/page/System/hooks/useConfigRender.tsx
index aa7b739b6..b9a57d1d4 100644
--- a/packages/base/src/page/System/hooks/useConfigRender.tsx
+++ b/packages/base/src/page/System/hooks/useConfigRender.tsx
@@ -24,6 +24,7 @@ export function renderReadOnlyModeConfig(
) {
const { data = {} as T, columns, modifyFlag } = params;
const hasConfig = columns.some((column) => !column.hidden);
+
return (
!modifyFlag &&
hasConfig && (
diff --git a/packages/base/src/page/System/index.tsx b/packages/base/src/page/System/index.tsx
index 911ecd88c..1115f6da5 100644
--- a/packages/base/src/page/System/index.tsx
+++ b/packages/base/src/page/System/index.tsx
@@ -3,9 +3,9 @@ import { useDispatch } from 'react-redux';
import { useTranslation } from 'react-i18next';
import { Row } from 'antd';
import { BasicSegmented, PageHeader } from '@actiontech/shared';
-import { ModalName } from '../../data/ModalName';
import { SystemStyleWrapper } from './style';
import { initSystemModalStatus } from '../../store/system';
+import { ModalName } from '../../data/ModalName';
// #if [sqle]
import PushNotification from './PushNotification';
@@ -31,6 +31,7 @@ enum SystemSegmentedKeyEnum {
const System = () => {
const { t } = useTranslation();
+
const dispatch = useDispatch();
const options = useMemo(
From 1e79e90ecf2102c59af4f3cd5c9d1cf67866b179 Mon Sep 17 00:00:00 2001
From: xinbinyan <404928130@qq.com>
Date: Tue, 23 Jan 2024 13:53:32 +0800
Subject: [PATCH 03/27] upgrade processConnection
---
.../components/ConfigExtraButtons.tsx | 71 +++++
.../components/ConfigField.tsx | 39 +++
.../DingTalkSetting/index.tsx | 120 ++------
.../components/ConfigExtraButtons.tsx | 191 +++++++++++++
.../components/ConfigField.tsx | 37 +++
.../LarkAuditSetting/index.tsx | 262 ++----------------
6 files changed, 386 insertions(+), 334 deletions(-)
create mode 100644 packages/base/src/page/System/ProcessConnection/DingTalkSetting/components/ConfigExtraButtons.tsx
create mode 100644 packages/base/src/page/System/ProcessConnection/DingTalkSetting/components/ConfigField.tsx
create mode 100644 packages/base/src/page/System/ProcessConnection/LarkAuditSetting/components/ConfigExtraButtons.tsx
create mode 100644 packages/base/src/page/System/ProcessConnection/LarkAuditSetting/components/ConfigField.tsx
diff --git a/packages/base/src/page/System/ProcessConnection/DingTalkSetting/components/ConfigExtraButtons.tsx b/packages/base/src/page/System/ProcessConnection/DingTalkSetting/components/ConfigExtraButtons.tsx
new file mode 100644
index 000000000..493e092b3
--- /dev/null
+++ b/packages/base/src/page/System/ProcessConnection/DingTalkSetting/components/ConfigExtraButtons.tsx
@@ -0,0 +1,71 @@
+import { useTranslation } from 'react-i18next';
+import { useRef } from 'react';
+
+import { message, Space } from 'antd';
+import { BasicToolTips, BasicButton } from '@actiontech/shared';
+import ConfigModifyBtn from '../../../components/ConfigModifyBtn';
+import { IconTest } from '../../../../../icon/system';
+
+import configuration from '@actiontech/shared/lib/api/sqle/service/configuration';
+import { ResponseCode } from '@actiontech/shared/lib/enum';
+
+interface ConfigExtraButtonsProps {
+ isConfigClosed: boolean;
+ extraButtonsVisible: boolean;
+ handleClickModify: () => void;
+}
+
+const ConfigExtraButtons = ({
+ isConfigClosed,
+ extraButtonsVisible,
+ handleClickModify
+}: ConfigExtraButtonsProps) => {
+ const { t } = useTranslation();
+ const [messageApi, messageContextHolder] = message.useMessage();
+
+ const testTing = useRef(false);
+ const testDingTalkConfiguration = () => {
+ if (testTing.current) {
+ return;
+ }
+ testTing.current = true;
+ configuration
+ .testDingTalkConfigV1()
+ .then((res) => {
+ if (res.data.code === ResponseCode.SUCCESS) {
+ if (res.data.data?.is_ding_talk_send_normal) {
+ messageApi.success(t('dmsSystem.dingTalk.testSuccess'));
+ } else {
+ messageApi.error(
+ res.data.data?.send_error_message ?? t('common.unknownError')
+ );
+ }
+ }
+ })
+ .finally(() => {
+ testTing.current = false;
+ });
+ };
+
+ return (
+ <>
+ {messageContextHolder}
+
+
+ }
+ onClick={testDingTalkConfiguration}
+ />
+
+
+
+ >
+ );
+};
+
+export default ConfigExtraButtons;
diff --git a/packages/base/src/page/System/ProcessConnection/DingTalkSetting/components/ConfigField.tsx b/packages/base/src/page/System/ProcessConnection/DingTalkSetting/components/ConfigField.tsx
new file mode 100644
index 000000000..54dab0374
--- /dev/null
+++ b/packages/base/src/page/System/ProcessConnection/DingTalkSetting/components/ConfigField.tsx
@@ -0,0 +1,39 @@
+import { useTranslation } from 'react-i18next';
+
+import { FormItemLabel } from '@actiontech/shared/lib/components/FormCom';
+import { BasicInput } from '@actiontech/shared';
+
+const ConfigField = () => {
+ const { t } = useTranslation();
+
+ return (
+ <>
+
+
+
+
+
+
+ >
+ );
+};
+
+export default ConfigField;
diff --git a/packages/base/src/page/System/ProcessConnection/DingTalkSetting/index.tsx b/packages/base/src/page/System/ProcessConnection/DingTalkSetting/index.tsx
index 213282dfd..579399a95 100644
--- a/packages/base/src/page/System/ProcessConnection/DingTalkSetting/index.tsx
+++ b/packages/base/src/page/System/ProcessConnection/DingTalkSetting/index.tsx
@@ -1,29 +1,27 @@
-import { useCallback, useMemo, useRef } from 'react';
import { useTranslation } from 'react-i18next';
import { useBoolean, useRequest } from 'ahooks';
-import { Form, message, Space, Spin, Typography } from 'antd';
-import { BasicToolTips, BasicButton, BasicInput } from '@actiontech/shared';
+import { useCallback, useMemo } from 'react';
+
+import { Form, Spin, Typography } from 'antd';
+import { CustomLabelContent } from '@actiontech/shared/lib/components/FormCom';
+import ConfigSwitch from '../../components/ConfigSwitch';
+import ConfigExtraButtons from './components/ConfigExtraButtons';
+import ConfigField from './components/ConfigField';
+
import useConfigRender, {
ReadOnlyConfigColumnsType
} from '../../hooks/useConfigRender';
+import useConfigSwitch from '../../hooks/useConfigSwitch';
+
import configuration from '@actiontech/shared/lib/api/sqle/service/configuration';
import { IDingTalkConfigurationV1 } from '@actiontech/shared/lib/api/sqle/service/common';
import { ResponseCode } from '@actiontech/shared/lib/enum';
import { FormFields } from './index.type';
import { defaultFormData, switchFieldName } from './index.data';
-import useConfigSwitch from '../../hooks/useConfigSwitch';
-import {
- CustomLabelContent,
- FormItemLabel,
- FormItemNoLabel
-} from '@actiontech/shared/lib/components/FormCom';
-import ConfigModifyBtn from '../../components/ConfigModifyBtn';
-import { IconTest } from '../../../../icon/system';
-import ConfigSwitch from '../../components/ConfigSwitch';
+import ConfigSubmitButtonField from '../../components/ConfigSubmitButtonField';
const DingTalkSetting: React.FC = () => {
const { t } = useTranslation();
- const [messageApi, messageContextHolder] = message.useMessage();
const {
form,
renderConfigForm,
@@ -132,30 +130,6 @@ const DingTalkSetting: React.FC = () => {
handleToggleSwitch
});
- const testTing = useRef(false);
- const testDingTalkConfiguration = () => {
- if (testTing.current) {
- return;
- }
- testTing.current = true;
- configuration
- .testDingTalkConfigV1()
- .then((res) => {
- if (res.data.code === ResponseCode.SUCCESS) {
- if (res.data.data?.is_ding_talk_send_normal) {
- messageApi.success(t('dmsSystem.dingTalk.testSuccess'));
- } else {
- messageApi.error(
- res.data.data?.send_error_message ?? t('common.unknownError')
- );
- }
- }
- })
- .finally(() => {
- testTing.current = false;
- });
- };
-
const readonlyColumnsConfig: ReadOnlyConfigColumnsType =
useMemo(() => {
return [
@@ -174,26 +148,15 @@ const DingTalkSetting: React.FC = () => {
return (
- {messageContextHolder}
-
{renderConfigForm({
data: dingTalkInfo ?? {},
columns: readonlyColumnsConfig,
configExtraButtons: (
-
-
- }
- onClick={testDingTalkConfiguration}
- />
-
-
-
+
),
configSwitchNode: (
{
onSwitchPopoverOpen={onConfigSwitchPopoverOpen}
/>
),
- configField: (
- <>
-
-
-
-
-
-
- >
- ),
+ configField: ,
submitButtonField: (
-
-
-
- {t('common.cancel')}
-
-
- {t('common.submit')}
-
-
-
+
),
submit: submitDingTalkConfig
})}
diff --git a/packages/base/src/page/System/ProcessConnection/LarkAuditSetting/components/ConfigExtraButtons.tsx b/packages/base/src/page/System/ProcessConnection/LarkAuditSetting/components/ConfigExtraButtons.tsx
new file mode 100644
index 000000000..2e5b9cabb
--- /dev/null
+++ b/packages/base/src/page/System/ProcessConnection/LarkAuditSetting/components/ConfigExtraButtons.tsx
@@ -0,0 +1,191 @@
+import { useTranslation } from 'react-i18next';
+import { useRef, useState } from 'react';
+
+import {
+ Form,
+ Radio,
+ RadioGroupProps,
+ Space,
+ message as messageApi
+} from 'antd';
+import { BasicInput, EmptyBox } from '@actiontech/shared';
+import {
+ FormItemLabel,
+ FormItemNoLabel
+} from '@actiontech/shared/lib/components/FormCom';
+import ConfigTestBtn from '../../../components/ConfigTestBtn';
+import ConfigTestPopoverForm from '../../../components/ConfigTestPopoverForm';
+import ConfigModifyBtn from '../../../components/ConfigModifyBtn';
+import { formItemLayout } from '@actiontech/shared/lib/components/FormCom/style';
+
+import configuration from '@actiontech/shared/lib/api/sqle/service/configuration';
+import { TestFeishuConfigurationReqV1AccountTypeEnum } from '@actiontech/shared/lib/api/sqle/service/common.enum';
+import { phoneRule } from '@actiontech/shared/lib/utils/FormRule';
+import { TestFormFields } from '../index.type';
+import { ResponseCode } from '@actiontech/shared/lib/enum';
+
+interface ConfigExtraButtonsProps {
+ isConfigClosed: boolean;
+ extraButtonsVisible: boolean;
+ enabled: string | boolean;
+ handleClickModify: () => void;
+}
+
+const ConfigExtraButtons = ({
+ isConfigClosed,
+ extraButtonsVisible,
+ enabled,
+ handleClickModify
+}: ConfigExtraButtonsProps) => {
+ const { t } = useTranslation();
+ const [message, messageContextHolder] = messageApi.useMessage();
+
+ const [testForm] = Form.useForm();
+ const [testPopoverVisible, toggleTestPopoverVisible] = useState(false);
+ const [receiveType, setReceiveType] =
+ useState(
+ TestFeishuConfigurationReqV1AccountTypeEnum.email
+ );
+ const testing = useRef(false);
+
+ const testLarkAuditConfiguration = async () => {
+ if (testing.current) {
+ return;
+ }
+ testing.current = true;
+ toggleTestPopoverVisible(false);
+ const hide = message.loading(t('dmsSystem.larkAudit.testing'), 0);
+ const values = await testForm.validateFields();
+
+ configuration
+ .testFeishuAuditConfigV1({
+ account:
+ receiveType === TestFeishuConfigurationReqV1AccountTypeEnum.email
+ ? values.receiveEmail
+ : values.receivePhone,
+ account_type: values.receiveType
+ })
+ .then((res) => {
+ if (res.data.code === ResponseCode.SUCCESS) {
+ const resData = res.data?.data;
+
+ if (resData?.is_message_sent_normally) {
+ message.success(t('dmsSystem.larkAudit.testSuccess'));
+ } else {
+ message.error(resData?.error_message ?? t('common.unknownError'));
+ }
+ }
+ })
+ .finally(() => {
+ hide();
+ testing.current = false;
+ testForm.resetFields();
+ setReceiveType(TestFeishuConfigurationReqV1AccountTypeEnum.email);
+ });
+ };
+
+ const handleChangeReceiveType: RadioGroupProps['onChange'] = (e) => {
+ const receiveType = e.target.value;
+ setReceiveType(receiveType);
+
+ if (receiveType === TestFeishuConfigurationReqV1AccountTypeEnum.email) {
+ testForm.resetFields(['receivePhone']);
+ } else {
+ testForm.resetFields(['receiveEmail']);
+ }
+ };
+
+ const onTestPopoverOpen = (open: boolean) => {
+ if (!enabled) {
+ return;
+ }
+ if (!open) {
+ testForm.resetFields();
+ setReceiveType(TestFeishuConfigurationReqV1AccountTypeEnum.email);
+ }
+ toggleTestPopoverVisible(open);
+ };
+
+ return (
+ <>
+ {messageContextHolder}
+
+ toggleTestPopoverVisible(false)}
+ >
+
+
+ }
+ />
+
+
+ >
+ );
+};
+
+export default ConfigExtraButtons;
diff --git a/packages/base/src/page/System/ProcessConnection/LarkAuditSetting/components/ConfigField.tsx b/packages/base/src/page/System/ProcessConnection/LarkAuditSetting/components/ConfigField.tsx
new file mode 100644
index 000000000..9f847f0af
--- /dev/null
+++ b/packages/base/src/page/System/ProcessConnection/LarkAuditSetting/components/ConfigField.tsx
@@ -0,0 +1,37 @@
+import { useTranslation } from 'react-i18next';
+import { FormItemLabel } from '@actiontech/shared/lib/components/FormCom';
+import { BasicInput } from '@actiontech/shared';
+
+const ConfigField = () => {
+ const { t } = useTranslation();
+ return (
+ <>
+
+
+
+
+
+
+ >
+ );
+};
+
+export default ConfigField;
diff --git a/packages/base/src/page/System/ProcessConnection/LarkAuditSetting/index.tsx b/packages/base/src/page/System/ProcessConnection/LarkAuditSetting/index.tsx
index 6b701746b..f51328e0c 100644
--- a/packages/base/src/page/System/ProcessConnection/LarkAuditSetting/index.tsx
+++ b/packages/base/src/page/System/ProcessConnection/LarkAuditSetting/index.tsx
@@ -1,46 +1,29 @@
-import { useCallback, useMemo, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
-import {
- Form,
- Radio,
- RadioGroupProps,
- Space,
- Spin,
- Typography,
- message as messageApi
-} from 'antd';
import { useBoolean, useRequest } from 'ahooks';
-import {
- BasicButton,
- BasicInput,
- EmptyBox,
- EnterpriseFeatureDisplay
-} from '@actiontech/shared';
-import {
- CustomLabelContent,
- FormItemLabel,
- FormItemNoLabel
-} from '@actiontech/shared/lib/components/FormCom';
+import { useCallback, useMemo } from 'react';
+
+import { Form, Spin, Typography, message as messageApi } from 'antd';
+import { EnterpriseFeatureDisplay } from '@actiontech/shared';
+import ConfigSwitch from '../../components/ConfigSwitch';
+import { CustomLabelContent } from '@actiontech/shared/lib/components/FormCom';
+import ConfigField from './components/ConfigField';
+import ConfigSubmitButtonField from '../../components/ConfigSubmitButtonField';
+import ConfigExtraButtons from './components/ConfigExtraButtons';
+
+import useConfigSwitch from '../../hooks/useConfigSwitch';
import useConfigRender, {
ReadOnlyConfigColumnsType
} from '../../hooks/useConfigRender';
-import useConfigSwitch from '../../hooks/useConfigSwitch';
-import ConfigTestBtn from '../../components/ConfigTestBtn';
-import ConfigTestPopoverForm from '../../components/ConfigTestPopoverForm';
-import ConfigModifyBtn from '../../components/ConfigModifyBtn';
-import ConfigSwitch from '../../components/ConfigSwitch';
-import { ResponseCode } from '@actiontech/shared/lib/enum';
-import { FormFields, TestFormFields } from './index.type';
-import { TestFeishuConfigurationReqV1AccountTypeEnum } from '@actiontech/shared/lib/api/sqle/service/common.enum';
-import { defaultFormData, switchFieldName } from './index.data';
+
import configuration from '@actiontech/shared/lib/api/sqle/service/configuration';
+import { FormFields } from './index.type';
+import { defaultFormData, switchFieldName } from './index.data';
+import { ResponseCode } from '@actiontech/shared/lib/enum';
import { IFeishuConfigurationV1 } from '@actiontech/shared/lib/api/sqle/service/common';
-import { formItemLayout } from '@actiontech/shared/lib/components/FormCom/style';
-import { phoneRule } from '@actiontech/shared/lib/utils/FormRule';
const LarkAuditSetting: React.FC = () => {
const { t } = useTranslation();
- const [message, messageContextHolder] = messageApi.useMessage();
+
const {
form,
renderConfigForm,
@@ -151,72 +134,6 @@ const LarkAuditSetting: React.FC = () => {
handleToggleSwitch
});
- const [testForm] = Form.useForm();
- const [testPopoverVisible, toggleTestPopoverVisible] = useState(false);
- const [receiveType, setReceiveType] =
- useState(
- TestFeishuConfigurationReqV1AccountTypeEnum.email
- );
- const testing = useRef(false);
-
- const testLarkAuditConfiguration = async () => {
- if (testing.current) {
- return;
- }
- testing.current = true;
- toggleTestPopoverVisible(false);
- const hide = message.loading(t('dmsSystem.larkAudit.testing'), 0);
- const values = await testForm.validateFields();
-
- configuration
- .testFeishuAuditConfigV1({
- account:
- receiveType === TestFeishuConfigurationReqV1AccountTypeEnum.email
- ? values.receiveEmail
- : values.receivePhone,
- account_type: values.receiveType
- })
- .then((res) => {
- if (res.data.code === ResponseCode.SUCCESS) {
- const resData = res.data?.data;
-
- if (resData?.is_message_sent_normally) {
- message.success(t('dmsSystem.larkAudit.testSuccess'));
- } else {
- message.error(resData?.error_message ?? t('common.unknownError'));
- }
- }
- })
- .finally(() => {
- hide();
- testing.current = false;
- testForm.resetFields();
- setReceiveType(TestFeishuConfigurationReqV1AccountTypeEnum.email);
- });
- };
-
- const handleChangeReceiveType: RadioGroupProps['onChange'] = (e) => {
- const receiveType = e.target.value;
- setReceiveType(receiveType);
-
- if (receiveType === TestFeishuConfigurationReqV1AccountTypeEnum.email) {
- testForm.resetFields(['receivePhone']);
- } else {
- testForm.resetFields(['receiveEmail']);
- }
- };
-
- const onTestPopoverOpen = (open: boolean) => {
- if (!enabled) {
- return;
- }
- if (!open) {
- testForm.resetFields();
- setReceiveType(TestFeishuConfigurationReqV1AccountTypeEnum.email);
- }
- toggleTestPopoverVisible(open);
- };
-
const readonlyColumnsConfig: ReadOnlyConfigColumnsType =
useMemo(() => {
return [
@@ -235,8 +152,6 @@ const LarkAuditSetting: React.FC = () => {
return (
- {messageContextHolder}
-
{
data: larkAuditInfo ?? {},
columns: readonlyColumnsConfig,
configExtraButtons: (
-
- toggleTestPopoverVisible(false)}
- >
-
-
- }
- />
-
-
+
),
configSwitchNode: (
{
onSwitchPopoverOpen={onConfigSwitchPopoverOpen}
/>
),
- configField: (
- <>
-
-
-
-
-
-
- >
- ),
+ configField: ,
submitButtonField: (
-
-
-
- {t('common.cancel')}
-
-
- {t('common.submit')}
-
-
-
+
),
submit: submitLarkAuditConfig
})}
From d54c4aadd89395af59a6ee0db683e5c79a0827a5 Mon Sep 17 00:00:00 2001
From: xinbinyan <404928130@qq.com>
Date: Tue, 23 Jan 2024 14:13:49 +0800
Subject: [PATCH 04/27] case BasicTitle
---
.../__snapshots__/index.test.tsx.snap | 81 +++++++++++++++++++
.../components/BasicTitle/index.test.tsx | 27 +++++++
2 files changed, 108 insertions(+)
create mode 100644 packages/base/src/page/System/components/BasicTitle/__snapshots__/index.test.tsx.snap
create mode 100644 packages/base/src/page/System/components/BasicTitle/index.test.tsx
diff --git a/packages/base/src/page/System/components/BasicTitle/__snapshots__/index.test.tsx.snap b/packages/base/src/page/System/components/BasicTitle/__snapshots__/index.test.tsx.snap
new file mode 100644
index 000000000..5268fe619
--- /dev/null
+++ b/packages/base/src/page/System/components/BasicTitle/__snapshots__/index.test.tsx.snap
@@ -0,0 +1,81 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`base/System/components/BasicTitle render title 1`] = `
+
+
+
+`;
+
+exports[`base/System/components/BasicTitle render title when title other params 1`] = `
+
+
+
+`;
diff --git a/packages/base/src/page/System/components/BasicTitle/index.test.tsx b/packages/base/src/page/System/components/BasicTitle/index.test.tsx
new file mode 100644
index 000000000..603a248aa
--- /dev/null
+++ b/packages/base/src/page/System/components/BasicTitle/index.test.tsx
@@ -0,0 +1,27 @@
+import { renderWithTheme } from '@actiontech/shared/lib/testUtil/customRender';
+import SystemBasicTitle, { SystemBasicTitleProps } from '.';
+
+
+describe('base/System/components/BasicTitle', () => {
+ const customRender = (params: SystemBasicTitleProps) => {
+ return renderWithTheme( );
+ };
+
+ it('render title', () => {
+ const { baseElement } = customRender({
+ title: 'title cont',
+ children: child node
+ });
+ expect(baseElement).toMatchSnapshot();
+ });
+
+ it('render title when title other params', () => {
+ const { baseElement } = customRender({
+ title: 'title cont',
+ children: 'children string',
+ titleTip: 'this is title tip',
+ titleExtra: titleExtra
+ });
+ expect(baseElement).toMatchSnapshot();
+ });
+});
From e2f6c0fed1808111589c1f7715dc6422e60cc1d1 Mon Sep 17 00:00:00 2001
From: xinbinyan <404928130@qq.com>
Date: Tue, 23 Jan 2024 14:19:21 +0800
Subject: [PATCH 05/27] case ConfigModifyBtn
---
.../__snapshots__/index.test.tsx.snap | 106 ++++++++++++++++++
.../components/ConfigModifyBtn/index.test.tsx | 31 +++++
2 files changed, 137 insertions(+)
create mode 100644 packages/base/src/page/System/components/ConfigModifyBtn/__snapshots__/index.test.tsx.snap
create mode 100644 packages/base/src/page/System/components/ConfigModifyBtn/index.test.tsx
diff --git a/packages/base/src/page/System/components/ConfigModifyBtn/__snapshots__/index.test.tsx.snap b/packages/base/src/page/System/components/ConfigModifyBtn/__snapshots__/index.test.tsx.snap
new file mode 100644
index 000000000..a12e0b749
--- /dev/null
+++ b/packages/base/src/page/System/components/ConfigModifyBtn/__snapshots__/index.test.tsx.snap
@@ -0,0 +1,106 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`base/System/components/ConfigModifyBtn render snap 1`] = `
+
+
+
+`;
+
+exports[`base/System/components/ConfigModifyBtn render snap 2`] = `
+
+
+
+
+`;
diff --git a/packages/base/src/page/System/components/ConfigModifyBtn/index.test.tsx b/packages/base/src/page/System/components/ConfigModifyBtn/index.test.tsx
new file mode 100644
index 000000000..106941113
--- /dev/null
+++ b/packages/base/src/page/System/components/ConfigModifyBtn/index.test.tsx
@@ -0,0 +1,31 @@
+import { cleanup, fireEvent, act } from '@testing-library/react';
+import { renderWithTheme } from '@actiontech/shared/lib/testUtil/customRender';
+import { getBySelector } from '@actiontech/shared/lib/testUtil/customQuery';
+
+import ConfigModifyBtn from '.';
+
+describe('base/System/components/ConfigModifyBtn', () => {
+ beforeEach(() => {
+ jest.useFakeTimers();
+ });
+
+ afterEach(() => {
+ jest.useRealTimers();
+ cleanup();
+ });
+
+ it('render snap', async () => {
+ const onClickFn = jest.fn();
+ const { baseElement } = renderWithTheme( );
+ expect(baseElement).toMatchSnapshot();
+
+ const btnEle = getBySelector('.ant-btn', baseElement);
+
+ fireEvent.mouseOver(btnEle);
+ await act(async () => jest.advanceTimersByTime(500));
+ expect(baseElement).toMatchSnapshot();
+
+ fireEvent.click(btnEle);
+ expect(onClickFn).toBeCalled();
+ })
+});
From cbb48fe8764681c7607dd80fa3764a1047d0977e Mon Sep 17 00:00:00 2001
From: xinbinyan <404928130@qq.com>
Date: Tue, 23 Jan 2024 14:27:07 +0800
Subject: [PATCH 06/27] case ConfigSubmitButtonField
---
.../__snapshots__/index.test.tsx.snap | 158 ++++++++++++++++++
.../ConfigSubmitButtonField/index.test.tsx | 39 +++++
2 files changed, 197 insertions(+)
create mode 100644 packages/base/src/page/System/components/ConfigSubmitButtonField/__snapshots__/index.test.tsx.snap
create mode 100644 packages/base/src/page/System/components/ConfigSubmitButtonField/index.test.tsx
diff --git a/packages/base/src/page/System/components/ConfigSubmitButtonField/__snapshots__/index.test.tsx.snap b/packages/base/src/page/System/components/ConfigSubmitButtonField/__snapshots__/index.test.tsx.snap
new file mode 100644
index 000000000..2b8acb8f3
--- /dev/null
+++ b/packages/base/src/page/System/components/ConfigSubmitButtonField/__snapshots__/index.test.tsx.snap
@@ -0,0 +1,158 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`base/System/components/ConfigSubmitButtonField render snap when submit is false 1`] = `
+
+
+
+`;
+
+exports[`base/System/components/ConfigSubmitButtonField render snap when submit is true 1`] = `
+
+
+
+`;
diff --git a/packages/base/src/page/System/components/ConfigSubmitButtonField/index.test.tsx b/packages/base/src/page/System/components/ConfigSubmitButtonField/index.test.tsx
new file mode 100644
index 000000000..b535844da
--- /dev/null
+++ b/packages/base/src/page/System/components/ConfigSubmitButtonField/index.test.tsx
@@ -0,0 +1,39 @@
+import { cleanup, fireEvent, act, screen } from '@testing-library/react';
+import { renderWithTheme } from '@actiontech/shared/lib/testUtil/customRender';
+
+import ConfigSubmitButtonField from '.';
+
+describe('base/System/components/ConfigSubmitButtonField', () => {
+ const handleClickCancelFn = jest.fn();
+ const customRender = (submitLoading: boolean) => {
+ return renderWithTheme( );
+ }
+
+ beforeEach(() => {
+ jest.useFakeTimers();
+ });
+
+ afterEach(() => {
+ jest.useRealTimers();
+ cleanup();
+ });
+
+ it('render snap when submit is true', () => {
+ const { baseElement } = customRender(true);
+ expect(baseElement).toMatchSnapshot();
+ });
+
+ it('render snap when submit is false', () => {
+ const { baseElement } = customRender(false);
+ expect(baseElement).toMatchSnapshot();
+ });
+
+ it('render snap when click cancel', async () => {
+ customRender(false);
+
+ expect(screen.getByText('取 消')).toBeInTheDocument();
+ fireEvent.click(screen.getByText('取 消'));
+ await act(async () => jest.advanceTimersByTime(500));
+ expect(handleClickCancelFn).toBeCalled();
+ })
+});
From 7c8ba26839ecfb2b34a47bcb899f66e11da4551b Mon Sep 17 00:00:00 2001
From: xinbinyan <404928130@qq.com>
Date: Tue, 23 Jan 2024 14:42:40 +0800
Subject: [PATCH 07/27] case ConfigSwitch
---
.../__snapshots__/index.test.tsx.snap | 275 ++++++++++++++++++
.../components/ConfigSwitch/index.test.tsx | 86 ++++++
.../System/components/ConfigSwitch/index.tsx | 2 +-
3 files changed, 362 insertions(+), 1 deletion(-)
create mode 100644 packages/base/src/page/System/components/ConfigSwitch/__snapshots__/index.test.tsx.snap
create mode 100644 packages/base/src/page/System/components/ConfigSwitch/index.test.tsx
diff --git a/packages/base/src/page/System/components/ConfigSwitch/__snapshots__/index.test.tsx.snap b/packages/base/src/page/System/components/ConfigSwitch/__snapshots__/index.test.tsx.snap
new file mode 100644
index 000000000..735cfe111
--- /dev/null
+++ b/packages/base/src/page/System/components/ConfigSwitch/__snapshots__/index.test.tsx.snap
@@ -0,0 +1,275 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`base/System/components/ConfigSwitch render snap when modifyFlag is false 1`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Cancel
+
+
+
+
+ OK
+
+
+
+
+
+
+
+
+
+
+`;
+
+exports[`base/System/components/ConfigSwitch render snap when switch disabled 1`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 关闭配置后当前的编辑信息将不会被保留,是否确认关闭配置?
+
+
+
+
+
+
+ Cancel
+
+
+
+
+ OK
+
+
+
+
+
+
+
+
+
+
+`;
diff --git a/packages/base/src/page/System/components/ConfigSwitch/index.test.tsx b/packages/base/src/page/System/components/ConfigSwitch/index.test.tsx
new file mode 100644
index 000000000..778a40c28
--- /dev/null
+++ b/packages/base/src/page/System/components/ConfigSwitch/index.test.tsx
@@ -0,0 +1,86 @@
+import { cleanup, fireEvent, act, screen } from '@testing-library/react';
+import { renderWithTheme } from '@actiontech/shared/lib/testUtil/customRender';
+import ConfigSwitch, { ConfigSwitchParams } from '.';
+import Form from 'antd/es/form/Form';
+import { getBySelector } from '@actiontech/shared/lib/testUtil/customQuery';
+
+describe('base/System/components/ConfigSwitch', () => {
+ const onConfirmFn = jest.fn();
+ const onSwitchChangeFn = jest.fn();
+ const onSwitchPopoverOpenFn = jest.fn();
+ const customRender = (
+ params: Omit<
+ ConfigSwitchParams,
+ 'switchFieldName' | 'onConfirm' | 'onSwitchChange' | 'onSwitchPopoverOpen'
+ >
+ ) => {
+ return renderWithTheme(
+
+ );
+ };
+
+ beforeEach(() => {
+ jest.useFakeTimers();
+ });
+
+ afterEach(() => {
+ jest.useRealTimers();
+ cleanup();
+ });
+
+ it('render snap when switch disabled', () => {
+ const { baseElement } = customRender({
+ switchOpen: false,
+ modifyFlag: true,
+ submitLoading: true,
+ popoverVisible: true
+ });
+ expect(baseElement).toMatchSnapshot();
+ });
+
+ it('render snap when modifyFlag is false', () => {
+ const { baseElement } = customRender({
+ switchOpen: false,
+ modifyFlag: false,
+ submitLoading: true,
+ popoverVisible: true
+ });
+ expect(baseElement).toMatchSnapshot();
+ });
+
+ it('render snap when confirm popover', async () => {
+ customRender({
+ switchOpen: false,
+ modifyFlag: false,
+ submitLoading: false,
+ popoverVisible: true
+ });
+ expect(screen.getByText('是否确认关闭当前配置?')).toBeInTheDocument();
+ expect(screen.getByText('OK')).toBeInTheDocument();
+ fireEvent.click(screen.getByText('OK'));
+ await act(async () => jest.advanceTimersByTime(500));
+ expect(onConfirmFn).toBeCalled();
+ });
+
+ it('render snap when click switch', async () => {
+ const { baseElement } = customRender({
+ switchOpen: false,
+ modifyFlag: false,
+ submitLoading: false,
+ popoverVisible: false
+ });
+
+ const switchHandle = getBySelector('.ant-switch-handle', baseElement);
+ fireEvent.click(switchHandle);
+ await act(async () => jest.advanceTimersByTime(500));
+ expect(onSwitchChangeFn).toBeCalled();
+ })
+});
diff --git a/packages/base/src/page/System/components/ConfigSwitch/index.tsx b/packages/base/src/page/System/components/ConfigSwitch/index.tsx
index 0d212f188..c7d94954d 100644
--- a/packages/base/src/page/System/components/ConfigSwitch/index.tsx
+++ b/packages/base/src/page/System/components/ConfigSwitch/index.tsx
@@ -3,7 +3,7 @@ import { useTranslation } from 'react-i18next';
import { FormItemLabel } from '@actiontech/shared/lib/components/FormCom';
import { BasicSwitch } from '@actiontech/shared';
-interface ConfigSwitchParams {
+export interface ConfigSwitchParams {
switchFieldName: string;
switchOpen?: boolean;
modifyFlag: boolean;
From ecb7c7004deac866ac73447fab30e599ded82870 Mon Sep 17 00:00:00 2001
From: xinbinyan <404928130@qq.com>
Date: Tue, 23 Jan 2024 15:19:16 +0800
Subject: [PATCH 08/27] case ConfigTestBtn
---
.../__snapshots__/index.test.tsx.snap | 218 ++++++++++++++++++
.../components/ConfigTestBtn/index.test.tsx | 55 +++++
2 files changed, 273 insertions(+)
create mode 100644 packages/base/src/page/System/components/ConfigTestBtn/__snapshots__/index.test.tsx.snap
create mode 100644 packages/base/src/page/System/components/ConfigTestBtn/index.test.tsx
diff --git a/packages/base/src/page/System/components/ConfigTestBtn/__snapshots__/index.test.tsx.snap b/packages/base/src/page/System/components/ConfigTestBtn/__snapshots__/index.test.tsx.snap
new file mode 100644
index 000000000..2c0f6aa2c
--- /dev/null
+++ b/packages/base/src/page/System/components/ConfigTestBtn/__snapshots__/index.test.tsx.snap
@@ -0,0 +1,218 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`base/System/components/ConfigTestBtn render snap when Popover cont show 1`] = `
+
+
+
+
+`;
+
+exports[`base/System/components/ConfigTestBtn render snap when btn hover 1`] = `
+
+
+
+
+`;
+
+exports[`base/System/components/ConfigTestBtn render snap when btn is default 1`] = `
+
+
+
+`;
+
+exports[`base/System/components/ConfigTestBtn render snap when btn is loading 1`] = `
+
+
+
+`;
diff --git a/packages/base/src/page/System/components/ConfigTestBtn/index.test.tsx b/packages/base/src/page/System/components/ConfigTestBtn/index.test.tsx
new file mode 100644
index 000000000..5ffc41f8f
--- /dev/null
+++ b/packages/base/src/page/System/components/ConfigTestBtn/index.test.tsx
@@ -0,0 +1,55 @@
+import { cleanup, fireEvent, act, screen } from '@testing-library/react';
+import { renderWithTheme } from '@actiontech/shared/lib/testUtil/customRender';
+import ConfigTestBtn from '.';
+import { getBySelector } from '@actiontech/shared/lib/testUtil/customQuery';
+
+describe('base/System/components/ConfigTestBtn', () => {
+ const onPopoverOpenChangeFn = jest.fn();
+ const testingRef = jest.fn();
+
+ const customRender = (popoverOpen = false) => {
+ return renderWithTheme(
+ popoverForm}
+ testingRef={testingRef()}
+ />
+ );
+ };
+
+ beforeEach(() => {
+ jest.useFakeTimers();
+ testingRef.mockImplementation(() => ({ current: false }));
+ });
+
+ afterEach(() => {
+ jest.useRealTimers();
+ cleanup();
+ });
+
+ it('render snap when btn is default', () => {
+ const { baseElement } = customRender(false);
+ expect(baseElement).toMatchSnapshot();
+ });
+
+ it('render snap when btn is loading', () => {
+ testingRef.mockImplementation(() => ({ current: true }));
+ const { baseElement } = customRender(false);
+ expect(baseElement).toMatchSnapshot();
+ });
+
+ it('render snap when btn hover', async () => {
+ const { baseElement } = customRender(false);
+
+ const btnEle = getBySelector('.ant-btn[type="submit"]');
+ fireEvent.mouseOver(btnEle);
+ await act(async () => jest.advanceTimersByTime(500));
+ expect(baseElement).toMatchSnapshot();
+ });
+
+ it('render snap when Popover cont show', async () => {
+ const { baseElement } = customRender(true);
+ expect(baseElement).toMatchSnapshot();
+ });
+});
From d9b159ce32453953c9aac0dc5713e356770a8060 Mon Sep 17 00:00:00 2001
From: xinbinyan <404928130@qq.com>
Date: Tue, 23 Jan 2024 15:25:18 +0800
Subject: [PATCH 09/27] case ConfigTestPopoverForm
---
.../__snapshots__/index.test.tsx.snap | 62 +++++++++++++++++++
.../ConfigTestPopoverForm/index.test.tsx | 48 ++++++++++++++
2 files changed, 110 insertions(+)
create mode 100644 packages/base/src/page/System/components/ConfigTestPopoverForm/__snapshots__/index.test.tsx.snap
create mode 100644 packages/base/src/page/System/components/ConfigTestPopoverForm/index.test.tsx
diff --git a/packages/base/src/page/System/components/ConfigTestPopoverForm/__snapshots__/index.test.tsx.snap b/packages/base/src/page/System/components/ConfigTestPopoverForm/__snapshots__/index.test.tsx.snap
new file mode 100644
index 000000000..362fa005f
--- /dev/null
+++ b/packages/base/src/page/System/components/ConfigTestPopoverForm/__snapshots__/index.test.tsx.snap
@@ -0,0 +1,62 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`base/System/components/ConfigTestPopoverForm render snap 1`] = `
+
+
+
+
+
+ this is a children node
+
+
+
+
+
+
+
+
+
+ 取 消
+
+
+
+
+
+
+ 确 认
+
+
+
+
+
+
+
+
+
+
+`;
diff --git a/packages/base/src/page/System/components/ConfigTestPopoverForm/index.test.tsx b/packages/base/src/page/System/components/ConfigTestPopoverForm/index.test.tsx
new file mode 100644
index 000000000..1999ec230
--- /dev/null
+++ b/packages/base/src/page/System/components/ConfigTestPopoverForm/index.test.tsx
@@ -0,0 +1,48 @@
+import { cleanup, fireEvent, act, screen } from '@testing-library/react';
+import { renderWithTheme } from '@actiontech/shared/lib/testUtil/customRender';
+
+import ConfigTestPopoverForm from '.';
+
+describe('base/System/components/ConfigTestPopoverForm', () => {
+ const handleTestFn = jest.fn();
+ const handleCancelFn = jest.fn();
+ const customRender = () => {
+ return renderWithTheme(
+ this is a children node }
+ />
+ );
+ };
+
+ beforeEach(() => {
+ jest.useFakeTimers();
+ });
+
+ afterEach(() => {
+ jest.useRealTimers();
+ cleanup();
+ });
+
+ it('render snap', () => {
+ const { baseElement } = customRender();
+ expect(baseElement).toMatchSnapshot();
+ });
+
+ it('render snap when click cancel btn', async () => {
+ customRender();
+
+ expect(screen.getByText('取 消')).toBeInTheDocument();
+ fireEvent.click(screen.getByText('取 消'));
+ expect(handleCancelFn).toBeCalled();
+ });
+
+ it('render snap when click submit btn', async () => {
+ customRender();
+
+ expect(screen.getByText('确 认')).toBeInTheDocument();
+ fireEvent.click(screen.getByText('确 认'));
+ expect(handleTestFn).toBeCalled();
+ });
+});
From edbcff836bb68881d37c13a78737748c90ad37f8 Mon Sep 17 00:00:00 2001
From: xinbinyan <404928130@qq.com>
Date: Tue, 23 Jan 2024 15:26:24 +0800
Subject: [PATCH 10/27] delete no used code
---
.../LarkSetting/index copy.tsx | 395 ------------------
1 file changed, 395 deletions(-)
delete mode 100644 packages/base/src/page/System/PushNotification/LarkSetting/index copy.tsx
diff --git a/packages/base/src/page/System/PushNotification/LarkSetting/index copy.tsx b/packages/base/src/page/System/PushNotification/LarkSetting/index copy.tsx
deleted file mode 100644
index b6d714d35..000000000
--- a/packages/base/src/page/System/PushNotification/LarkSetting/index copy.tsx
+++ /dev/null
@@ -1,395 +0,0 @@
-import { useBoolean, useRequest } from 'ahooks';
-import {
- Form,
- message,
- Radio,
- RadioGroupProps,
- Space,
- Spin,
- Typography
-} from 'antd';
-import { useForm } from 'antd/es/form/Form';
-import { useCallback, useMemo, useRef, useState } from 'react';
-import { useTranslation } from 'react-i18next';
-import { FormFields, TestFormFields } from './index.type';
-import { BasicButton, BasicInput, EmptyBox } from '@actiontech/shared';
-import { phoneRule } from '@actiontech/shared/lib/utils/FormRule';
-import { ResponseCode } from '@actiontech/shared/lib/enum';
-import { TestFeishuConfigurationAccountTypeEnum } from '@actiontech/shared/lib/api/base/service/common.enum';
-import useConfigSwitch from '../../hooks/useConfigSwitch';
-import useConfigRender, {
- ReadOnlyConfigColumnsType
-} from '../../hooks/useConfigRender';
-import ConfigTestBtn from '../../components/ConfigTestBtn';
-import ConfigTestPopoverForm from '../../components/ConfigTestPopoverForm';
-import ConfigModifyBtn from '../../components/ConfigModifyBtn';
-import ConfigSwitch from '../../components/ConfigSwitch';
-import {
- FormItemLabel,
- FormItemNoLabel
-} from '@actiontech/shared/lib/components/FormCom';
-import { formItemLayout } from '@actiontech/shared/lib/components/FormCom/style';
-import dms from '@actiontech/shared/lib/api/base/service/dms';
-import { IFeishuConfigurationResData } from '@actiontech/shared/lib/api/base/service/common';
-import { switchFieldName } from './index.data';
-
-const LarkSetting: React.FC = () => {
- const { t } = useTranslation();
- const [messageApi, messageContextHolder] = message.useMessage();
-
- const {
- form,
- renderConfigForm,
- startModify,
- modifyFinish,
- modifyFlag,
- extraButtonsVisible,
- enabled
- } = useConfigRender({
- switchFieldName,
- switchFieldLabel: t('dmsSystem.lark.enable')
- });
-
- const [submitLoading, { setTrue: startSubmit, setFalse: submitFinish }] =
- useBoolean();
-
- const {
- data: larkInfo,
- loading,
- refresh: refreshLarkInfo
- } = useRequest(
- () => dms.GetFeishuConfiguration().then((res) => res.data?.data ?? {}),
- {
- onSuccess(res) {
- if (res) {
- form.setFieldsValue({
- enabled: !!res.is_feishu_notification_enabled
- });
- }
- }
- }
- );
- const isConfigClosed = useMemo(() => {
- return !larkInfo?.is_feishu_notification_enabled;
- }, [larkInfo]);
-
- const setFormDefaultValue = useCallback(() => {
- form.setFieldsValue({
- appKey: larkInfo?.app_id,
- appSecret: undefined
- });
- }, [form, larkInfo]);
-
- const handleClickModify = () => {
- setFormDefaultValue();
- startModify();
- };
- const handleClickCancel = () => {
- if (isConfigClosed) form.setFieldsValue({ [switchFieldName]: false });
- setFormDefaultValue();
- modifyFinish();
- };
- const handleToggleSwitch = (open: boolean) => {
- form.setFieldValue(switchFieldName, open);
- };
-
- const submitLarkConfig = (values: FormFields) => {
- startSubmit();
- dms
- .UpdateFeishuConfiguration({
- update_feishu_configuration: {
- is_feishu_notification_enabled: values.enabled,
- app_id: values.appKey,
- app_secret: values.appSecret
- }
- })
- .then((res) => {
- if (res.data.code === ResponseCode.SUCCESS) {
- modifyFinish();
- refreshLarkInfo();
- form.resetFields();
- }
- })
- .finally(() => {
- submitFinish();
- });
- };
-
- const switchOpen = Form.useWatch(switchFieldName, form);
-
- const {
- configSwitchPopoverVisible,
- onConfigSwitchPopoverOpen,
- onConfigSwitchPopoverConfirm,
- onConfigSwitchChange
- } = useConfigSwitch({
- isConfigClosed,
- switchOpen,
- modifyFlag,
- startSubmit,
- submitFinish,
- handleClickModify,
- handleUpdateConfig: () =>
- dms.UpdateFeishuConfiguration({
- update_feishu_configuration: {
- ...larkInfo,
- is_feishu_notification_enabled: false
- }
- }),
- handleClickCancel,
- refreshConfig: refreshLarkInfo,
- handleToggleSwitch
- });
-
- const [testPopoverVisible, toggleTestPopoverVisible] = useState(false);
- const [testForm] = useForm();
- const [receiveType, setReceiveType] =
- useState(
- TestFeishuConfigurationAccountTypeEnum.email
- );
- const testing = useRef(false);
- const testLarkConfiguration = async () => {
- if (testing.current) {
- return;
- }
- const values = await testForm.validateFields();
- testing.current = true;
- toggleTestPopoverVisible(false);
- const hide = messageApi.loading(t('dmsSystem.lark.testing'), 0);
- dms
- .TestFeishuConfiguration({
- test_feishu_configuration: {
- account:
- receiveType === TestFeishuConfigurationAccountTypeEnum.email
- ? values.receiveEmail
- : values.receivePhone,
- account_type: values.receiveType
- }
- })
- .then((res) => {
- if (res.data.code === ResponseCode.SUCCESS) {
- const resData = res.data?.data;
- if (resData?.is_message_sent_normally) {
- messageApi.success(t('dmsSystem.lark.testSuccess'));
- } else {
- messageApi.error(
- resData?.error_message ?? t('common.unknownError')
- );
- }
- }
- })
- .finally(() => {
- hide();
- testing.current = false;
- testForm.resetFields();
- setReceiveType(TestFeishuConfigurationAccountTypeEnum.email);
- });
- };
- const onTestPopoverOpen = (open: boolean) => {
- if (!enabled) {
- return;
- }
- if (!open) {
- testForm.resetFields();
- setReceiveType(TestFeishuConfigurationAccountTypeEnum.email);
- }
- toggleTestPopoverVisible(open);
- };
-
- const handleChangeReceiveType: RadioGroupProps['onChange'] = (e) => {
- const receiveType = e.target.value;
- setReceiveType(receiveType);
-
- if (receiveType === TestFeishuConfigurationAccountTypeEnum.email) {
- testForm.resetFields(['receivePhone']);
- } else {
- testForm.resetFields(['receiveEmail']);
- }
- };
-
- const readonlyColumnsConfig: ReadOnlyConfigColumnsType =
- useMemo(() => {
- return [
- {
- label: 'App ID',
- span: 3,
- dataIndex: 'app_id',
- hidden: !larkInfo?.is_feishu_notification_enabled,
- render: (val) => (
- {val || '--'}
- )
- }
- ];
- }, [larkInfo]);
-
- return (
-
-
- {messageContextHolder}
-
- {renderConfigForm({
- data: larkInfo ?? {},
- columns: readonlyColumnsConfig,
- configExtraButtons: (
-
- toggleTestPopoverVisible(false)}
- >
-
-
- }
- />
-
-
- ),
- configSwitchNode: (
-
- ),
- configField: (
- <>
-
-
-
-
-
-
- >
- ),
- submitButtonField: (
-
-
-
- {t('common.cancel')}
-
-
- {t('common.submit')}
-
-
-
- ),
- submit: submitLarkConfig
- })}
-
-
- );
-};
-
-export default LarkSetting;
From 7cf4f33271c0fb51876fe34e4433114e32ec61cc Mon Sep 17 00:00:00 2001
From: xinbinyan <404928130@qq.com>
Date: Tue, 23 Jan 2024 16:34:38 +0800
Subject: [PATCH 11/27] case LarkSetting components
---
.../conponents/ConfigExtraButtons.test.tsx | 155 ++++
.../conponents/ConfigExtraButtons.tsx | 2 +-
.../conponents/ConfigField.test.tsx | 13 +
.../ConfigExtraButtons.test.tsx.snap | 741 ++++++++++++++++++
.../ConfigTestPopoverForm/index.test.tsx | 2 +-
5 files changed, 911 insertions(+), 2 deletions(-)
create mode 100644 packages/base/src/page/System/PushNotification/LarkSetting/conponents/ConfigExtraButtons.test.tsx
create mode 100644 packages/base/src/page/System/PushNotification/LarkSetting/conponents/ConfigField.test.tsx
create mode 100644 packages/base/src/page/System/PushNotification/LarkSetting/conponents/__snapshots__/ConfigExtraButtons.test.tsx.snap
diff --git a/packages/base/src/page/System/PushNotification/LarkSetting/conponents/ConfigExtraButtons.test.tsx b/packages/base/src/page/System/PushNotification/LarkSetting/conponents/ConfigExtraButtons.test.tsx
new file mode 100644
index 000000000..f33d65d25
--- /dev/null
+++ b/packages/base/src/page/System/PushNotification/LarkSetting/conponents/ConfigExtraButtons.test.tsx
@@ -0,0 +1,155 @@
+import ConfigExtraButtons, {
+ ConfigExtraButtonsProps
+} from './ConfigExtraButtons';
+
+import { cleanup, fireEvent, act, screen } from '@testing-library/react';
+import { renderWithTheme } from '@actiontech/shared/lib/testUtil/customRender';
+import { getBySelector } from '@actiontech/shared/lib/testUtil/customQuery';
+
+import system from '../../../../../testUtils/mockApi/system';
+import { TestFeishuConfigurationAccountTypeEnum } from '@actiontech/shared/lib/api/base/service/common.enum';
+import { createSpyErrorResponse } from '@actiontech/shared/lib/testUtil/mockApi';
+
+describe('base/System/PushNotification/LarkSetting/ConfigExtraButtons', () => {
+ let requestTestFeishuConfiguration: jest.SpyInstance;
+ const handleClickModifyFn = jest.fn();
+ const customRender = (
+ params: Omit
+ ) => {
+ return renderWithTheme(
+
+ );
+ };
+
+ beforeEach(() => {
+ jest.useFakeTimers();
+ requestTestFeishuConfiguration = system.testLarkConfig();
+ });
+
+ afterEach(() => {
+ jest.useRealTimers();
+ jest.clearAllMocks();
+ cleanup();
+ });
+
+ describe('render snap when hidden val is true', () => {
+ it('render isConfigClosed is true', () => {
+ const { baseElement } = customRender({
+ isConfigClosed: true,
+ extraButtonsVisible: true,
+ enabled: false
+ });
+ expect(baseElement).toMatchSnapshot();
+ });
+ it('render extraButtonsVisible is false', () => {
+ const { baseElement } = customRender({
+ isConfigClosed: false,
+ extraButtonsVisible: false,
+ enabled: false
+ });
+ expect(baseElement).toMatchSnapshot();
+ });
+ });
+
+ describe('render snap form', () => {
+ it('render popover cancel btn', async () => {
+ const { baseElement } = customRender({
+ isConfigClosed: false,
+ extraButtonsVisible: true,
+ enabled: true
+ });
+
+ const btnPopoverOpen = getBySelector(
+ '.ant-btn[type="submit"]',
+ baseElement
+ );
+ fireEvent.click(btnPopoverOpen);
+ await act(async () => jest.advanceTimersByTime(500));
+ expect(screen.getByText('取 消')).toBeInTheDocument();
+ await act(async () => jest.advanceTimersByTime(300));
+ expect(baseElement).toMatchSnapshot();
+ });
+
+ it('render form validate', async () => {
+ const { baseElement } = customRender({
+ isConfigClosed: false,
+ extraButtonsVisible: true,
+ enabled: true
+ });
+
+ const btnPopoverOpen = getBySelector(
+ '.ant-btn[type="submit"]',
+ baseElement
+ );
+ fireEvent.click(btnPopoverOpen);
+ await act(async () => jest.advanceTimersByTime(500));
+ expect(baseElement).toMatchSnapshot();
+
+ expect(
+ getBySelector('input[ placeholder="请输入邮箱"]', baseElement)
+ ).toBeInTheDocument();
+ expect(screen.getByText('手机号')).toBeInTheDocument();
+ fireEvent.click(screen.getByText('手机号'));
+ await act(async () => jest.advanceTimersByTime(500));
+ expect(
+ getBySelector('input[ placeholder="请输入手机号"]', baseElement)
+ ).toBeInTheDocument();
+
+ fireEvent.change(getBySelector('#receivePhone', baseElement), {
+ target: {
+ value: '15115215134'
+ }
+ });
+ await act(async () => jest.advanceTimersByTime(500));
+
+ expect(screen.getByText('确 认')).toBeInTheDocument();
+ fireEvent.click(screen.getByText('确 认'));
+ await act(async () => jest.advanceTimersByTime(300));
+ expect(screen.getByText('正在向飞书推送消息...')).toBeInTheDocument();
+ await act(async () => jest.advanceTimersByTime(3000));
+ expect(requestTestFeishuConfiguration).toBeCalled();
+ expect(requestTestFeishuConfiguration).toBeCalledWith({
+ test_feishu_configuration: {
+ account: '15115215134',
+ account_type: TestFeishuConfigurationAccountTypeEnum.phone
+ }
+ });
+ expect(screen.getByText('已成功将消息推送至指定账号')).toBeInTheDocument();
+ });
+
+ it('render form when api error', async () => {
+ requestTestFeishuConfiguration.mockImplementation(() =>
+ createSpyErrorResponse({ error_message: 'error info' })
+ );
+ const { baseElement } = customRender({
+ isConfigClosed: false,
+ extraButtonsVisible: true,
+ enabled: true
+ });
+
+ const btnPopoverOpen = getBySelector(
+ '.ant-btn[type="submit"]',
+ baseElement
+ );
+ fireEvent.click(btnPopoverOpen);
+ await act(async () => jest.advanceTimersByTime(500));
+
+ fireEvent.change(getBySelector('#receiveEmail', baseElement), {
+ target: {
+ value: '1@q.com'
+ }
+ });
+ await act(async () => jest.advanceTimersByTime(500));
+
+ fireEvent.click(screen.getByText('确 认'));
+ await act(async () => jest.advanceTimersByTime(3300));
+ expect(requestTestFeishuConfiguration).toBeCalled();
+ expect(requestTestFeishuConfiguration).toBeCalledWith({
+ test_feishu_configuration: {
+ account: '1@q.com',
+ account_type: TestFeishuConfigurationAccountTypeEnum.email
+ }
+ });
+ });
+ })
+});
diff --git a/packages/base/src/page/System/PushNotification/LarkSetting/conponents/ConfigExtraButtons.tsx b/packages/base/src/page/System/PushNotification/LarkSetting/conponents/ConfigExtraButtons.tsx
index 9da13b4e2..6fd0e5c04 100644
--- a/packages/base/src/page/System/PushNotification/LarkSetting/conponents/ConfigExtraButtons.tsx
+++ b/packages/base/src/page/System/PushNotification/LarkSetting/conponents/ConfigExtraButtons.tsx
@@ -20,7 +20,7 @@ import { ResponseCode } from '@actiontech/shared/lib/enum';
import { TestFormFields } from '../index.type';
import { TestFeishuConfigurationAccountTypeEnum } from '@actiontech/shared/lib/api/base/service/common.enum';
-interface ConfigExtraButtonsProps {
+export interface ConfigExtraButtonsProps {
enabled: string | boolean;
isConfigClosed: boolean;
extraButtonsVisible: boolean;
diff --git a/packages/base/src/page/System/PushNotification/LarkSetting/conponents/ConfigField.test.tsx b/packages/base/src/page/System/PushNotification/LarkSetting/conponents/ConfigField.test.tsx
new file mode 100644
index 000000000..f672930a4
--- /dev/null
+++ b/packages/base/src/page/System/PushNotification/LarkSetting/conponents/ConfigField.test.tsx
@@ -0,0 +1,13 @@
+import { renderWithTheme } from '@actiontech/shared/lib/testUtil/customRender';
+
+import { Form } from 'antd';
+import ConfigField from './ConfigField';
+
+describe('base/System/PushNotification/LarkSetting/ConfigField', () => {
+ it('render snap', () => {
+ const { baseElement } = renderWithTheme();
+ expect(baseElement).toMatchSnapshot();
+ });
+});
diff --git a/packages/base/src/page/System/PushNotification/LarkSetting/conponents/__snapshots__/ConfigExtraButtons.test.tsx.snap b/packages/base/src/page/System/PushNotification/LarkSetting/conponents/__snapshots__/ConfigExtraButtons.test.tsx.snap
new file mode 100644
index 000000000..02b57800c
--- /dev/null
+++ b/packages/base/src/page/System/PushNotification/LarkSetting/conponents/__snapshots__/ConfigExtraButtons.test.tsx.snap
@@ -0,0 +1,741 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`base/System/PushNotification/LarkSetting/ConfigExtraButtons render snap form render form validate 1`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 取 消
+
+
+
+
+
+
+ 确 认
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+`;
+
+exports[`base/System/PushNotification/LarkSetting/ConfigExtraButtons render snap form render popover cancel btn 1`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 取 消
+
+
+
+
+
+
+ 确 认
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+`;
+
+exports[`base/System/PushNotification/LarkSetting/ConfigExtraButtons render snap when hidden val is true render extraButtonsVisible is false 1`] = `
+
+
+
+`;
+
+exports[`base/System/PushNotification/LarkSetting/ConfigExtraButtons render snap when hidden val is true render isConfigClosed is true 1`] = `
+
+
+
+`;
diff --git a/packages/base/src/page/System/components/ConfigTestPopoverForm/index.test.tsx b/packages/base/src/page/System/components/ConfigTestPopoverForm/index.test.tsx
index 1999ec230..abdaf2764 100644
--- a/packages/base/src/page/System/components/ConfigTestPopoverForm/index.test.tsx
+++ b/packages/base/src/page/System/components/ConfigTestPopoverForm/index.test.tsx
@@ -1,4 +1,4 @@
-import { cleanup, fireEvent, act, screen } from '@testing-library/react';
+import { cleanup, fireEvent, screen } from '@testing-library/react';
import { renderWithTheme } from '@actiontech/shared/lib/testUtil/customRender';
import ConfigTestPopoverForm from '.';
From f8a4454754547bf84cc7f6a36878dd129e810747 Mon Sep 17 00:00:00 2001
From: xinbinyan <404928130@qq.com>
Date: Tue, 23 Jan 2024 17:05:20 +0800
Subject: [PATCH 12/27] init case LarkSetting
---
.../LarkAuditSetting/index.tsx | 2 +-
.../__snapshots__/index.test.tsx.snap | 2317 +++++++++++++++++
.../__snapshots__/ConfigField.test.tsx.snap | 121 +
.../LarkSetting/index.test.tsx | 93 +
4 files changed, 2532 insertions(+), 1 deletion(-)
create mode 100644 packages/base/src/page/System/PushNotification/LarkSetting/__snapshots__/index.test.tsx.snap
create mode 100644 packages/base/src/page/System/PushNotification/LarkSetting/conponents/__snapshots__/ConfigField.test.tsx.snap
create mode 100644 packages/base/src/page/System/PushNotification/LarkSetting/index.test.tsx
diff --git a/packages/base/src/page/System/ProcessConnection/LarkAuditSetting/index.tsx b/packages/base/src/page/System/ProcessConnection/LarkAuditSetting/index.tsx
index f51328e0c..9d85f3846 100644
--- a/packages/base/src/page/System/ProcessConnection/LarkAuditSetting/index.tsx
+++ b/packages/base/src/page/System/ProcessConnection/LarkAuditSetting/index.tsx
@@ -2,7 +2,7 @@ import { useTranslation } from 'react-i18next';
import { useBoolean, useRequest } from 'ahooks';
import { useCallback, useMemo } from 'react';
-import { Form, Spin, Typography, message as messageApi } from 'antd';
+import { Form, Spin, Typography } from 'antd';
import { EnterpriseFeatureDisplay } from '@actiontech/shared';
import ConfigSwitch from '../../components/ConfigSwitch';
import { CustomLabelContent } from '@actiontech/shared/lib/components/FormCom';
diff --git a/packages/base/src/page/System/PushNotification/LarkSetting/__snapshots__/index.test.tsx.snap b/packages/base/src/page/System/PushNotification/LarkSetting/__snapshots__/index.test.tsx.snap
new file mode 100644
index 000000000..a9ae5bf8f
--- /dev/null
+++ b/packages/base/src/page/System/PushNotification/LarkSetting/__snapshots__/index.test.tsx.snap
@@ -0,0 +1,2317 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`base/System/PushNotification/LarkSetting render snap 1`] = `
+
+
+
+`;
+
+exports[`base/System/PushNotification/LarkSetting render snap 2`] = `
+
+
+
+`;
+
+exports[`base/System/PushNotification/LarkSetting render switch cancel btn render snap when click cont cancel btn 1`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Cancel
+
+
+
+
+ OK
+
+
+
+
+
+
+
+
+
+
+`;
+
+exports[`base/System/PushNotification/LarkSetting render switch cancel btn render snap when click cont cancel btn 2`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Cancel
+
+
+
+
+ OK
+
+
+
+
+
+
+
+
+
+
+`;
+
+exports[`base/System/PushNotification/LarkSetting render switch cancel btn render snap when click switch change 1`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Cancel
+
+
+
+
+ OK
+
+
+
+
+
+
+
+
+
+
+`;
diff --git a/packages/base/src/page/System/PushNotification/LarkSetting/conponents/__snapshots__/ConfigField.test.tsx.snap b/packages/base/src/page/System/PushNotification/LarkSetting/conponents/__snapshots__/ConfigField.test.tsx.snap
new file mode 100644
index 000000000..94e68b284
--- /dev/null
+++ b/packages/base/src/page/System/PushNotification/LarkSetting/conponents/__snapshots__/ConfigField.test.tsx.snap
@@ -0,0 +1,121 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`base/System/PushNotification/LarkSetting/ConfigField render snap 1`] = `
+
+
+
+`;
diff --git a/packages/base/src/page/System/PushNotification/LarkSetting/index.test.tsx b/packages/base/src/page/System/PushNotification/LarkSetting/index.test.tsx
new file mode 100644
index 000000000..9851dfd41
--- /dev/null
+++ b/packages/base/src/page/System/PushNotification/LarkSetting/index.test.tsx
@@ -0,0 +1,93 @@
+import LarkSetting from '.';
+
+import system from '../../../../testUtils/mockApi/system';
+
+import { cleanup, fireEvent, act, screen, getAllByText } from '@testing-library/react';
+import { renderWithTheme } from '@actiontech/shared/lib/testUtil/customRender';
+import { getBySelector } from '@actiontech/shared/lib/testUtil/customQuery';
+
+describe('base/System/PushNotification/LarkSetting', () => {
+ let requestGetFeishuConfiguration: jest.SpyInstance;
+ let requestUpdateFeishuConfiguration: jest.SpyInstance;
+ const customRender = () => {
+ return renderWithTheme( );
+ };
+
+ beforeEach(() => {
+ jest.useFakeTimers();
+ requestGetFeishuConfiguration = system.getLarkConfig();
+ requestUpdateFeishuConfiguration = system.updateLarkConfig();
+ });
+
+ afterEach(() => {
+ jest.useRealTimers();
+ jest.clearAllMocks();
+ cleanup();
+ });
+
+ it('render snap', async () => {
+ const { baseElement } = customRender();
+
+ await act(async () => jest.advanceTimersByTime(500));
+ expect(baseElement).toMatchSnapshot();
+ await act(async () => jest.advanceTimersByTime(2600));
+ expect(requestGetFeishuConfiguration).toBeCalled();
+ expect(baseElement).toMatchSnapshot();
+ });
+
+ describe('render switch cancel btn', () => {
+ it('render snap when click cont cancel btn', async () => {
+ const { baseElement } = customRender();
+
+ await act(async () => jest.advanceTimersByTime(3300));
+ expect(screen.getByText('是否启用飞书推送')).toBeInTheDocument();
+
+ const switchEle = getBySelector(
+ '.basic-switch-wrapper .ant-switch-inner',
+ baseElement
+ );
+ fireEvent.click(switchEle);
+ await act(async () => jest.advanceTimersByTime(500));
+ expect(baseElement).toMatchSnapshot();
+
+ expect(screen.getByText('取 消')).toBeInTheDocument();
+ fireEvent.click(screen.getByText('取 消'));
+ await act(async () => jest.advanceTimersByTime(500));
+ expect(baseElement).toMatchSnapshot();
+ });
+
+ it('render snap when click switch change', async () => {
+ const { baseElement } = customRender();
+
+ await act(async () => jest.advanceTimersByTime(3300));
+
+ const switchEle = getBySelector(
+ '.basic-switch-wrapper .ant-switch-inner',
+ baseElement
+ );
+ fireEvent.click(switchEle);
+ await act(async () => jest.advanceTimersByTime(500));
+
+ fireEvent.click(switchEle);
+ await act(async () => jest.advanceTimersByTime(500));
+ expect(screen.getByText('是否确认关闭当前配置?')).toBeInTheDocument();
+ expect(screen.getByText('Cancel')).toBeInTheDocument();
+ expect(screen.getByText('OK')).toBeInTheDocument();
+
+ fireEvent.click(screen.getByText('Cancel'));
+ await act(async () => jest.advanceTimersByTime(500));
+
+ fireEvent.click(switchEle);
+ await act(async () => jest.advanceTimersByTime(500));
+ fireEvent.click(screen.getByText('OK'));
+ await act(async () => jest.advanceTimersByTime(500));
+ expect(baseElement).toMatchSnapshot();
+ });
+ });
+
+ describe('render submit lark setting', () => {
+ it('render submit success', async () => {
+
+ })
+ })
+});
From 68b254e5bc56fd024af02677141920f9aaa5bf19 Mon Sep 17 00:00:00 2001
From: xinbinyan <404928130@qq.com>
Date: Tue, 23 Jan 2024 17:20:52 +0800
Subject: [PATCH 13/27] formatter code
---
.../conponents/ConfigExtraButtons.test.tsx | 6 ++++--
.../LarkSetting/conponents/ConfigField.test.tsx | 8 +++++---
.../PushNotification/LarkSetting/index.test.tsx | 14 +++++++++-----
.../System/components/BasicTitle/index.test.tsx | 1 -
.../components/ConfigModifyBtn/index.test.tsx | 6 ++++--
.../ConfigSubmitButtonField/index.test.tsx | 11 ++++++++---
.../components/ConfigSwitch/index.test.tsx | 16 ++++++++--------
7 files changed, 38 insertions(+), 24 deletions(-)
diff --git a/packages/base/src/page/System/PushNotification/LarkSetting/conponents/ConfigExtraButtons.test.tsx b/packages/base/src/page/System/PushNotification/LarkSetting/conponents/ConfigExtraButtons.test.tsx
index f33d65d25..cf3c1c71f 100644
--- a/packages/base/src/page/System/PushNotification/LarkSetting/conponents/ConfigExtraButtons.test.tsx
+++ b/packages/base/src/page/System/PushNotification/LarkSetting/conponents/ConfigExtraButtons.test.tsx
@@ -114,7 +114,9 @@ describe('base/System/PushNotification/LarkSetting/ConfigExtraButtons', () => {
account_type: TestFeishuConfigurationAccountTypeEnum.phone
}
});
- expect(screen.getByText('已成功将消息推送至指定账号')).toBeInTheDocument();
+ expect(
+ screen.getByText('已成功将消息推送至指定账号')
+ ).toBeInTheDocument();
});
it('render form when api error', async () => {
@@ -151,5 +153,5 @@ describe('base/System/PushNotification/LarkSetting/ConfigExtraButtons', () => {
}
});
});
- })
+ });
});
diff --git a/packages/base/src/page/System/PushNotification/LarkSetting/conponents/ConfigField.test.tsx b/packages/base/src/page/System/PushNotification/LarkSetting/conponents/ConfigField.test.tsx
index f672930a4..6c92d2658 100644
--- a/packages/base/src/page/System/PushNotification/LarkSetting/conponents/ConfigField.test.tsx
+++ b/packages/base/src/page/System/PushNotification/LarkSetting/conponents/ConfigField.test.tsx
@@ -5,9 +5,11 @@ import ConfigField from './ConfigField';
describe('base/System/PushNotification/LarkSetting/ConfigField', () => {
it('render snap', () => {
- const { baseElement } = renderWithTheme();
+ const { baseElement } = renderWithTheme(
+
+ );
expect(baseElement).toMatchSnapshot();
});
});
diff --git a/packages/base/src/page/System/PushNotification/LarkSetting/index.test.tsx b/packages/base/src/page/System/PushNotification/LarkSetting/index.test.tsx
index 9851dfd41..87d6ce6c1 100644
--- a/packages/base/src/page/System/PushNotification/LarkSetting/index.test.tsx
+++ b/packages/base/src/page/System/PushNotification/LarkSetting/index.test.tsx
@@ -2,7 +2,13 @@ import LarkSetting from '.';
import system from '../../../../testUtils/mockApi/system';
-import { cleanup, fireEvent, act, screen, getAllByText } from '@testing-library/react';
+import {
+ cleanup,
+ fireEvent,
+ act,
+ screen,
+ getAllByText
+} from '@testing-library/react';
import { renderWithTheme } from '@actiontech/shared/lib/testUtil/customRender';
import { getBySelector } from '@actiontech/shared/lib/testUtil/customQuery';
@@ -86,8 +92,6 @@ describe('base/System/PushNotification/LarkSetting', () => {
});
describe('render submit lark setting', () => {
- it('render submit success', async () => {
-
- })
- })
+ it('render submit success', async () => {});
+ });
});
diff --git a/packages/base/src/page/System/components/BasicTitle/index.test.tsx b/packages/base/src/page/System/components/BasicTitle/index.test.tsx
index 603a248aa..35e9f1256 100644
--- a/packages/base/src/page/System/components/BasicTitle/index.test.tsx
+++ b/packages/base/src/page/System/components/BasicTitle/index.test.tsx
@@ -1,7 +1,6 @@
import { renderWithTheme } from '@actiontech/shared/lib/testUtil/customRender';
import SystemBasicTitle, { SystemBasicTitleProps } from '.';
-
describe('base/System/components/BasicTitle', () => {
const customRender = (params: SystemBasicTitleProps) => {
return renderWithTheme( );
diff --git a/packages/base/src/page/System/components/ConfigModifyBtn/index.test.tsx b/packages/base/src/page/System/components/ConfigModifyBtn/index.test.tsx
index 106941113..2536527d0 100644
--- a/packages/base/src/page/System/components/ConfigModifyBtn/index.test.tsx
+++ b/packages/base/src/page/System/components/ConfigModifyBtn/index.test.tsx
@@ -16,7 +16,9 @@ describe('base/System/components/ConfigModifyBtn', () => {
it('render snap', async () => {
const onClickFn = jest.fn();
- const { baseElement } = renderWithTheme( );
+ const { baseElement } = renderWithTheme(
+
+ );
expect(baseElement).toMatchSnapshot();
const btnEle = getBySelector('.ant-btn', baseElement);
@@ -27,5 +29,5 @@ describe('base/System/components/ConfigModifyBtn', () => {
fireEvent.click(btnEle);
expect(onClickFn).toBeCalled();
- })
+ });
});
diff --git a/packages/base/src/page/System/components/ConfigSubmitButtonField/index.test.tsx b/packages/base/src/page/System/components/ConfigSubmitButtonField/index.test.tsx
index b535844da..9399d52ac 100644
--- a/packages/base/src/page/System/components/ConfigSubmitButtonField/index.test.tsx
+++ b/packages/base/src/page/System/components/ConfigSubmitButtonField/index.test.tsx
@@ -6,8 +6,13 @@ import ConfigSubmitButtonField from '.';
describe('base/System/components/ConfigSubmitButtonField', () => {
const handleClickCancelFn = jest.fn();
const customRender = (submitLoading: boolean) => {
- return renderWithTheme( );
- }
+ return renderWithTheme(
+
+ );
+ };
beforeEach(() => {
jest.useFakeTimers();
@@ -35,5 +40,5 @@ describe('base/System/components/ConfigSubmitButtonField', () => {
fireEvent.click(screen.getByText('取 消'));
await act(async () => jest.advanceTimersByTime(500));
expect(handleClickCancelFn).toBeCalled();
- })
+ });
});
diff --git a/packages/base/src/page/System/components/ConfigSwitch/index.test.tsx b/packages/base/src/page/System/components/ConfigSwitch/index.test.tsx
index 778a40c28..65596a496 100644
--- a/packages/base/src/page/System/components/ConfigSwitch/index.test.tsx
+++ b/packages/base/src/page/System/components/ConfigSwitch/index.test.tsx
@@ -27,14 +27,14 @@ describe('base/System/components/ConfigSwitch', () => {
);
};
- beforeEach(() => {
- jest.useFakeTimers();
- });
+ beforeEach(() => {
+ jest.useFakeTimers();
+ });
- afterEach(() => {
- jest.useRealTimers();
- cleanup();
- });
+ afterEach(() => {
+ jest.useRealTimers();
+ cleanup();
+ });
it('render snap when switch disabled', () => {
const { baseElement } = customRender({
@@ -82,5 +82,5 @@ describe('base/System/components/ConfigSwitch', () => {
fireEvent.click(switchHandle);
await act(async () => jest.advanceTimersByTime(500));
expect(onSwitchChangeFn).toBeCalled();
- })
+ });
});
From aea7be7fd4b5995fa0d32f5ecdf4d26b0a991bb8 Mon Sep 17 00:00:00 2001
From: xinbinyan <404928130@qq.com>
Date: Tue, 23 Jan 2024 19:20:30 +0800
Subject: [PATCH 14/27] case LarkSetting
---
.../LarkAuditSetting/index.ee.tsx | 188 +++++++
.../LarkAuditSetting/index.tsx | 203 +------
.../__snapshots__/index.test.tsx.snap | 517 ++++++++++++++++++
.../LarkSetting/index.test.tsx | 49 +-
4 files changed, 759 insertions(+), 198 deletions(-)
create mode 100644 packages/base/src/page/System/ProcessConnection/LarkAuditSetting/index.ee.tsx
diff --git a/packages/base/src/page/System/ProcessConnection/LarkAuditSetting/index.ee.tsx b/packages/base/src/page/System/ProcessConnection/LarkAuditSetting/index.ee.tsx
new file mode 100644
index 000000000..2b8ebf627
--- /dev/null
+++ b/packages/base/src/page/System/ProcessConnection/LarkAuditSetting/index.ee.tsx
@@ -0,0 +1,188 @@
+import { useTranslation } from 'react-i18next';
+import { useBoolean, useRequest } from 'ahooks';
+import { useCallback, useMemo } from 'react';
+
+import { Form, Spin, Typography } from 'antd';
+import ConfigSwitch from '../../components/ConfigSwitch';
+import { CustomLabelContent } from '@actiontech/shared/lib/components/FormCom';
+import ConfigField from './components/ConfigField';
+import ConfigSubmitButtonField from '../../components/ConfigSubmitButtonField';
+import ConfigExtraButtons from './components/ConfigExtraButtons';
+
+import useConfigSwitch from '../../hooks/useConfigSwitch';
+import useConfigRender, {
+ ReadOnlyConfigColumnsType
+} from '../../hooks/useConfigRender';
+
+import configuration from '@actiontech/shared/lib/api/sqle/service/configuration';
+import { FormFields } from './index.type';
+import { defaultFormData, switchFieldName } from './index.data';
+import { ResponseCode } from '@actiontech/shared/lib/enum';
+import { IFeishuConfigurationV1 } from '@actiontech/shared/lib/api/sqle/service/common';
+
+const LarkAuditSettingEEIndex = () => {
+ const { t } = useTranslation();
+
+ const {
+ form,
+ renderConfigForm,
+ startModify,
+ modifyFinish,
+ modifyFlag,
+ extraButtonsVisible,
+ enabled
+ } = useConfigRender({
+ switchFieldName,
+ switchFieldLabel: (
+
+ )
+ });
+
+ const [submitLoading, { setTrue: startSubmit, setFalse: submitFinish }] =
+ useBoolean();
+
+ const {
+ data: larkAuditInfo,
+ loading: getLarkAuditInfoLoading,
+ refresh: refreshLarkAuditInfo
+ } = useRequest(
+ () =>
+ configuration
+ .getFeishuAuditConfigurationV1()
+ .then((res) => res.data.data ?? {}),
+ {
+ onSuccess(res) {
+ if (res) {
+ form.setFieldsValue({
+ enabled: !!res.is_feishu_notification_enabled
+ });
+ }
+ }
+ }
+ );
+
+ const isConfigClosed = useMemo(() => {
+ return !larkAuditInfo?.is_feishu_notification_enabled;
+ }, [larkAuditInfo]);
+
+ const setFormDefaultValue = useCallback(() => {
+ form.setFieldsValue({
+ appKey: larkAuditInfo?.app_id,
+ appSecret: undefined
+ });
+ }, [form, larkAuditInfo]);
+
+ const handleClickModify = () => {
+ setFormDefaultValue();
+ startModify();
+ };
+
+ const handleClickCancel = () => {
+ if (isConfigClosed) form.setFieldValue(switchFieldName, false);
+ setFormDefaultValue();
+ modifyFinish();
+ };
+
+ const handleToggleSwitch = (open: boolean) => {
+ form.setFieldValue(switchFieldName, open);
+ };
+
+ const submitLarkAuditConfig = (values: FormFields) => {
+ startSubmit();
+ configuration
+ .updateFeishuAuditConfigurationV1({
+ is_feishu_notification_enabled: values.enabled,
+ app_id: values.appKey,
+ app_secret: values.appSecret
+ })
+ .then((res) => {
+ if (res.data.code === ResponseCode.SUCCESS) {
+ handleClickCancel();
+ refreshLarkAuditInfo();
+ }
+ })
+ .finally(() => {
+ submitFinish();
+ });
+ };
+
+ const switchOpen = Form.useWatch(switchFieldName, form);
+
+ const {
+ configSwitchPopoverVisible,
+ onConfigSwitchPopoverOpen,
+ onConfigSwitchPopoverConfirm,
+ onConfigSwitchChange
+ } = useConfigSwitch({
+ isConfigClosed,
+ switchOpen,
+ modifyFlag,
+ startSubmit,
+ submitFinish,
+ handleClickModify,
+ handleUpdateConfig: () =>
+ configuration.updateFeishuAuditConfigurationV1({
+ ...defaultFormData,
+ is_feishu_notification_enabled: false
+ }),
+ handleClickCancel,
+ refreshConfig: refreshLarkAuditInfo,
+ handleToggleSwitch
+ });
+
+ const readonlyColumnsConfig: ReadOnlyConfigColumnsType =
+ useMemo(() => {
+ return [
+ {
+ label: 'App ID',
+ span: 3,
+ dataIndex: 'app_id',
+ hidden: !larkAuditInfo?.is_feishu_notification_enabled,
+ render: (val) => (
+ {val || '--'}
+ )
+ }
+ ];
+ }, [larkAuditInfo]);
+ return (
+
+ {renderConfigForm({
+ data: larkAuditInfo ?? {},
+ columns: readonlyColumnsConfig,
+ configExtraButtons: (
+
+ ),
+ configSwitchNode: (
+
+ ),
+ configField: ,
+ submitButtonField: (
+
+ ),
+ submit: submitLarkAuditConfig
+ })}
+
+ );
+};
+
+export default LarkAuditSettingEEIndex;
diff --git a/packages/base/src/page/System/ProcessConnection/LarkAuditSetting/index.tsx b/packages/base/src/page/System/ProcessConnection/LarkAuditSetting/index.tsx
index 9d85f3846..4b7364c9e 100644
--- a/packages/base/src/page/System/ProcessConnection/LarkAuditSetting/index.tsx
+++ b/packages/base/src/page/System/ProcessConnection/LarkAuditSetting/index.tsx
@@ -1,202 +1,25 @@
import { useTranslation } from 'react-i18next';
-import { useBoolean, useRequest } from 'ahooks';
-import { useCallback, useMemo } from 'react';
-import { Form, Spin, Typography } from 'antd';
+import { Typography } from 'antd';
import { EnterpriseFeatureDisplay } from '@actiontech/shared';
-import ConfigSwitch from '../../components/ConfigSwitch';
-import { CustomLabelContent } from '@actiontech/shared/lib/components/FormCom';
-import ConfigField from './components/ConfigField';
-import ConfigSubmitButtonField from '../../components/ConfigSubmitButtonField';
-import ConfigExtraButtons from './components/ConfigExtraButtons';
-
-import useConfigSwitch from '../../hooks/useConfigSwitch';
-import useConfigRender, {
- ReadOnlyConfigColumnsType
-} from '../../hooks/useConfigRender';
-
-import configuration from '@actiontech/shared/lib/api/sqle/service/configuration';
-import { FormFields } from './index.type';
-import { defaultFormData, switchFieldName } from './index.data';
-import { ResponseCode } from '@actiontech/shared/lib/enum';
-import { IFeishuConfigurationV1 } from '@actiontech/shared/lib/api/sqle/service/common';
+import LarkAuditSettingEEIndex from './index.ee';
const LarkAuditSetting: React.FC = () => {
const { t } = useTranslation();
- const {
- form,
- renderConfigForm,
- startModify,
- modifyFinish,
- modifyFlag,
- extraButtonsVisible,
- enabled
- } = useConfigRender({
- switchFieldName,
- switchFieldLabel: (
-
- )
- });
-
- const [submitLoading, { setTrue: startSubmit, setFalse: submitFinish }] =
- useBoolean();
-
- const {
- data: larkAuditInfo,
- loading: getLarkAuditInfoLoading,
- refresh: refreshLarkAuditInfo
- } = useRequest(
- () =>
- configuration
- .getFeishuAuditConfigurationV1()
- .then((res) => res.data.data ?? {}),
- {
- onSuccess(res) {
- if (res) {
- form.setFieldsValue({
- enabled: !!res.is_feishu_notification_enabled
- });
- }
- }
- }
- );
-
- const isConfigClosed = useMemo(() => {
- return !larkAuditInfo?.is_feishu_notification_enabled;
- }, [larkAuditInfo]);
-
- const setFormDefaultValue = useCallback(() => {
- form.setFieldsValue({
- appKey: larkAuditInfo?.app_id,
- appSecret: undefined
- });
- }, [form, larkAuditInfo]);
-
- const handleClickModify = () => {
- setFormDefaultValue();
- startModify();
- };
-
- const handleClickCancel = () => {
- if (isConfigClosed) form.setFieldValue(switchFieldName, false);
- setFormDefaultValue();
- modifyFinish();
- };
-
- const handleToggleSwitch = (open: boolean) => {
- form.setFieldValue(switchFieldName, open);
- };
-
- const submitLarkAuditConfig = (values: FormFields) => {
- startSubmit();
- configuration
- .updateFeishuAuditConfigurationV1({
- is_feishu_notification_enabled: values.enabled,
- app_id: values.appKey,
- app_secret: values.appSecret
- })
- .then((res) => {
- if (res.data.code === ResponseCode.SUCCESS) {
- handleClickCancel();
- refreshLarkAuditInfo();
- }
- })
- .finally(() => {
- submitFinish();
- });
- };
-
- const switchOpen = Form.useWatch(switchFieldName, form);
-
- const {
- configSwitchPopoverVisible,
- onConfigSwitchPopoverOpen,
- onConfigSwitchPopoverConfirm,
- onConfigSwitchChange
- } = useConfigSwitch({
- isConfigClosed,
- switchOpen,
- modifyFlag,
- startSubmit,
- submitFinish,
- handleClickModify,
- handleUpdateConfig: () =>
- configuration.updateFeishuAuditConfigurationV1({
- ...defaultFormData,
- is_feishu_notification_enabled: false
- }),
- handleClickCancel,
- refreshConfig: refreshLarkAuditInfo,
- handleToggleSwitch
- });
-
- const readonlyColumnsConfig: ReadOnlyConfigColumnsType =
- useMemo(() => {
- return [
- {
- label: 'App ID',
- span: 3,
- dataIndex: 'app_id',
- hidden: !larkAuditInfo?.is_feishu_notification_enabled,
- render: (val) => (
- {val || '--'}
- )
- }
- ];
- }, [larkAuditInfo]);
-
return (
-
-
- {t('dmsSystem.larkAudit.ceTips')}
-
- }
- isConfigPage={true}
- >
- <>
- {renderConfigForm({
- data: larkAuditInfo ?? {},
- columns: readonlyColumnsConfig,
- configExtraButtons: (
-
- ),
- configSwitchNode: (
-
- ),
- configField: ,
- submitButtonField: (
-
- ),
- submit: submitLarkAuditConfig
- })}
- >
-
-
+
+ {t('dmsSystem.larkAudit.ceTips')}
+
+ }
+ isConfigPage={true}
+ >
+
+
);
};
diff --git a/packages/base/src/page/System/PushNotification/LarkSetting/__snapshots__/index.test.tsx.snap b/packages/base/src/page/System/PushNotification/LarkSetting/__snapshots__/index.test.tsx.snap
index a9ae5bf8f..0c008d203 100644
--- a/packages/base/src/page/System/PushNotification/LarkSetting/__snapshots__/index.test.tsx.snap
+++ b/packages/base/src/page/System/PushNotification/LarkSetting/__snapshots__/index.test.tsx.snap
@@ -796,6 +796,523 @@ exports[`base/System/PushNotification/LarkSetting render snap 2`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+ Cancel
+
+
+
+
+ OK
+
+
+
+
+
+
+
+
+
+
diff --git a/packages/base/src/page/System/PushNotification/LarkSetting/index.test.tsx b/packages/base/src/page/System/PushNotification/LarkSetting/index.test.tsx
index 87d6ce6c1..13a515c30 100644
--- a/packages/base/src/page/System/PushNotification/LarkSetting/index.test.tsx
+++ b/packages/base/src/page/System/PushNotification/LarkSetting/index.test.tsx
@@ -2,13 +2,7 @@ import LarkSetting from '.';
import system from '../../../../testUtils/mockApi/system';
-import {
- cleanup,
- fireEvent,
- act,
- screen,
- getAllByText
-} from '@testing-library/react';
+import { cleanup, fireEvent, act, screen } from '@testing-library/react';
import { renderWithTheme } from '@actiontech/shared/lib/testUtil/customRender';
import { getBySelector } from '@actiontech/shared/lib/testUtil/customQuery';
@@ -92,6 +86,45 @@ describe('base/System/PushNotification/LarkSetting', () => {
});
describe('render submit lark setting', () => {
- it('render submit success', async () => {});
+ it('render submit success', async () => {
+ const { baseElement } = customRender();
+
+ await act(async () => jest.advanceTimersByTime(3300));
+ const switchEle = getBySelector(
+ '.basic-switch-wrapper .ant-switch-inner',
+ baseElement
+ );
+ fireEvent.click(switchEle);
+ await act(async () => jest.advanceTimersByTime(500));
+
+ fireEvent.change(getBySelector('#appKey', baseElement), {
+ target: {
+ value: 'app key'
+ }
+ });
+ await act(async () => jest.advanceTimersByTime(300));
+
+ fireEvent.change(getBySelector('#appSecret', baseElement), {
+ target: {
+ value: 'app secret'
+ }
+ });
+ await act(async () => jest.advanceTimersByTime(300));
+
+ expect(screen.getByText('提 交')).toBeInTheDocument();
+ fireEvent.click(screen.getByText('提 交'));
+ await act(async () => jest.advanceTimersByTime(300));
+ expect(baseElement).toMatchSnapshot();
+ await act(async () => jest.advanceTimersByTime(3000));
+ expect(requestUpdateFeishuConfiguration).toBeCalled();
+ expect(requestUpdateFeishuConfiguration).toBeCalledWith({
+ update_feishu_configuration: {
+ app_id: 'app key',
+ app_secret: 'app secret',
+ is_feishu_notification_enabled: true
+ }
+ });
+ expect(requestGetFeishuConfiguration).toBeCalled();
+ });
});
});
From 5a8a26a972255ca43e2345e44b645654bafe83c0 Mon Sep 17 00:00:00 2001
From: xinbinyan <404928130@qq.com>
Date: Tue, 23 Jan 2024 19:38:00 +0800
Subject: [PATCH 15/27] case ConfigExtraButtons
---
.../components/ConfigExtraButtons.test.tsx | 140 +++
.../components/ConfigExtraButtons.tsx | 17 +-
.../ConfigExtraButtons.test.tsx.snap | 842 ++++++++++++++++++
.../PushNotification/SMTPSetting/index.tsx | 2 +-
4 files changed, 991 insertions(+), 10 deletions(-)
create mode 100644 packages/base/src/page/System/PushNotification/SMTPSetting/components/ConfigExtraButtons.test.tsx
create mode 100644 packages/base/src/page/System/PushNotification/SMTPSetting/components/__snapshots__/ConfigExtraButtons.test.tsx.snap
diff --git a/packages/base/src/page/System/PushNotification/SMTPSetting/components/ConfigExtraButtons.test.tsx b/packages/base/src/page/System/PushNotification/SMTPSetting/components/ConfigExtraButtons.test.tsx
new file mode 100644
index 000000000..db950a190
--- /dev/null
+++ b/packages/base/src/page/System/PushNotification/SMTPSetting/components/ConfigExtraButtons.test.tsx
@@ -0,0 +1,140 @@
+import ConfigExtraButtons, { typeConfigExtraButtons } from './ConfigExtraButtons';
+
+import { cleanup, fireEvent, act, screen } from '@testing-library/react';
+import { renderWithTheme } from '@actiontech/shared/lib/testUtil/customRender';
+import { getBySelector } from '@actiontech/shared/lib/testUtil/customQuery';
+
+import system from '../../../../../testUtils/mockApi/system';
+
+describe('base/System/PushNotification/SMTPSetting/ConfigExtraButtons', () => {
+ let requestTestSMTPConfigurationSuccess: jest.SpyInstance;
+ const handleClickModifyFn = jest.fn();
+ const customRender = (
+ params: Omit
+ ) => {
+ return renderWithTheme(
+
+ );
+ };
+
+ beforeEach(() => {
+ jest.useFakeTimers();
+ requestTestSMTPConfigurationSuccess = system.testSMTPConfigSuccess();
+ });
+
+ afterEach(() => {
+ jest.useRealTimers();
+ jest.clearAllMocks();
+ cleanup();
+ });
+
+ describe('render snap when hidden val is true', () => {
+ it('render isConfigClosed is true', () => {
+ const { baseElement } = customRender({
+ isConfigClosed: true,
+ extraButtonsVisible: true,
+ enabled: false,
+ });
+ expect(baseElement).toMatchSnapshot();
+ });
+ it('render extraButtonsVisible is false', () => {
+ const { baseElement } = customRender({
+ isConfigClosed: false,
+ extraButtonsVisible: false,
+ enabled: false
+ });
+ expect(baseElement).toMatchSnapshot();
+ });
+ });
+
+ describe('render snap form', () => {
+ it('render popover cancel btn', async () => {
+ const { baseElement } = customRender({
+ isConfigClosed: false,
+ extraButtonsVisible: true,
+ enabled: true
+ });
+
+ const btnPopoverOpen = getBySelector(
+ '.ant-btn[type="submit"]',
+ baseElement
+ );
+ fireEvent.click(btnPopoverOpen);
+ await act(async () => jest.advanceTimersByTime(500));
+ expect(screen.getByText('取 消')).toBeInTheDocument();
+ await act(async () => jest.advanceTimersByTime(300));
+ expect(baseElement).toMatchSnapshot();
+ });
+
+ it('render form validate', async () => {
+ const { baseElement } = customRender({
+ isConfigClosed: false,
+ extraButtonsVisible: true,
+ enabled: true
+ });
+
+ const btnPopoverOpen = getBySelector(
+ '.ant-btn[type="submit"]',
+ baseElement
+ );
+ fireEvent.click(btnPopoverOpen);
+ await act(async () => jest.advanceTimersByTime(500));
+ expect(baseElement).toMatchSnapshot();
+ expect(
+ getBySelector('input[ placeholder="请输入接收邮箱"]', baseElement)
+ ).toBeInTheDocument();
+
+ fireEvent.change(getBySelector('#receiveEmail', baseElement), {
+ target: {
+ value: '1@q.com'
+ }
+ });
+ await act(async () => jest.advanceTimersByTime(500));
+
+ fireEvent.click(screen.getByText('确 认'));
+ await act(async () => jest.advanceTimersByTime(3300));
+ expect(requestTestSMTPConfigurationSuccess).toBeCalled();
+ expect(requestTestSMTPConfigurationSuccess).toBeCalledWith({
+ test_smtp_configuration: {
+ recipient_addr: '1@q.com'
+ }
+ });
+ });
+
+ it('render form submit error', async () => {
+ const requestTestSMTPConfigurationError = system.testSMTPConfigFail();
+
+ const { baseElement } = customRender({
+ isConfigClosed: false,
+ extraButtonsVisible: true,
+ enabled: true
+ });
+
+ const btnPopoverOpen = getBySelector(
+ '.ant-btn[type="submit"]',
+ baseElement
+ );
+ fireEvent.click(btnPopoverOpen);
+ await act(async () => jest.advanceTimersByTime(500));
+
+ expect(
+ getBySelector('input[ placeholder="请输入接收邮箱"]', baseElement)
+ ).toBeInTheDocument();
+
+ fireEvent.change(getBySelector('#receiveEmail', baseElement), {
+ target: {
+ value: '2@a.com'
+ }
+ });
+ await act(async () => jest.advanceTimersByTime(500));
+ fireEvent.click(screen.getByText('确 认'));
+ await act(async () => jest.advanceTimersByTime(3300));
+ expect(requestTestSMTPConfigurationError).toBeCalledWith({
+ test_smtp_configuration: {
+ recipient_addr: '2@a.com'
+ }
+ });
+ expect(baseElement).toMatchSnapshot();
+ })
+ })
+});
diff --git a/packages/base/src/page/System/PushNotification/SMTPSetting/components/ConfigExtraButtons.tsx b/packages/base/src/page/System/PushNotification/SMTPSetting/components/ConfigExtraButtons.tsx
index 57651a481..048fbe089 100644
--- a/packages/base/src/page/System/PushNotification/SMTPSetting/components/ConfigExtraButtons.tsx
+++ b/packages/base/src/page/System/PushNotification/SMTPSetting/components/ConfigExtraButtons.tsx
@@ -12,17 +12,16 @@ import ConfigModifyBtn from '../../../components/ConfigModifyBtn';
import dms from '@actiontech/shared/lib/api/base/service/dms';
import { ResponseCode } from '@actiontech/shared/lib/enum';
-import { ISMTPConfigurationResData } from '@actiontech/shared/lib/api/base/service/common';
-type typeConfigExtraButtons = {
- smtpInfo: ISMTPConfigurationResData | undefined;
+export type typeConfigExtraButtons = {
+ isConfigClosed: boolean;
enabled: string | number | boolean;
extraButtonsVisible: boolean;
handleClickModify: () => void;
};
const ConfigExtraButtons = ({
- smtpInfo,
+ isConfigClosed,
enabled,
extraButtonsVisible,
handleClickModify
@@ -34,10 +33,6 @@ const ConfigExtraButtons = ({
const [testPopoverVisible, toggleTestPopoverVisible] = useState(false);
- const isConfigClosed = useMemo(() => {
- return !smtpInfo?.enable_smtp_notify;
- }, [smtpInfo]);
-
const testTing = useRef(false);
const onTestPopoverOpen = (open: boolean) => {
@@ -119,7 +114,11 @@ const ConfigExtraButtons = ({
}
]}
>
-
+
diff --git a/packages/base/src/page/System/PushNotification/SMTPSetting/components/__snapshots__/ConfigExtraButtons.test.tsx.snap b/packages/base/src/page/System/PushNotification/SMTPSetting/components/__snapshots__/ConfigExtraButtons.test.tsx.snap
new file mode 100644
index 000000000..dc1fa7927
--- /dev/null
+++ b/packages/base/src/page/System/PushNotification/SMTPSetting/components/__snapshots__/ConfigExtraButtons.test.tsx.snap
@@ -0,0 +1,842 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`base/System/PushNotification/SMTPSetting/ConfigExtraButtons render snap form render form submit error 1`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 取 消
+
+
+
+
+
+
+ 确 认
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 正在向 “2@a.com” 发送测试邮件...
+
+
+
+
+
+
+`;
+
+exports[`base/System/PushNotification/SMTPSetting/ConfigExtraButtons render snap form render form validate 1`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 取 消
+
+
+
+
+
+
+ 确 认
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+`;
+
+exports[`base/System/PushNotification/SMTPSetting/ConfigExtraButtons render snap form render popover cancel btn 1`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 取 消
+
+
+
+
+
+
+ 确 认
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+`;
+
+exports[`base/System/PushNotification/SMTPSetting/ConfigExtraButtons render snap when hidden val is true render extraButtonsVisible is false 1`] = `
+
+
+
+`;
+
+exports[`base/System/PushNotification/SMTPSetting/ConfigExtraButtons render snap when hidden val is true render isConfigClosed is true 1`] = `
+
+
+
+`;
diff --git a/packages/base/src/page/System/PushNotification/SMTPSetting/index.tsx b/packages/base/src/page/System/PushNotification/SMTPSetting/index.tsx
index c10cc957d..af9af9c07 100644
--- a/packages/base/src/page/System/PushNotification/SMTPSetting/index.tsx
+++ b/packages/base/src/page/System/PushNotification/SMTPSetting/index.tsx
@@ -188,7 +188,7 @@ const SMTPSetting = () => {
columns: readonlyColumnsConfig,
configExtraButtons: (
Date: Tue, 23 Jan 2024 19:48:07 +0800
Subject: [PATCH 16/27] case ConfigField
---
.../components/ConfigField.test.tsx | 99 +
.../__snapshots__/ConfigField.test.tsx.snap | 2381 +++++++++++++++++
2 files changed, 2480 insertions(+)
create mode 100644 packages/base/src/page/System/PushNotification/SMTPSetting/components/ConfigField.test.tsx
create mode 100644 packages/base/src/page/System/PushNotification/SMTPSetting/components/__snapshots__/ConfigField.test.tsx.snap
diff --git a/packages/base/src/page/System/PushNotification/SMTPSetting/components/ConfigField.test.tsx b/packages/base/src/page/System/PushNotification/SMTPSetting/components/ConfigField.test.tsx
new file mode 100644
index 000000000..0d3b1c105
--- /dev/null
+++ b/packages/base/src/page/System/PushNotification/SMTPSetting/components/ConfigField.test.tsx
@@ -0,0 +1,99 @@
+import { cleanup, fireEvent, act, screen } from '@testing-library/react';
+import { renderWithTheme } from '@actiontech/shared/lib/testUtil/customRender';
+
+import { Form } from 'antd';
+import ConfigField from './ConfigField';
+import { getBySelector } from '@actiontech/shared/lib/testUtil/customQuery';
+
+describe('base/System/PushNotification/SMTPSetting/ConfigField', () => {
+ const customRender = () => {
+ return renderWithTheme(
+
+ );
+ };
+
+ beforeEach(() => {
+ jest.useFakeTimers();
+ });
+
+ afterEach(() => {
+ jest.useRealTimers();
+ jest.clearAllMocks();
+ cleanup();
+ });
+
+ it('render snap', () => {
+ const { baseElement } = customRender();
+ expect(baseElement).toMatchSnapshot();
+ });
+
+ it('render validator Port', async () => {
+ const { baseElement } = customRender();
+
+ const portEle = getBySelector('#port', baseElement);
+
+ fireEvent.change(portEle, {
+ target: {
+ value: 'a'
+ }
+ });
+ await act(async () => jest.advanceTimersByTime(500));
+ expect(baseElement).toMatchSnapshot();
+
+ fireEvent.change(portEle, {
+ target: {
+ value: '0'
+ }
+ });
+ await act(async () => jest.advanceTimersByTime(500));
+ expect(baseElement).toMatchSnapshot();
+
+ fireEvent.change(portEle, {
+ target: {
+ value: '65536'
+ }
+ });
+ await act(async () => jest.advanceTimersByTime(500));
+ expect(baseElement).toMatchSnapshot();
+
+ fireEvent.change(portEle, {
+ target: {
+ value: '8080'
+ }
+ });
+ await act(async () => jest.advanceTimersByTime(500));
+ expect(baseElement).toMatchSnapshot();
+ });
+
+ it('render pwd must be same', async () => {
+ const { baseElement } = customRender();
+
+ const pwdEle = getBySelector('#password', baseElement);
+ const pwdConfirmEle = getBySelector('#passwordConfirm', baseElement);
+
+ fireEvent.change(pwdEle, {
+ target: {
+ value: '1'
+ }
+ });
+ await act(async () => jest.advanceTimersByTime(500));
+
+ fireEvent.change(pwdConfirmEle, {
+ target: {
+ value: '12'
+ }
+ });
+ await act(async () => jest.advanceTimersByTime(500));
+ expect(baseElement).toMatchSnapshot();
+
+ fireEvent.change(pwdConfirmEle, {
+ target: {
+ value: '1'
+ }
+ });
+ await act(async () => jest.advanceTimersByTime(500));
+ expect(baseElement).toMatchSnapshot();
+ });
+});
diff --git a/packages/base/src/page/System/PushNotification/SMTPSetting/components/__snapshots__/ConfigField.test.tsx.snap b/packages/base/src/page/System/PushNotification/SMTPSetting/components/__snapshots__/ConfigField.test.tsx.snap
new file mode 100644
index 000000000..4ff8bbb6c
--- /dev/null
+++ b/packages/base/src/page/System/PushNotification/SMTPSetting/components/__snapshots__/ConfigField.test.tsx.snap
@@ -0,0 +1,2381 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`base/System/PushNotification/SMTPSetting/ render pwd must be same 1`] = `
+
+
+
+`;
+
+exports[`base/System/PushNotification/SMTPSetting/ render pwd must be same 2`] = `
+
+
+
+`;
+
+exports[`base/System/PushNotification/SMTPSetting/ render snap 1`] = `
+
+
+
+`;
+
+exports[`base/System/PushNotification/SMTPSetting/ render validator Port 1`] = `
+
+
+
+`;
+
+exports[`base/System/PushNotification/SMTPSetting/ render validator Port 2`] = `
+
+
+
+`;
+
+exports[`base/System/PushNotification/SMTPSetting/ render validator Port 3`] = `
+
+
+
+`;
+
+exports[`base/System/PushNotification/SMTPSetting/ render validator Port 4`] = `
+
+
+
+`;
From 1c50464f319c3adf0c92a47388928b5a2b2e6fc5 Mon Sep 17 00:00:00 2001
From: xinbinyan <404928130@qq.com>
Date: Wed, 24 Jan 2024 13:43:40 +0800
Subject: [PATCH 17/27] case SMTPSetting
---
.../__snapshots__/index.test.tsx.snap | 4545 +++++++++++++++++
.../components/ConfigExtraButtons.test.tsx | 10 +-
.../components/ConfigExtraButtons.tsx | 2 +-
.../components/ConfigField.test.tsx | 2 +-
.../SMTPSetting/components/ConfigField.tsx | 30 +-
.../__snapshots__/ConfigField.test.tsx.snap | 2380 +++++++++
.../SMTPSetting/index.test.tsx | 152 +
7 files changed, 7110 insertions(+), 11 deletions(-)
create mode 100644 packages/base/src/page/System/PushNotification/SMTPSetting/__snapshots__/index.test.tsx.snap
create mode 100644 packages/base/src/page/System/PushNotification/SMTPSetting/index.test.tsx
diff --git a/packages/base/src/page/System/PushNotification/SMTPSetting/__snapshots__/index.test.tsx.snap b/packages/base/src/page/System/PushNotification/SMTPSetting/__snapshots__/index.test.tsx.snap
new file mode 100644
index 000000000..8488a47d3
--- /dev/null
+++ b/packages/base/src/page/System/PushNotification/SMTPSetting/__snapshots__/index.test.tsx.snap
@@ -0,0 +1,4545 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`base/System/PushNotification/SMTPSetting render snap 1`] = `
+
+
+
+`;
+
+exports[`base/System/PushNotification/SMTPSetting render snap 2`] = `
+
+
+
+`;
+
+exports[`base/System/PushNotification/SMTPSetting render submit SMTP setting render submit success 1`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Cancel
+
+
+
+
+ OK
+
+
+
+
+
+
+
+
+
+
+`;
+
+exports[`base/System/PushNotification/SMTPSetting render switch cancel btn render snap when click cont cancel btn 1`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Cancel
+
+
+
+
+ OK
+
+
+
+
+
+
+
+
+
+
+`;
+
+exports[`base/System/PushNotification/SMTPSetting render switch cancel btn render snap when click cont cancel btn 2`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Cancel
+
+
+
+
+ OK
+
+
+
+
+
+
+
+
+
+
+`;
+
+exports[`base/System/PushNotification/SMTPSetting render switch cancel btn render snap when click switch change 1`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Cancel
+
+
+
+
+ OK
+
+
+
+
+
+
+
+
+
+
+`;
diff --git a/packages/base/src/page/System/PushNotification/SMTPSetting/components/ConfigExtraButtons.test.tsx b/packages/base/src/page/System/PushNotification/SMTPSetting/components/ConfigExtraButtons.test.tsx
index db950a190..7f6bef009 100644
--- a/packages/base/src/page/System/PushNotification/SMTPSetting/components/ConfigExtraButtons.test.tsx
+++ b/packages/base/src/page/System/PushNotification/SMTPSetting/components/ConfigExtraButtons.test.tsx
@@ -1,4 +1,6 @@
-import ConfigExtraButtons, { typeConfigExtraButtons } from './ConfigExtraButtons';
+import ConfigExtraButtons, {
+ typeConfigExtraButtons
+} from './ConfigExtraButtons';
import { cleanup, fireEvent, act, screen } from '@testing-library/react';
import { renderWithTheme } from '@actiontech/shared/lib/testUtil/customRender';
@@ -33,7 +35,7 @@ describe('base/System/PushNotification/SMTPSetting/ConfigExtraButtons', () => {
const { baseElement } = customRender({
isConfigClosed: true,
extraButtonsVisible: true,
- enabled: false,
+ enabled: false
});
expect(baseElement).toMatchSnapshot();
});
@@ -135,6 +137,6 @@ describe('base/System/PushNotification/SMTPSetting/ConfigExtraButtons', () => {
}
});
expect(baseElement).toMatchSnapshot();
- })
- })
+ });
+ });
});
diff --git a/packages/base/src/page/System/PushNotification/SMTPSetting/components/ConfigExtraButtons.tsx b/packages/base/src/page/System/PushNotification/SMTPSetting/components/ConfigExtraButtons.tsx
index 048fbe089..33e9bd0a1 100644
--- a/packages/base/src/page/System/PushNotification/SMTPSetting/components/ConfigExtraButtons.tsx
+++ b/packages/base/src/page/System/PushNotification/SMTPSetting/components/ConfigExtraButtons.tsx
@@ -1,6 +1,6 @@
import { Form, message, Space } from 'antd';
import { useTranslation } from 'react-i18next';
-import { useMemo, useRef, useState } from 'react';
+import { useRef, useState } from 'react';
import { useForm } from 'antd/es/form/Form';
import { formItemLayout } from '@actiontech/shared/lib/components/FormCom/style';
diff --git a/packages/base/src/page/System/PushNotification/SMTPSetting/components/ConfigField.test.tsx b/packages/base/src/page/System/PushNotification/SMTPSetting/components/ConfigField.test.tsx
index 0d3b1c105..3597027e5 100644
--- a/packages/base/src/page/System/PushNotification/SMTPSetting/components/ConfigField.test.tsx
+++ b/packages/base/src/page/System/PushNotification/SMTPSetting/components/ConfigField.test.tsx
@@ -1,4 +1,4 @@
-import { cleanup, fireEvent, act, screen } from '@testing-library/react';
+import { cleanup, fireEvent, act } from '@testing-library/react';
import { renderWithTheme } from '@actiontech/shared/lib/testUtil/customRender';
import { Form } from 'antd';
diff --git a/packages/base/src/page/System/PushNotification/SMTPSetting/components/ConfigField.tsx b/packages/base/src/page/System/PushNotification/SMTPSetting/components/ConfigField.tsx
index 6004d9a51..4f9a82011 100644
--- a/packages/base/src/page/System/PushNotification/SMTPSetting/components/ConfigField.tsx
+++ b/packages/base/src/page/System/PushNotification/SMTPSetting/components/ConfigField.tsx
@@ -34,7 +34,11 @@ const ConfigField = () => {
}
]}
>
-
+
{
}
]}
>
-
+
{
}
]}
>
-
+
{
}
]}
>
-
+
{
})
]}
>
-
+
>
);
diff --git a/packages/base/src/page/System/PushNotification/SMTPSetting/components/__snapshots__/ConfigField.test.tsx.snap b/packages/base/src/page/System/PushNotification/SMTPSetting/components/__snapshots__/ConfigField.test.tsx.snap
index 4ff8bbb6c..e1dcadc3d 100644
--- a/packages/base/src/page/System/PushNotification/SMTPSetting/components/__snapshots__/ConfigField.test.tsx.snap
+++ b/packages/base/src/page/System/PushNotification/SMTPSetting/components/__snapshots__/ConfigField.test.tsx.snap
@@ -2379,3 +2379,2383 @@ exports[`base/System/PushNotification/SMTPSetting/ render validator Port 4`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+
+