diff --git a/frontend/src/metabase/parameters/utils/dashboards.ts b/frontend/src/metabase/parameters/utils/dashboards.ts index 2968e9550483531dcbf6cfa15503dd7e5758f68a..e12b68b8b75502307e0a72657b1f8590ab056c35 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 568dd4408758a8859ce1ccec0518e1b9f49d9aec..691d5e70b69c7343e32b8a80cf6c3a04650ee15f 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: [