mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-07-15 15:43:16 +02:00
Add root_page_id option for Notion connector
This commit is contained in:
@ -82,6 +82,7 @@ class NotionConnector(LoadConnector, PollConnector):
|
||||
"Notion-Version": "2022-06-28",
|
||||
}
|
||||
self.indexed_pages: set[str] = set()
|
||||
self.root_page_id = root_page_id
|
||||
# if enabled, will recursively index child pages as they are found rather
|
||||
# relying entirely on the `search` API. We have recieved reports that the
|
||||
# `search` API misses many pages - in those cases, this might need to be
|
||||
@ -89,8 +90,9 @@ class NotionConnector(LoadConnector, PollConnector):
|
||||
# NOTE: this also removes all benefits polling, since we need to traverse
|
||||
# all pages regardless of if they are updated. If the notion workspace is
|
||||
# very large, this may not be practical.
|
||||
self.recursive_index_enabled = recursive_index_enabled
|
||||
self.root_page_id = root_page_id
|
||||
self.recursive_index_enabled = (
|
||||
recursive_index_enabled or self.root_page_id is not None
|
||||
)
|
||||
|
||||
@retry(tries=3, delay=1, backoff=2)
|
||||
def _fetch_blocks(self, block_id: str, cursor: str | None = None) -> dict[str, Any]:
|
||||
|
@ -144,17 +144,26 @@ const Main = () => {
|
||||
</>
|
||||
)}
|
||||
|
||||
<h2 className="font-bold mb-2 mt-6 ml-auto mr-auto">
|
||||
Step 2: Manage Connectors
|
||||
</h2>
|
||||
{notionConnectorIndexingStatuses.length > 0 && (
|
||||
<>
|
||||
<h2 className="font-bold mb-2 mt-6 ml-auto mr-auto">
|
||||
Notion indexing status
|
||||
</h2>
|
||||
<p className="text-sm mb-2">
|
||||
The latest page updates are fetched from Notion every 10 minutes.
|
||||
</p>
|
||||
<div className="mb-2">
|
||||
<ConnectorsTable<NotionConfig, NotionCredentialJson>
|
||||
connectorIndexingStatuses={notionConnectorIndexingStatuses}
|
||||
specialColumns={[
|
||||
{
|
||||
header: "Root Page ID",
|
||||
key: "root_page_id",
|
||||
getValue: (ccPairStatus) =>
|
||||
ccPairStatus.connector.connector_specific_config
|
||||
.root_page_id || "-",
|
||||
},
|
||||
]}
|
||||
liveCredential={notionCredential}
|
||||
getCredential={(credential) => {
|
||||
return (
|
||||
@ -177,21 +186,43 @@ const Main = () => {
|
||||
</>
|
||||
)}
|
||||
|
||||
{notionCredential && notionConnectorIndexingStatuses.length === 0 && (
|
||||
{notionCredential && (
|
||||
<>
|
||||
<div className="border-solid border-gray-600 border rounded-md p-6 mt-4">
|
||||
<h2 className="font-bold mb-3">Create Connection</h2>
|
||||
<h2 className="font-bold mb-1">Create New Connection</h2>
|
||||
<p className="text-sm mb-4">
|
||||
Press connect below to start the connection to Notion.
|
||||
</p>
|
||||
<ConnectorForm<NotionConfig>
|
||||
nameBuilder={() => `NotionConnector`}
|
||||
ccPairNameBuilder={() => `Notion`}
|
||||
nameBuilder={(values) =>
|
||||
values.root_page_id
|
||||
? `NotionConnector-${values.root_page_id}`
|
||||
: "NotionConnector"
|
||||
}
|
||||
ccPairNameBuilder={(values) =>
|
||||
values.root_page_id ? `Notion-${values.root_page_id}` : "Notion"
|
||||
}
|
||||
source="notion"
|
||||
inputType="poll"
|
||||
formBody={<></>}
|
||||
validationSchema={Yup.object().shape({})}
|
||||
initialValues={{}}
|
||||
formBody={
|
||||
<>
|
||||
<TextFormField
|
||||
name="root_page_id"
|
||||
label="[Optional] Root Page ID"
|
||||
subtext={
|
||||
"If specified, will only index the specified page + all of its child pages. " +
|
||||
"If left blank, will index all pages the integration has been given access to."
|
||||
}
|
||||
autoCompleteDisabled={true}
|
||||
/>
|
||||
</>
|
||||
}
|
||||
validationSchema={Yup.object().shape({
|
||||
root_page_id: Yup.string(),
|
||||
})}
|
||||
initialValues={{
|
||||
root_page_id: "",
|
||||
}}
|
||||
refreshFreq={10 * 60} // 10 minutes
|
||||
credentialId={notionCredential.id}
|
||||
/>
|
||||
|
@ -116,7 +116,9 @@ export interface ZulipConfig {
|
||||
realm_url: string;
|
||||
}
|
||||
|
||||
export interface NotionConfig {}
|
||||
export interface NotionConfig {
|
||||
root_page_id?: string;
|
||||
}
|
||||
|
||||
export interface HubSpotConfig {}
|
||||
|
||||
|
Reference in New Issue
Block a user