From 766c1201f40e907a98cd3f162c00f0e6a003f518 Mon Sep 17 00:00:00 2001 From: Uladzimir Havenchyk <125459446+uladzimirdev@users.noreply.github.com> Date: Wed, 1 May 2024 21:51:20 +0300 Subject: [PATCH] Drop unused isDashboardParameterWithoutMapping function (#42103) --- .../metabase/parameters/utils/dashboards.ts | 16 ---- .../parameters/utils/dashboards.unit.spec.js | 90 ------------------- 2 files changed, 106 deletions(-) diff --git a/frontend/src/metabase/parameters/utils/dashboards.ts b/frontend/src/metabase/parameters/utils/dashboards.ts index 2968e955048..e12b68b8b75 100644 --- a/frontend/src/metabase/parameters/utils/dashboards.ts +++ b/frontend/src/metabase/parameters/utils/dashboards.ts @@ -94,22 +94,6 @@ export function hasMapping(parameter: Parameter, dashboard: Dashboard) { }); } -export function isDashboardParameterWithoutMapping( - parameter: Parameter, - dashboard: Dashboard, -) { - if (!dashboard || !dashboard.parameters) { - return false; - } - - const parameterExistsOnDashboard = dashboard.parameters.some( - dashParam => dashParam.id === parameter.id, - ); - const parameterHasMapping = hasMapping(parameter, dashboard); - - return parameterExistsOnDashboard && !parameterHasMapping; -} - function getMappings(dashcards: QuestionDashboardCard[]): ExtendedMapping[] { return dashcards.flatMap(dashcard => { const { parameter_mappings, card, series } = dashcard; diff --git a/frontend/src/metabase/parameters/utils/dashboards.unit.spec.js b/frontend/src/metabase/parameters/utils/dashboards.unit.spec.js index 568dd440875..691d5e70b69 100644 --- a/frontend/src/metabase/parameters/utils/dashboards.unit.spec.js +++ b/frontend/src/metabase/parameters/utils/dashboards.unit.spec.js @@ -3,7 +3,6 @@ import { createParameter, setParameterName, hasMapping, - isDashboardParameterWithoutMapping, getParametersMappedToDashcard, hasMatchingParameters, getFilteringParameterValuesMap, @@ -192,95 +191,6 @@ describe("metabase/parameters/utils/dashboards", () => { }); }); - describe("isDashboardParameterWithoutMapping", () => { - const parameter = { id: "foo" }; - - it("should return false when passed a falsy dashboard", () => { - expect(isDashboardParameterWithoutMapping(parameter, undefined)).toBe( - false, - ); - }); - - it("should return false when the given parameter is not found in the dashboard's parameters list", () => { - const brokenDashboard = { - dashcards: [ - { - parameter_mappings: [ - { - parameter_id: "bar", - }, - { - // having this parameter mapped but not in the parameters list shouldn't happen in practice, - // but I am proving the significance of having the parameter exist in the dashboard's parameters list - parameter_id: "foo", - }, - ], - }, - ], - parameters: [ - { - id: "bar", - }, - ], - }; - - expect( - isDashboardParameterWithoutMapping(parameter, brokenDashboard), - ).toBe(false); - }); - - it("should return false when the given parameter is both found in the dashboard's parameters and also mapped", () => { - const dashboard = { - dashcards: [ - { - parameter_mappings: [ - { - parameter_id: "bar", - }, - { - parameter_id: "foo", - }, - ], - }, - ], - parameters: [ - { - id: "bar", - }, - { id: "foo" }, - ], - }; - - expect(isDashboardParameterWithoutMapping(parameter, dashboard)).toBe( - false, - ); - }); - - it("should return true when the given parameter is found on the dashboard but is not mapped", () => { - const dashboard = { - dashcards: [ - { - parameter_mappings: [ - { - parameter_id: "bar", - }, - ], - }, - ], - parameters: [ - { - id: "bar", - }, - { id: "foo" }, - ], - }; - - expect(isDashboardParameterWithoutMapping(parameter, dashboard)).toBe( - true, - ); - }); - }); - describe("getParametersMappedToDashcard", () => { const dashboard = { parameters: [ -- GitLab