From 8516d15a4e54d8040635f8bf5536c43f4b0d9242 Mon Sep 17 00:00:00 2001 From: baonudesifeizhai <85092850+baonudesifeizhai@users.noreply.github.com> Date: Tue, 1 Jul 2025 04:58:00 -0400 Subject: [PATCH] fix: handle configure button for notion internal integration (#21412) --- .gitignore | 1 + .../console/auth/data_source_oauth.py | 2 +- dev/mypy-check | 2 +- .../data-source-notion/index.tsx | 19 ++++++++++++++++--- web/i18n/en-US/common.ts | 1 + 5 files changed, 20 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 8f82bea00..dd4673a3d 100644 --- a/.gitignore +++ b/.gitignore @@ -214,3 +214,4 @@ mise.toml # AI Assistant .roo/ +api/.env.backup diff --git a/api/controllers/console/auth/data_source_oauth.py b/api/controllers/console/auth/data_source_oauth.py index 1049f864c..4c9697cc3 100644 --- a/api/controllers/console/auth/data_source_oauth.py +++ b/api/controllers/console/auth/data_source_oauth.py @@ -41,7 +41,7 @@ class OAuthDataSource(Resource): if not internal_secret: return ({"error": "Internal secret is not set"},) oauth_provider.save_internal_access_token(internal_secret) - return {"data": ""} + return {"data": "internal"} else: auth_url = oauth_provider.get_authorization_url() return {"data": auth_url}, 200 diff --git a/dev/mypy-check b/dev/mypy-check index b1c2c969a..8a2342730 100755 --- a/dev/mypy-check +++ b/dev/mypy-check @@ -7,4 +7,4 @@ cd "$SCRIPT_DIR/.." # run mypy checks uv run --directory api --dev --with pip \ - python -m mypy --install-types --non-interactive ./ + python -m mypy --install-types --non-interactive --exclude venv ./ diff --git a/web/app/components/header/account-setting/data-source-page/data-source-notion/index.tsx b/web/app/components/header/account-setting/data-source-page/data-source-notion/index.tsx index 38efdcb1b..065ef91eb 100644 --- a/web/app/components/header/account-setting/data-source-page/data-source-notion/index.tsx +++ b/web/app/components/header/account-setting/data-source-page/data-source-notion/index.tsx @@ -9,6 +9,8 @@ import { useAppContext } from '@/context/app-context' import { fetchNotionConnection } from '@/service/common' import NotionIcon from '@/app/components/base/notion-icon' import { noop } from 'lodash-es' +import { useTranslation } from 'react-i18next' +import Toast from '@/app/components/base/toast' const Icon: FC<{ src: string @@ -33,6 +35,7 @@ const DataSourceNotion: FC = ({ const { isCurrentWorkspaceManager } = useAppContext() const [canConnectNotion, setCanConnectNotion] = useState(false) const { data } = useSWR(canConnectNotion ? '/oauth/data-source/notion' : null, fetchNotionConnection) + const { t } = useTranslation() const connected = !!workspaces.length @@ -51,9 +54,19 @@ const DataSourceNotion: FC = ({ } useEffect(() => { - if (data?.data) - window.location.href = data.data - }, [data]) + if (data && 'data' in data) { + if (data.data && typeof data.data === 'string' && data.data.startsWith('http')) { + window.location.href = data.data + } + else if (data.data === 'internal') { + Toast.notify({ + type: 'info', + message: t('common.dataSource.notion.integratedAlert'), + }) + } + } + }, [data, t]) + return (