mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[Lens] Metric non-clickable if not filterable (#154212)
## Summary Closes https://github.com/elastic/kibana/issues/153621 In case metric is not filterable the cursor should not indicate that it is.  ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
This commit is contained in:
parent
affc44329b
commit
9bfd8b6ecb
2 changed files with 40 additions and 23 deletions
|
@ -1103,15 +1103,27 @@ describe('MetricVisComponent', function () {
|
|||
});
|
||||
|
||||
it('should do nothing if primary metric is not filterable', () => {
|
||||
const event: MetricElementEvent = {
|
||||
type: 'metricElementEvent',
|
||||
rowIndex: 1,
|
||||
columnIndex: 0,
|
||||
const props = {
|
||||
...defaultProps,
|
||||
filterable: false,
|
||||
};
|
||||
const metricComponent = shallow(
|
||||
<MetricVis
|
||||
config={{
|
||||
metric: {
|
||||
progressDirection: 'vertical',
|
||||
maxCols: 5,
|
||||
},
|
||||
dimensions: {
|
||||
metric: basePriceColumnId,
|
||||
},
|
||||
}}
|
||||
data={table}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
|
||||
fireFilter(event, false, true);
|
||||
|
||||
expect(fireEventSpy).not.toHaveBeenCalled();
|
||||
expect(metricComponent.find(Settings).props().onElementClick).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -362,22 +362,27 @@ export const MetricVis = ({
|
|||
]}
|
||||
baseTheme={baseTheme}
|
||||
onRenderChange={onRenderChange}
|
||||
onElementClick={(events) => {
|
||||
if (!filterable) {
|
||||
return;
|
||||
}
|
||||
events.forEach((event) => {
|
||||
if (isMetricElementEvent(event)) {
|
||||
const colIdx = breakdownByColumn
|
||||
? data.columns.findIndex((col) => col === breakdownByColumn)
|
||||
: data.columns.findIndex((col) => col === primaryMetricColumn);
|
||||
const rowLength = grid[0].length;
|
||||
fireEvent(
|
||||
buildFilterEvent(event.rowIndex * rowLength + event.columnIndex, colIdx, data)
|
||||
);
|
||||
}
|
||||
});
|
||||
}}
|
||||
onElementClick={
|
||||
filterable
|
||||
? (events) => {
|
||||
events.forEach((event) => {
|
||||
if (isMetricElementEvent(event)) {
|
||||
const colIdx = breakdownByColumn
|
||||
? data.columns.findIndex((col) => col === breakdownByColumn)
|
||||
: data.columns.findIndex((col) => col === primaryMetricColumn);
|
||||
const rowLength = grid[0].length;
|
||||
fireEvent(
|
||||
buildFilterEvent(
|
||||
event.rowIndex * rowLength + event.columnIndex,
|
||||
colIdx,
|
||||
data
|
||||
)
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
/>
|
||||
<Metric id="metric" data={grid} />
|
||||
</Chart>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue