diff --git a/frontend/src/components/console/settings/notifications.tsx b/frontend/src/components/console/settings/notifications.tsx index 19cc166f7..4d9a38137 100644 --- a/frontend/src/components/console/settings/notifications.tsx +++ b/frontend/src/components/console/settings/notifications.tsx @@ -58,7 +58,9 @@ import { Spinner } from "@/components/ui/spinner" import { Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia } from "@/components/ui/empty" import { WechatMpBindDialog } from "@/components/console/wechat-mp-bind-dialog" import { useCommonData } from "@/components/console/data-provider" +import { useAppRuntime } from "@/components/app-runtime-provider" import { IS_ONLINE_EDITION } from "@/utils/edition" +import { shouldShowWechatMp } from "@/utils/wechat-mp" import { useTranslation } from "react-i18next" /** Receiver type used by the UI; wechat_work maps to the API wecom kind. */ @@ -103,6 +105,8 @@ function getReceiverTypeIcon(type: ReceiverType): React.ReactNode { export default function Notifications() { const { t } = useTranslation() const { user, reloadUser } = useCommonData() + const { serverConfig } = useAppRuntime() + const showWechatMp = shouldShowWechatMp(IS_ONLINE_EDITION, serverConfig?.region) const [channels, setChannels] = useState([]) const [eventTypes, setEventTypes] = useState([]) const [loadingChannels, setLoadingChannels] = useState(true) @@ -456,7 +460,7 @@ export default function Notifications() {
- {IS_ONLINE_EDITION && wechatMpStatusCard} + {showWechatMp && wechatMpStatusCard} {loadingChannels ? ( loadingContent ) : channels.length > 0 ? ( @@ -605,7 +609,7 @@ export default function Notifications() { - {IS_ONLINE_EDITION && ( + {showWechatMp && ( <> { assert.equal(cn.consoleSettings.notifications.remove.description, "确定要移除接收端 \"{{name}}\" 吗?此操作不可撤销。"); assert.equal(en.consoleSettings.notifications.remove.description, "Remove receiver \"{{name}}\"? This action cannot be undone."); }); + +test("海外 SaaS 隐藏微信公众号绑定并保留企业微信机器人", () => { + assert.match(source, /useAppRuntime/); + assert.match( + source, + /const showWechatMp = shouldShowWechatMp\(IS_ONLINE_EDITION, serverConfig\?\.region\)/, + ); + assert.match(source, /\{showWechatMp && wechatMpStatusCard\}/); + assert.match( + source, + /\{showWechatMp && \([\s\S]* { + assert.equal(shouldShowWechatMp(true, "cn"), true); + assert.equal(shouldShowWechatMp(true, "global"), false); + assert.equal(shouldShowWechatMp(true, undefined), false); + assert.equal(shouldShowWechatMp(false, "cn"), false); +});