Skip to content
Snippets Groups Projects
Unverified Commit 766c1201 authored by Uladzimir Havenchyk's avatar Uladzimir Havenchyk Committed by GitHub
Browse files

Drop unused isDashboardParameterWithoutMapping function (#42103)

parent 0dc75042
No related branches found
No related tags found
No related merge requests found
......@@ -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;
......
......@@ -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: [
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment