Skip to content

Commit ef1f1bc

Browse files
Wylie Conlonwylieconlon
authored andcommitted
[Lens] Fix bug in metric config panel (#60982)
* [Lens] Fix bug in metric config panel * Fix test
1 parent 7c4c3b1 commit ef1f1bc

2 files changed

Lines changed: 41 additions & 1 deletion

File tree

x-pack/legacy/plugins/lens/public/metric_visualization/metric_visualization.test.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,46 @@ describe('metric_visualization', () => {
7272
});
7373
});
7474

75+
describe('#getConfiguration', () => {
76+
it('can add a metric when there is no accessor', () => {
77+
expect(
78+
metricVisualization.getConfiguration({
79+
state: {
80+
accessor: undefined,
81+
layerId: 'l1',
82+
},
83+
layerId: 'l1',
84+
frame: mockFrame(),
85+
})
86+
).toEqual({
87+
groups: [
88+
expect.objectContaining({
89+
supportsMoreColumns: true,
90+
}),
91+
],
92+
});
93+
});
94+
95+
it('is not allowed to add a metric once one accessor is set', () => {
96+
expect(
97+
metricVisualization.getConfiguration({
98+
state: {
99+
accessor: 'a',
100+
layerId: 'l1',
101+
},
102+
layerId: 'l1',
103+
frame: mockFrame(),
104+
})
105+
).toEqual({
106+
groups: [
107+
expect.objectContaining({
108+
supportsMoreColumns: false,
109+
}),
110+
],
111+
});
112+
});
113+
});
114+
75115
describe('#setDimension', () => {
76116
it('sets the accessor', () => {
77117
expect(

x-pack/legacy/plugins/lens/public/metric_visualization/metric_visualization.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ export const metricVisualization: Visualization<State, PersistableState> = {
9494
groupLabel: i18n.translate('xpack.lens.metric.label', { defaultMessage: 'Metric' }),
9595
layerId: props.state.layerId,
9696
accessors: props.state.accessor ? [props.state.accessor] : [],
97-
supportsMoreColumns: false,
97+
supportsMoreColumns: !props.state.accessor,
9898
filterOperations: (op: OperationMetadata) => !op.isBucketed && op.dataType === 'number',
9999
},
100100
],

0 commit comments

Comments
 (0)