diff --git a/.circleci/config.yml b/.circleci/config.yml index 53c5a8c658..8b7d0ae1fd 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -122,6 +122,8 @@ jobs: VITE_ENV='test' \ REACT_APP_BACKEND_BASE_URL=$BACKEND_BASE_URL_TEST \ REACT_APP_SLACK_CLIENT_ID=$SLACK_CLIENT_ID_TEST \ + VITE_GOOGLE_PICKER_API_KEY=$VITE_GOOGLE_PICKER_API_KEY \ + VITE_GOOGLE_APP_ID=$VITE_GOOGLE_APP_ID \ NODE_ENV='staging' \ npm run build - run: @@ -165,6 +167,8 @@ jobs: command: | REACT_APP_BACKEND_BASE_URL=$APP_SLACK_BACKEND_BASE_URL_PROD \ REACT_APP_SLACK_CLIENT_ID=$SLACK_CLIENT_ID_PROD \ + VITE_GOOGLE_PICKER_API_KEY=$VITE_GOOGLE_PICKER_API_KEY \ + VITE_GOOGLE_APP_ID=$VITE_GOOGLE_APP_ID \ NODE_ENV='production' \ npm run build - publish diff --git a/apps/drive-integration/.env.example b/apps/drive-integration/.env.example index 4908c1ded4..4d709d9b5c 100644 --- a/apps/drive-integration/.env.example +++ b/apps/drive-integration/.env.example @@ -12,3 +12,9 @@ VITE_ENABLE_MOCK_EDIT_MODAL= # Frontend (Vite): opt in to a local Agents API during development. VITE_LOCAL_AGENTS_API_BASE_URL= + +# Frontend (Vite): Google Picker API key (from GCP > APIs & Services > Credentials > Drive Integration API key). +VITE_GOOGLE_PICKER_API_KEY= + +# Frontend (Vite): Google Cloud project number (991777691184 for the Contentful Google Docs App project). +VITE_GOOGLE_APP_ID= diff --git a/apps/drive-integration/src/hooks/useGoogleDocPicker.tsx b/apps/drive-integration/src/hooks/useGoogleDocPicker.tsx index 3a37b8a197..ff4faca206 100644 --- a/apps/drive-integration/src/hooks/useGoogleDocPicker.tsx +++ b/apps/drive-integration/src/hooks/useGoogleDocPicker.tsx @@ -15,9 +15,9 @@ type UseGoogleDocsPickerOptions = { onCancel?: () => void; }; -const GOOGLE_PICKER_API_KEY = ''; +const GOOGLE_PICKER_API_KEY = import.meta.env.VITE_GOOGLE_PICKER_API_KEY ?? ''; -const GOOGLE_APP_ID = 1; +const GOOGLE_APP_ID = import.meta.env.VITE_GOOGLE_APP_ID ?? ''; // These are already exposed by google in the network even if they were hidden as environment variables // and google acknowledges that these are okay to be public and that restrictions come from defining the diff --git a/apps/drive-integration/src/hooks/useWorkflowAgent.ts b/apps/drive-integration/src/hooks/useWorkflowAgent.ts index 8d35961c28..662f85235b 100644 --- a/apps/drive-integration/src/hooks/useWorkflowAgent.ts +++ b/apps/drive-integration/src/hooks/useWorkflowAgent.ts @@ -123,6 +123,14 @@ const getBackendWorkflowFailureReason = (runData: AgentRunData): WorkflowFailure return WorkflowFailureReason.GOOGLE_DRIVE_AUTH_EXPIRED; } + if (workflowFailure.code === WorkflowFailureReason.GOOGLE_DOCS_NOT_FOUND) { + return WorkflowFailureReason.GOOGLE_DOCS_NOT_FOUND; + } + + if (workflowFailure.code === WorkflowFailureReason.AI_SERVICE_UNAVAILABLE) { + return WorkflowFailureReason.AI_SERVICE_UNAVAILABLE; + } + if (workflowFailure.code === WorkflowFailureReason.GENERIC) { return WorkflowFailureReason.GENERIC; } @@ -138,6 +146,14 @@ const getWorkflowFailureMessage = ( return ERROR_MESSAGES.GOOGLE_DRIVE_AUTH_ERROR; } + if (failureReason === WorkflowFailureReason.GOOGLE_DOCS_NOT_FOUND) { + return ERROR_MESSAGES.GOOGLE_DOCS_NOT_FOUND; + } + + if (failureReason === WorkflowFailureReason.AI_SERVICE_UNAVAILABLE) { + return ERROR_MESSAGES.AI_SERVICE_UNAVAILABLE; + } + return getRunErrorMessage(runData); }; diff --git a/apps/drive-integration/src/locations/Page/components/mainpage/ModalOrchestrator.tsx b/apps/drive-integration/src/locations/Page/components/mainpage/ModalOrchestrator.tsx index 1311789f2e..b343e441c0 100644 --- a/apps/drive-integration/src/locations/Page/components/mainpage/ModalOrchestrator.tsx +++ b/apps/drive-integration/src/locations/Page/components/mainpage/ModalOrchestrator.tsx @@ -163,6 +163,30 @@ export const ModalOrchestrator = forwardRef