Skip to content
Snippets Groups Projects
Unverified Commit d550a27e authored by Aleksandr Lesnenko's avatar Aleksandr Lesnenko Committed by GitHub
Browse files

fix dashcards crash (#31044)

parent ffacb252
No related branches found
No related tags found
No related merge requests found
import { t } from "ttag";
import { assocIn } from "icepick";
import { getVisualizationRaw } from "metabase/visualizations";
import { isVirtualDashCard } from "metabase/dashboard/utils";
import { normalizeFieldRef } from "metabase-lib/queries/utils/dataset";
......@@ -64,12 +65,14 @@ function normalizeColumnSettings(columnSettings) {
}
export function getStoredSettingsForSeries(series) {
const storedSettings =
let storedSettings =
(series && series[0] && series[0].card.visualization_settings) || {};
if (storedSettings.column_settings) {
// normalize any settings stored under old style keys: [ref, [fk->, 1, 2]]
storedSettings.column_settings = normalizeColumnSettings(
storedSettings.column_settings,
storedSettings = assocIn(
storedSettings,
["column_settings"],
normalizeColumnSettings(storedSettings.column_settings),
);
}
return storedSettings;
......
import icepick from "icepick";
// NOTE: need to load visualizations first for getSettings to work
import "metabase/visualizations/index";
......@@ -164,6 +165,30 @@ describe("visualization_settings", () => {
]);
expect(settings).toEqual({ foo: "bar" });
});
it("should work correctly with frozen objects", () => {
const settings = getStoredSettingsForSeries(
icepick.freeze([
{
card: {
visualization_settings: {
column_settings: {
'["name","A"]': {
number_style: "currency",
},
},
},
},
},
]),
);
expect(settings).toEqual({
column_settings: {
'["name","A"]': {
number_style: "currency",
},
},
});
});
});
describe("table.cell_column", () => {
it("should pick the first metric column", () => {
......
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