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
When navigating with browser back/forward buttons, re-run the query only when the existing query results are dirty (#63092)
Alexander Polyankin500e03902314
diff --git a/e2e/test/scenarios/models/reproductions.cy.spec.ts b/e2e/test/scenarios/models/reproductions.cy.spec.tsindex 602831a84a7..2eee331ccb0 100644--- a/e2e/test/scenarios/models/reproductions.cy.spec.ts+++ b/e2e/test/scenarios/models/reproductions.cy.spec.ts@@ -1217,7 +1217,7 @@ describe("issue 34514", () => {assertBackToEmptyState();});- it("should allow browser history navigation between tabs (metabase#34514)", () => {+ it("should allow browser history navigation between tabs (metabase#34514, metabase#45787)", () => {H.entityPickerModal().within(() => {H.entityPickerModalTab("Tables").click();cy.wait("@fetchTables");@@ -1230,13 +1230,15 @@ describe("issue 34514", () => {cy.findByTestId("editor-tabs-columns-name").click();assertMetadataTabState();+ cy.get("@dataset.all").should("have.length", 1);cy.go("back");- cy.wait(["@dataset", "@fetchDatabase"]); // This should be removed when (metabase#45787) is fixedassertQueryTabState();+ cy.get("@dataset.all").should("have.length", 1);cy.go("back");assertBackToEmptyState();+ cy.get("@dataset.all").should("have.length", 1);});function assertQueryTabState() {diff --git a/frontend/src/metabase/query_builder/actions/core/core.ts b/frontend/src/metabase/query_builder/actions/core/core.tsindex b1b7a6db714..8d6560cf251 100644--- a/frontend/src/metabase/query_builder/actions/core/core.ts+++ b/frontend/src/metabase/query_builder/actions/core/core.ts@@ -44,7 +44,11 @@ import {getSubmittableQuestion,isBasedOnExistingQuestion,} from "../../selectors";-import { clearQueryResult, runQuestionQuery } from "../querying";+import {+ clearQueryResult,+ runDirtyQuestionQuery,+ runQuestionQuery,+} from "../querying";import { onCloseSidebars } from "../ui";import { updateUrl } from "../url";import { zoomInRow } from "../zoom";@@ -121,7 +125,7 @@ export const setCardAndRun = (// Update the card and originalCard before running the actual querydispatch({ type: SET_CARD_AND_RUN, payload: { card, originalCard } });- dispatch(runQuestionQuery({ shouldUpdateUrl }));+ dispatch(runDirtyQuestionQuery({ shouldUpdateUrl }));// Load table & database metadata for the current questiondispatch(loadMetadataForCard(card));diff --git a/frontend/src/metabase/query_builder/actions/querying.ts b/frontend/src/metabase/query_builder/actions/querying.tsindex 5f992da5536..266269c7800 100644--- a/frontend/src/metabase/query_builder/actions/querying.ts+++ b/frontend/src/metabase/query_builder/actions/querying.ts@@ -85,8 +85,13 @@ const loadErrorUIControls = createThunkAction(},);+type RunDirtyQuestionQueryOpts = {+ shouldUpdateUrl?: boolean;+};+export const runDirtyQuestionQuery =- () => async (dispatch: Dispatch, getState: GetState) => {+ ({ shouldUpdateUrl }: RunDirtyQuestionQueryOpts = {}) =>+ async (dispatch: Dispatch, getState: GetState) => {const areResultsDirty = getIsResultDirty(getState());const queryResults = getQueryResults(getState());@@ -100,7 +105,7 @@ export const runDirtyQuestionQuery =return dispatch(queryCompleted(question, queryResults));}- return dispatch(runQuestionQuery());+ return dispatch(runQuestionQuery({ shouldUpdateUrl }));};/**