Disallow Google Drive credential delete if connectors exist

This commit is contained in:
Weves
2024-01-08 15:48:52 -08:00
committed by Chris Weaver
parent e473ad0412
commit 4e3d57b1b9
3 changed files with 12 additions and 1 deletions

View File

@@ -19,5 +19,5 @@ pnpm dev
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
*Note:* if you are having problems accessing the ^, try setting the `WEB_DOMAIN` env variable to
_Note:_ if you are having problems accessing the ^, try setting the `WEB_DOMAIN` env variable to
`http://127.0.0.1:3000` and accessing it there.

View File

@@ -272,6 +272,7 @@ interface DriveCredentialSectionProps {
appCredentialData?: { client_id: string };
setPopup: (popupSpec: PopupSpec | null) => void;
refreshCredentials: () => void;
connectorExists: boolean;
}
export const DriveOAuthSection = ({
@@ -281,6 +282,7 @@ export const DriveOAuthSection = ({
appCredentialData,
setPopup,
refreshCredentials,
connectorExists,
}: DriveCredentialSectionProps) => {
const router = useRouter();
@@ -294,6 +296,14 @@ export const DriveOAuthSection = ({
</p>
<Button
onClick={async () => {
if (connectorExists) {
setPopup({
message:
"Cannot revoke access to Google Drive while any connector is still setup. Please delete all connectors, then try again.",
type: "error",
});
return;
}
await adminDeleteCredential(existingCredential.id);
setPopup({
message: "Successfully revoked access to Google Drive!",

View File

@@ -377,6 +377,7 @@ const Main = () => {
}
appCredentialData={appCredentialData}
serviceAccountKeyData={serviceAccountKeyData}
connectorExists={googleDriveConnectorIndexingStatuses.length > 0}
/>
<Title className="mb-2 mt-6 ml-auto mr-auto">