From 92c03cbdf9c47b0217258af116ace2d219301d8f Mon Sep 17 00:00:00 2001 From: yoan <536464346@qq.com> Date: Sun, 24 Nov 2024 20:06:30 +0800 Subject: [PATCH] fix conflict --- .github/workflows/push_image_next.yml | 2 +- ui/src/components/notify/Mail.tsx | 327 -------------------------- 2 files changed, 1 insertion(+), 328 deletions(-) delete mode 100644 ui/src/components/notify/Mail.tsx diff --git a/.github/workflows/push_image_next.yml b/.github/workflows/push_image_next.yml index 7052bab2..fa5abea3 100644 --- a/.github/workflows/push_image_next.yml +++ b/.github/workflows/push_image_next.yml @@ -34,7 +34,7 @@ jobs: registry.cn-shanghai.aliyuncs.com/usual2970/certimate tags: | type=ref,event=tag - type=raw,value=latest,enable={{is_default_branch}} + type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'master') }} - name: Log in to DOCKERHUB uses: docker/login-action@v3 diff --git a/ui/src/components/notify/Mail.tsx b/ui/src/components/notify/Mail.tsx deleted file mode 100644 index 79ea0f17..00000000 --- a/ui/src/components/notify/Mail.tsx +++ /dev/null @@ -1,327 +0,0 @@ -import { useEffect, useState } from "react"; -import { useTranslation } from "react-i18next"; - -import { Button } from "@/components/ui/button"; -import { Input } from "@/components/ui/input"; -import { Label } from "@/components/ui/label"; -import { Switch } from "@/components/ui/switch"; -import { useToast } from "@/components/ui/use-toast"; -import { getErrMessage } from "@/lib/error"; -import { NotifyChannelEmail, NotifyChannels } from "@/domain/settings"; -import { useNotifyContext } from "@/providers/notify"; -import { update } from "@/repository/settings"; -import Show from "@/components/Show"; -import { notifyTest } from "@/api/notify"; - -type MailSetting = { - id: string; - name: string; - data: NotifyChannelEmail; -}; - -const Mail = () => { - const { config, setChannels } = useNotifyContext(); - const { t } = useTranslation(); - - const [changed, setChanged] = useState(false); - - const [mail, setmail] = useState({ - id: config.id ?? "", - name: "notifyChannels", - data: { - senderAddress: "", - receiverAddresses: "", - smtpHostAddr: "", - smtpHostPort: "25", - username: "", - password: "", - enabled: false, - }, - }); - - const [originMail, setoriginMail] = useState({ - id: config.id ?? "", - name: "notifyChannels", - data: { - senderAddress: "", - receiverAddresses: "", - smtpHostAddr: "", - smtpHostPort: "25", - username: "", - password: "", - enabled: false, - }, - }); - - useEffect(() => { - setChanged(false); - }, [config]); - - useEffect(() => { - const data = getDetailMail(); - setoriginMail({ - id: config.id ?? "", - name: "mail", - data, - }); - }, [config]); - - useEffect(() => { - const data = getDetailMail(); - setmail({ - id: config.id ?? "", - name: "mail", - data, - }); - }, [config]); - - const { toast } = useToast(); - - const getDetailMail = () => { - const df: NotifyChannelMail = { - senderAddress: "", - receiverAddresses: "", - smtpHostAddr: "", - smtpHostPort: "25", - username: "", - password: "", - enabled: false, - }; - if (!config.content) { - return df; - } - const chanels = config.content as NotifyChannels; - if (!chanels.mail) { - return df; - } - - return chanels.mail as NotifyChannelMail; - }; - - const checkChanged = (data: NotifyChannelMail) => { - if ( - data.senderAddress !== originMail.data.senderAddress || - data.receiverAddresses !== originMail.data.receiverAddresses || - data.smtpHostAddr !== originMail.data.smtpHostAddr || - data.smtpHostPort !== originMail.data.smtpHostPort || - data.username !== originMail.data.username || - data.password !== originMail.data.password - ) { - setChanged(true); - } else { - setChanged(false); - } - }; - - const handleSaveClick = async () => { - try { - const resp = await update({ - ...config, - name: "notifyChannels", - content: { - ...config.content, - mail: { - ...mail.data, - }, - }, - }); - - setChannels(resp); - toast({ - title: t("common.save.succeeded.message"), - description: t("settings.notification.config.saved.message"), - }); - } catch (e) { - const msg = getErrMessage(e); - - toast({ - title: t("common.save.failed.message"), - description: `${t("settings.notification.config.failed.message")}: ${msg}`, - variant: "destructive", - }); - } - }; - - const handlePushTestClick = async () => { - try { - await notifyTest("mail"); - - toast({ - title: t("settings.notification.config.push.test.message.success.message"), - description: t("settings.notification.config.push.test.message.success.message"), - }); - } catch (e) { - const msg = getErrMessage(e); - - toast({ - title: t("settings.notification.config.push.test.message.failed.message"), - description: `${t("settings.notification.config.push.test.message.failed.message")}: ${msg}`, - variant: "destructive", - }); - } - }; - - const handleSwitchChange = async () => { - const newData = { - ...mail, - data: { - ...mail.data, - enabled: !mail.data.enabled, - }, - }; - setmail(newData); - - try { - const resp = await update({ - ...config, - name: "notifyChannels", - content: { - ...config.content, - mail: { - ...newData.data, - }, - }, - }); - - setChannels(resp); - } catch (e) { - const msg = getErrMessage(e); - - toast({ - title: t("common.save.failed.message"), - description: `${t("settings.notification.config.failed.message")}: ${msg}`, - variant: "destructive", - }); - } - }; - - return ( -
- { - const newData = { - ...mail, - data: { - ...mail.data, - senderAddress: e.target.value, - }, - }; - checkChanged(newData.data); - setmail(newData); - }} - /> - { - const newData = { - ...mail, - data: { - ...mail.data, - receiverAddresses: e.target.value, - }, - }; - checkChanged(newData.data); - setmail(newData); - }} - /> - { - const newData = { - ...mail, - data: { - ...mail.data, - smtpHostAddr: e.target.value, - }, - }; - checkChanged(newData.data); - setmail(newData); - }} - /> - { - const newData = { - ...mail, - data: { - ...mail.data, - smtpHostPort: e.target.value, - }, - }; - checkChanged(newData.data); - setmail(newData); - }} - /> - { - const newData = { - ...mail, - data: { - ...mail.data, - username: e.target.value, - }, - }; - checkChanged(newData.data); - setmail(newData); - }} - /> - { - const newData = { - ...mail, - data: { - ...mail.data, - password: e.target.value, - }, - }; - checkChanged(newData.data); - setmail(newData); - }} - /> -
- - -
- -
- - - - - - - -
-
- ); -}; - -export default Mail; -