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
Show explore further toast only when a page has queries (#79530)
Kevin Kelleher0e5501550b7a
diff --git a/frontend/src/metabase/explorations/pages/ExplorationPage.tsx b/frontend/src/metabase/explorations/pages/ExplorationPage.tsxindex 69af01044fe..0816bf4be4b 100644--- a/frontend/src/metabase/explorations/pages/ExplorationPage.tsx+++ b/frontend/src/metabase/explorations/pages/ExplorationPage.tsx@@ -357,7 +357,7 @@ function ExplorationPageForId() {// Detect new threads (from "Explore further") and toast when their first// page lands. Threads arrive without pages while query planning is still- // running, so we wait for a page before marking a thread as seen.+ // running, so we wait for a page with queries before marking a thread as seen.const seenThreadIdsRef = useRef<Set<number> | null>(null);useEffect(() => {const threads = exploration?.threads;@@ -375,7 +375,9 @@ function ExplorationPageForId() {if (seen.has(thread.id)) {continue;}- const firstPage = thread.blocks?.flatMap((b) => b.pages ?? [])?.[0];+ const firstPage = thread.blocks?.flatMap((b) =>+ b.pages.filter((p) => p.query_ids.length > 0),+ )?.[0];if (!firstPage) {continue;}diff --git a/frontend/src/metabase/explorations/pages/ExplorationPage.unit.spec.tsx b/frontend/src/metabase/explorations/pages/ExplorationPage.unit.spec.tsxindex 9193df36a81..2537927c22a 100644--- a/frontend/src/metabase/explorations/pages/ExplorationPage.unit.spec.tsx+++ b/frontend/src/metabase/explorations/pages/ExplorationPage.unit.spec.tsx@@ -142,9 +142,10 @@ describe("ExplorationPage thread-ready toasts", () => {expect(sendToastMock).not.toHaveBeenCalled();});- it("waits for the first page before toasting about a new thread", async () => {+ it("waits for the first page with queries before toasting about a new thread", async () => {renderExplorationPage();+ // Thread arrives while query planning is still running — no pages yet.explorationData = makeExploration([getThreads(explorationData)[0],createThread({@@ -157,6 +158,26 @@ describe("ExplorationPage thread-ready toasts", () => {rerenderExplorationPage();expect(sendToastMock).not.toHaveBeenCalled();+ // A page can land before it has queries. The sidebar hides pages without+ // queries, so the toast must wait for the same readiness condition.+ explorationData = makeExploration([+ getThreads(explorationData)[0],+ makeThread(+ 2,+ "Revenue deep dive",+ [+ createPage({+ id: 200,+ name: "Follow-up page",+ query_ids: [],+ }),+ ],+ [],+ ),+ ]);+ rerenderExplorationPage();+ expect(sendToastMock).not.toHaveBeenCalled();+explorationData = makeExploration([getThreads(explorationData)[0],makeThread(