fix: handle configure button for notion internal integration (#21412)
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -214,3 +214,4 @@ mise.toml
|
|||||||
|
|
||||||
# AI Assistant
|
# AI Assistant
|
||||||
.roo/
|
.roo/
|
||||||
|
api/.env.backup
|
||||||
|
@@ -41,7 +41,7 @@ class OAuthDataSource(Resource):
|
|||||||
if not internal_secret:
|
if not internal_secret:
|
||||||
return ({"error": "Internal secret is not set"},)
|
return ({"error": "Internal secret is not set"},)
|
||||||
oauth_provider.save_internal_access_token(internal_secret)
|
oauth_provider.save_internal_access_token(internal_secret)
|
||||||
return {"data": ""}
|
return {"data": "internal"}
|
||||||
else:
|
else:
|
||||||
auth_url = oauth_provider.get_authorization_url()
|
auth_url = oauth_provider.get_authorization_url()
|
||||||
return {"data": auth_url}, 200
|
return {"data": auth_url}, 200
|
||||||
|
@@ -7,4 +7,4 @@ cd "$SCRIPT_DIR/.."
|
|||||||
|
|
||||||
# run mypy checks
|
# run mypy checks
|
||||||
uv run --directory api --dev --with pip \
|
uv run --directory api --dev --with pip \
|
||||||
python -m mypy --install-types --non-interactive ./
|
python -m mypy --install-types --non-interactive --exclude venv ./
|
||||||
|
@@ -9,6 +9,8 @@ import { useAppContext } from '@/context/app-context'
|
|||||||
import { fetchNotionConnection } from '@/service/common'
|
import { fetchNotionConnection } from '@/service/common'
|
||||||
import NotionIcon from '@/app/components/base/notion-icon'
|
import NotionIcon from '@/app/components/base/notion-icon'
|
||||||
import { noop } from 'lodash-es'
|
import { noop } from 'lodash-es'
|
||||||
|
import { useTranslation } from 'react-i18next'
|
||||||
|
import Toast from '@/app/components/base/toast'
|
||||||
|
|
||||||
const Icon: FC<{
|
const Icon: FC<{
|
||||||
src: string
|
src: string
|
||||||
@@ -33,6 +35,7 @@ const DataSourceNotion: FC<Props> = ({
|
|||||||
const { isCurrentWorkspaceManager } = useAppContext()
|
const { isCurrentWorkspaceManager } = useAppContext()
|
||||||
const [canConnectNotion, setCanConnectNotion] = useState(false)
|
const [canConnectNotion, setCanConnectNotion] = useState(false)
|
||||||
const { data } = useSWR(canConnectNotion ? '/oauth/data-source/notion' : null, fetchNotionConnection)
|
const { data } = useSWR(canConnectNotion ? '/oauth/data-source/notion' : null, fetchNotionConnection)
|
||||||
|
const { t } = useTranslation()
|
||||||
|
|
||||||
const connected = !!workspaces.length
|
const connected = !!workspaces.length
|
||||||
|
|
||||||
@@ -51,9 +54,19 @@ const DataSourceNotion: FC<Props> = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (data?.data)
|
if (data && 'data' in data) {
|
||||||
window.location.href = data.data
|
if (data.data && typeof data.data === 'string' && data.data.startsWith('http')) {
|
||||||
}, [data])
|
window.location.href = data.data
|
||||||
|
}
|
||||||
|
else if (data.data === 'internal') {
|
||||||
|
Toast.notify({
|
||||||
|
type: 'info',
|
||||||
|
message: t('common.dataSource.notion.integratedAlert'),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, [data, t])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Panel
|
<Panel
|
||||||
type={DataSourceType.notion}
|
type={DataSourceType.notion}
|
||||||
|
@@ -456,6 +456,7 @@ const translation = {
|
|||||||
connected: 'Connected',
|
connected: 'Connected',
|
||||||
disconnected: 'Disconnected',
|
disconnected: 'Disconnected',
|
||||||
changeAuthorizedPages: 'Change authorized pages',
|
changeAuthorizedPages: 'Change authorized pages',
|
||||||
|
integratedAlert: 'Notion is integrated via internal credential, no need to re-authorize.',
|
||||||
pagesAuthorized: 'Pages authorized',
|
pagesAuthorized: 'Pages authorized',
|
||||||
sync: 'Sync',
|
sync: 'Sync',
|
||||||
remove: 'Remove',
|
remove: 'Remove',
|
||||||
|
Reference in New Issue
Block a user