diff --git a/backend/danswer/connectors/notion/connector.py b/backend/danswer/connectors/notion/connector.py index 11961be5fa9..fd3de72b15e 100644 --- a/backend/danswer/connectors/notion/connector.py +++ b/backend/danswer/connectors/notion/connector.py @@ -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]: diff --git a/web/src/app/admin/connectors/notion/page.tsx b/web/src/app/admin/connectors/notion/page.tsx index 0be36bc1a1a..be8401633f0 100644 --- a/web/src/app/admin/connectors/notion/page.tsx +++ b/web/src/app/admin/connectors/notion/page.tsx @@ -144,17 +144,26 @@ const Main = () => { )} +

+ Step 2: Manage Connectors +

{notionConnectorIndexingStatuses.length > 0 && ( <> -

- Notion indexing status -

The latest page updates are fetched from Notion every 10 minutes.

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 && ( <>
-

Create Connection

+

Create New Connection

Press connect below to start the connection to Notion.

- 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={ + <> + + + } + validationSchema={Yup.object().shape({ + root_page_id: Yup.string(), + })} + initialValues={{ + root_page_id: "", + }} refreshFreq={10 * 60} // 10 minutes credentialId={notionCredential.id} /> diff --git a/web/src/lib/types.ts b/web/src/lib/types.ts index f692424c183..9a7840fc413 100644 --- a/web/src/lib/types.ts +++ b/web/src/lib/types.ts @@ -116,7 +116,9 @@ export interface ZulipConfig { realm_url: string; } -export interface NotionConfig {} +export interface NotionConfig { + root_page_id?: string; +} export interface HubSpotConfig {}