Skip to content
Snippets Groups Projects
Unverified Commit 6e87634c authored by Paul Rosenzweig's avatar Paul Rosenzweig Committed by GitHub
Browse files

Only show line/area/bar buttons for line, area, bar, or combo charts (#10979)

parent b53ec3a0
No related branches found
No related tags found
No related merge requests found
......@@ -27,6 +27,8 @@ export default class ChartNestedSettingSeries extends React.Component {
const objectKey = object && getObjectKey(object);
const isSelected = single => objectKey === getObjectKey(single);
const display = object && object.card.display;
const isLineAreaBar = ["line", "area", "bar", "combo"].includes(display);
const isStacked = settings["stackable.stack_type"] != null;
return (
......@@ -58,7 +60,7 @@ export default class ChartNestedSettingSeries extends React.Component {
onChangeObjectSettings(single, { title: e.target.value })
}
/>
{!isStacked ? (
{isLineAreaBar && !isStacked ? (
<ButtonGroup
className="ml1 align-self-stretch"
value={settings.display}
......
import React from "react";
import { mount } from "enzyme";
// these tests use ChartSettings directly, but logic we're testing lives in ChartNestedSettingSeries
import ChartSettings from "metabase/visualizations/components/ChartSettings";
function getSeries(display) {
return [
{
card: { display, visualization_settings: {} },
data: {
rows: [["a", 1], ["b", 2]],
cols: [{ name: "foo" }, { name: "bar" }],
},
},
];
}
describe("ChartNestedSettingSeries", () => {
it("shouldn't show line/area/bar buttons for row charts", () => {
const settings = mount(
<ChartSettings
series={getSeries("row")}
initial={{ section: "Display" }}
/>,
);
expect(settings.find(".Icon-line")).toHaveLength(0);
expect(settings.find(".Icon-area")).toHaveLength(0);
expect(settings.find(".Icon-bar")).toHaveLength(0);
});
it("should show line/area/bar buttons for bar charts", () => {
const settings = mount(
<ChartSettings
series={getSeries("bar")}
initial={{ section: "Display" }}
/>,
);
expect(settings.find(".Icon-line")).toHaveLength(1);
expect(settings.find(".Icon-area")).toHaveLength(1);
expect(settings.find(".Icon-bar")).toHaveLength(1);
});
});
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