The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
Keep the Google Drive modal closed until the connection status loads (#83009)
Nemanja Glumac32176e152af4
diff --git a/enterprise/frontend/src/metabase-enterprise/google_drive/GdriveConnectionModal.tsx b/enterprise/frontend/src/metabase-enterprise/google_drive/GdriveConnectionModal.tsxindex 41026515d95..3c4729db50d 100644--- a/enterprise/frontend/src/metabase-enterprise/google_drive/GdriveConnectionModal.tsx+++ b/enterprise/frontend/src/metabase-enterprise/google_drive/GdriveConnectionModal.tsx@@ -45,11 +45,13 @@ export function GdriveConnectionModal({const { data: { email: serviceAccountEmail } = {} } =useGetServiceAccountQuery(shouldShow ? undefined : skipToken);- const { data: gSheetData, error } = useGetGsheetsFolderQuery(- shouldShow ? undefined : skipToken,- );+ const {+ data: gSheetData,+ error,+ isLoading,+ } = useGetGsheetsFolderQuery(shouldShow ? undefined : skipToken);- if (!shouldShow) {+ if (!shouldShow || isLoading) {return null;}diff --git a/enterprise/frontend/src/metabase-enterprise/google_drive/GdriveConnectionModal.unit.spec.tsx b/enterprise/frontend/src/metabase-enterprise/google_drive/GdriveConnectionModal.unit.spec.tsxindex aa5f911ca37..14a7dadc7a9 100644--- a/enterprise/frontend/src/metabase-enterprise/google_drive/GdriveConnectionModal.unit.spec.tsx+++ b/enterprise/frontend/src/metabase-enterprise/google_drive/GdriveConnectionModal.unit.spec.tsx@@ -1,4 +1,5 @@import userEvent from "@testing-library/user-event";+import fetchMock from "fetch-mock";import {findRequests,@@ -22,9 +23,11 @@ import { GdriveConnectionModal } from "./GdriveConnectionModal";const setup = ({status,isAdmin = true,+ folderResponse,}: {status: GdrivePayload["status"];isAdmin?: boolean;+ folderResponse?: Promise<Partial<GdrivePayload>>;}) => {const settings = createMockSettings({"show-google-sheets-integration": true,@@ -39,6 +42,9 @@ const setup = ({setupGdriveGetFolderEndpoint({status,});+ if (folderResponse) {+ fetchMock.modifyRoute("gdrive-get-folder", { response: folderResponse });+ }setupGdriveServiceAccountEndpoint();@@ -62,6 +68,20 @@ describe("Google Drive > Connect / Disconnect modal", () => {expect(await screen.findByText("Disconnect")).toBeInTheDocument();});+ it("should not show connection modal while the connection status is loading", async () => {+ const { promise: folderResponse, resolve } =+ Promise.withResolvers<Partial<GdrivePayload>>();+ setup({ status: "active", folderResponse });++ await waitFor(() =>+ expect(fetchMock.callHistory.called("gdrive-get-folder")).toBe(true),+ );+ expect(screen.queryByText("Import Google Sheets")).not.toBeInTheDocument();++ resolve({ status: "active" });+ expect(await screen.findByText("Disconnect")).toBeInTheDocument();+ });+it("should show connection modal if not connected", async () => {setup({status: "not-connected",