diff --git a/web/src/app/admin/connectors/google-drive/page.tsx b/web/src/app/admin/connectors/google-drive/page.tsx index 4426f6d0e03..ada615c0221 100644 --- a/web/src/app/admin/connectors/google-drive/page.tsx +++ b/web/src/app/admin/connectors/google-drive/page.tsx @@ -93,6 +93,351 @@ const AppCredentialUpload = ({ ); }; +interface GoogleDriveConnectorManagementProps { + googleDrivePublicCredential: + | Credential + | undefined; + googleDriveConnectorIndexingStatus: ConnectorIndexingStatus<{}> | null; + credentialIsLinked: boolean; + setPopup: (popupSpec: PopupSpec | null) => void; +} + +const GoogleDriveConnectorManagement = ({ + googleDrivePublicCredential, + googleDriveConnectorIndexingStatus, + credentialIsLinked, + setPopup, +}: GoogleDriveConnectorManagementProps) => { + const { mutate } = useSWRConfig(); + + if (!googleDrivePublicCredential) { + return ( +

+ Please authenticate with Google Drive as described in Step 2! Once done + with that, you can then move on to enable this connector. +

+ ); + } + + // NOTE: if the connector has no credential linked, then it will not be + // returned by the indexing-status API + if (!googleDriveConnectorIndexingStatus) { + return ( + <> +

+ Click the button below to create a connector. We will refresh the + latest documents from Google Drive every 10 minutes. +

+ + + ); + } + + // If the connector has no credential, we will just hit the ^ section. + // Leaving this in for now in case we want to change this behavior later + // if (!credentialIsLinked) { + // <> + //

+ // Click the button below to link your credentials! Once this is done, all + // public documents in your Google Drive will be searchable. We will + // refresh the latest documents every 10 minutes. + //

+ // + // ; + // } + + return ( +
+
+
+ The Google Drive connector is setup! Status:{" "} + { + mutate("/api/manage/admin/connector/indexing-status"); + }} + /> +
+

+ Checkout the{" "} + + status page + {" "} + for the latest indexing status. We fetch the latest documents from + Google Drive every 10 minutes. +

+
+ +
+ ); + + // return ( + // <> + // {googleDrivePublicCredential ? ( + // googleDriveConnectorIndexingStatus ? ( + // credentialIsLinked ? ( + //
+ //
+ //
+ // The Google Drive connector is setup!{" "} + // Status:{" "} + // { + // mutate("/api/manage/admin/connector/indexing-status"); + // }} + // /> + //
+ //

+ // Checkout the{" "} + // + // status page + // {" "} + // for the latest indexing status. We fetch the latest documents + // from Google Drive every 10 minutes. + //

+ //
+ // + //
+ // ) : ( + // <> + //

+ // Click the button below to link your credentials! Once this is + // done, all public documents in your Google Drive will be + // searchable. We will refresh the latest documents every 10{" "} + // minutes. + //

+ // + // + // ) + // ) : ( + // <> + //

+ // Click the button below to create a connector. We will refresh the + // latest documents from Google Drive every 10 minutes. + //

+ // + // + // ) + // ) : ( + //

+ // Please authenticate with Google Drive as described in Step 2! Once + // done with that, you can then move on to enable this connector. + //

+ // )} + // + // ); +}; + const Main = () => { const router = useRouter(); const { mutate } = useSWRConfig(); @@ -303,146 +648,12 @@ const Main = () => {

Step 3: Start Indexing!

- {googleDrivePublicCredential ? ( - googleDriveConnectorIndexingStatus ? ( - credentialIsLinked ? ( -
-
-
- The Google Drive connector is setup!{" "} - Status:{" "} - { - mutate("/api/manage/admin/connector/indexing-status"); - }} - /> -
-

- Checkout the{" "} - - status page - {" "} - for the latest indexing status. We fetch the latest documents - from Google Drive every 10 minutes. -

-
- -
- ) : ( - <> -

- Click the button below to link your credentials! Once this is - done, all public documents in your Google Drive will be - searchable. We will refresh the latest documents every 10{" "} - minutes. -

- - - ) - ) : ( - <> -

- Click the button below to create a connector. We will refresh the - latest documents from Google Drive every 10 minutes. -

- - - ) - ) : ( -

- Please authenticate with Google Drive as described in Step 2! Once - done with that, you can then move on to enable this connector. -

- )} + ); }; diff --git a/web/src/components/admin/connectors/table/ConnectorsTable.tsx b/web/src/components/admin/connectors/table/ConnectorsTable.tsx index 9a6f698693f..e113968461e 100644 --- a/web/src/components/admin/connectors/table/ConnectorsTable.tsx +++ b/web/src/components/admin/connectors/table/ConnectorsTable.tsx @@ -173,11 +173,18 @@ export function ConnectorsTable({
{ - deleteConnector(connector.id).then(() => { - setPopup({ - message: "Successfully deleted connector", - type: "success", - }); + deleteConnector(connector.id).then((errorMsg) => { + if (errorMsg) { + setPopup({ + message: `Unable to delete existing connector - ${errorMsg}`, + type: "error", + }); + } else { + setPopup({ + message: "Successfully deleted connector", + type: "success", + }); + } setTimeout(() => { setPopup(null); }, 4000); diff --git a/web/src/lib/connector.ts b/web/src/lib/connector.ts index ed9e337aa83..2a79503a074 100644 --- a/web/src/lib/connector.ts +++ b/web/src/lib/connector.ts @@ -36,16 +36,19 @@ export async function updateConnector( return await response.json(); } -export async function deleteConnector( +export async function deleteConnector( connectorId: number -): Promise> { +): Promise { const response = await fetch(`/api/manage/admin/connector/${connectorId}`, { method: "DELETE", headers: { "Content-Type": "application/json", }, }); - return await response.json(); + if (response.ok) { + return null; + } + return (await response.json()).detail; } export async function runConnector(