fix: handle configure button for notion internal integration (#21412)

This commit is contained in:
baonudesifeizhai
2025-07-01 04:58:00 -04:00
committed by GitHub
parent 4198a533ad
commit 8516d15a4e
5 changed files with 20 additions and 5 deletions

View File

@@ -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<Props> = ({
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<Props> = ({
}
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 (
<Panel
type={DataSourceType.notion}