Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

keep timeline event choices when the dashboard changes (#83851)

Uladzimir Havenchykeb83504d8ee0
diff --git a/e2e/test/scenarios/organization/timelines-dashboard.cy.spec.ts b/e2e/test/scenarios/organization/timelines-dashboard.cy.spec.ts
index bbef3914cbe..7939c6d1002 100644
--- a/e2e/test/scenarios/organization/timelines-dashboard.cy.spec.ts
+++ b/e2e/test/scenarios/organization/timelines-dashboard.cy.spec.ts
@@ -117,6 +117,15 @@ describe("scenarios > organization > timelines > dashboard", () => {
cy.get("@questionUpdates").should("not.have.been.called");
cy.get("@dashboardUpdates").should("not.have.been.called");
+ cy.intercept("GET", "/api/dashboard/*").as("getDashboard");
+ cy.findByTestId("dashboard-name-heading").type(" renamed").blur();
+ cy.wait("@getDashboard");
+ eventChip(1, "RC1").should("be.visible");
+ eventsSidebar().within(() => {
+ H.timelineEventVisibility("RC1").should("not.be.checked");
+ });
+ eventChip(0, "RC1").should("not.exist");
+
cy.reload();
H.waitForDashcardsToLoad({ count: 2 });
eventChip(0, "RC1").should("be.visible");
diff --git a/frontend/src/metabase/dashboard/reducers-typed.ts b/frontend/src/metabase/dashboard/reducers-typed.ts
index cd1e4604079..ff2b8616fc8 100644
--- a/frontend/src/metabase/dashboard/reducers-typed.ts
+++ b/frontend/src/metabase/dashboard/reducers-typed.ts
@@ -223,14 +223,6 @@ export const timelineEvents = createReducer(
...INITIAL_DASHBOARD_STATE.timelineEvents,
hasTrackedEventsShown: state.hasTrackedEventsShown,
}));
- builder.addCase(fetchDashboard.fulfilled, (state) => {
- if (Object.keys(state.overrides).length > 0) {
- state.overrides = {};
- }
- if (Object.keys(state.enabledByDashCard).length > 0) {
- state.enabledByDashCard = {};
- }
- });
builder.addCase(CLOSE_SIDEBAR, (state) => {
state.selection = null;
});
diff --git a/frontend/src/metabase/dashboard/reducers.unit.spec.ts b/frontend/src/metabase/dashboard/reducers.unit.spec.ts
index 232c476a0c6..d7dde2baff2 100644
--- a/frontend/src/metabase/dashboard/reducers.unit.spec.ts
+++ b/frontend/src/metabase/dashboard/reducers.unit.spec.ts
@@ -474,17 +474,23 @@ describe("dashboard reducers", () => {
const overriddenState = () =>
reducer(
- selectedState(),
- setDashCardTimelineEventsVisibility({
- 1: { "timeline.selected_timeline_ids": [10] },
- }),
+ reducer(
+ selectedState(),
+ setDashCardTimelineEventsVisibility({
+ 1: { "timeline.selected_timeline_ids": [10] },
+ }),
+ ),
+ setDashCardTimelineEventsEnabled({ dashcardId: 1, isEnabled: false }),
);
- it("resets when dashboard editing starts", () => {
- const state = reducer(overriddenState(), {
- type: SET_EDITING_DASHBOARD,
- payload: TEST_DASHBOARD,
- });
+ it.each([
+ {
+ name: "dashboard editing starts",
+ action: { type: SET_EDITING_DASHBOARD, payload: TEST_DASHBOARD },
+ },
+ { name: "another dashboard is opened", action: { type: INITIALIZE } },
+ ])("resets when $name", ({ action }) => {
+ const state = reducer(overriddenState(), action);
expect(state.timelineEvents).toEqual({
overrides: {},
enabledByDashCard: {},
@@ -493,17 +499,16 @@ describe("dashboard reducers", () => {
});
});
- it("drops the session overrides when the dashboard is refetched", () => {
- const overridden = reducer(
- overriddenState(),
- setDashCardTimelineEventsEnabled({ dashcardId: 1, isEnabled: false }),
- );
- const state = timelineEvents(overridden.timelineEvents, {
+ it("keeps the session overrides when the dashboard is refetched", () => {
+ const state = timelineEvents(overriddenState().timelineEvents, {
type: fetchDashboard.fulfilled.type,
});
- expect(state.overrides).toEqual({});
- expect(state.enabledByDashCard).toEqual({});
- expect(state.selection).toEqual({ dashcardId: 1, eventIds: [100] });
+ expect(state).toEqual({
+ overrides: { 1: { "timeline.selected_timeline_ids": [10] } },
+ enabledByDashCard: { 1: false },
+ selection: { dashcardId: 1, eventIds: [100] },
+ hasTrackedEventsShown: false,
+ });
});
});