Skip to content

Commit

Permalink
Merge branch 'fix/notion-sync' into deploy/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
zxhlyh committed Sep 28, 2023
2 parents 25d3176 + efb4f7f commit 2a0ac4b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions api/controllers/console/auth/data_source_oauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ def get(self, provider: str):
if current_app.config.get('NOTION_INTEGRATION_TYPE') == 'internal':
internal_secret = current_app.config.get('NOTION_INTERNAL_SECRET')
oauth_provider.save_internal_access_token(internal_secret)
return redirect(f'{current_app.config.get("CONSOLE_WEB_URL")}?oauth_data_source=success')
return { 'data': f'{current_app.config.get("CONSOLE_WEB_URL")}?oauth_data_source=success' }
else:
auth_url = oauth_provider.get_authorization_url()
return redirect(auth_url)
return { 'data': auth_url }, 200



Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState } from 'react'
import { useEffect, useState } from 'react'
import useSWR from 'swr'
import { useTranslation } from 'react-i18next'
import { PlusIcon } from '@heroicons/react/24/solid'
Expand All @@ -20,7 +20,7 @@ const DataSourceNotion = ({
const { t } = useTranslation()
const { isCurrentWorkspaceManager } = useAppContext()
const [canConnectNotion, setCanConnectNotion] = useState(false)
useSWR(canConnectNotion ? '/oauth/data-source/notion' : null, fetchNotionConnection)
const { data } = useSWR(canConnectNotion ? '/oauth/data-source/notion' : null, fetchNotionConnection)

const connected = !!workspaces.length

Expand All @@ -31,6 +31,11 @@ const DataSourceNotion = ({
setCanConnectNotion(true)
}

useEffect(() => {
if (data?.data)
window.location.href = data.data
}, [data])

return (
<div className='mb-2 border-[0.5px] border-gray-200 bg-gray-50 rounded-xl'>
<div className='flex items-center px-3 py-[9px]'>
Expand Down
4 changes: 2 additions & 2 deletions web/service/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,6 @@ export const fetchFreeQuotaVerify: Fetcher<{ result: string; flag: boolean; reas
return get(url) as Promise<{ result: string; flag: boolean; reason: string }>
}

export const fetchNotionConnection: Fetcher<CommonResponse, string> = (url) => {
return get(url) as Promise<CommonResponse>
export const fetchNotionConnection: Fetcher<{ data: string }, string> = (url) => {
return get(url) as Promise<{ data: string }>
}

0 comments on commit 2a0ac4b

Please sign in to comment.