mirror of
https://github.com/elastic/kibana.git
synced 2025-04-25 02:09:32 -04:00
[8.x] [Lens] Disable config axis side and color picker when groupid is breakdown and collaseFn enable (#195845) (#196247)
# Backport This will backport the following commits from `main` to `8.x`: - [[Lens] Disable config axis side and color picker when groupid is breakdown and collaseFn enable (#195845)](https://github.com/elastic/kibana/pull/195845) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Linghao Su","email":"linghao.su@daocloud.io"},"sourceCommit":{"committedDate":"2024-10-14T07:54:11Z","message":"[Lens] Disable config axis side and color picker when groupid is breakdown and collaseFn enable (#195845)\n\n## Summary\r\nFixes https://github.com/elastic/kibana/issues/195481\r\n\r\nFor XY charts only, when opening the breakdown dimension editor, we\r\ndisable the color picker and axis side configuration.\r\n\r\n## Before\r\n\r\n\r\n\r\n\r\n## After\r\n\r\n\r\n.(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:Visualizations","Feature:Lens","💝community","v9.0.0","backport:prev-minor","v8.16.0"],"title":"[Lens] Disable config axis side and color picker when groupid is breakdown and collaseFn enable","number":195845,"url":"https://github.com/elastic/kibana/pull/195845","mergeCommit":{"message":"[Lens] Disable config axis side and color picker when groupid is breakdown and collaseFn enable (#195845)\n\n## Summary\r\nFixes https://github.com/elastic/kibana/issues/195481\r\n\r\nFor XY charts only, when opening the breakdown dimension editor, we\r\ndisable the color picker and axis side configuration.\r\n\r\n## Before\r\n\r\n\r\n\r\n\r\n## After\r\n\r\n\r\n\n\n## Summary\r\nFixes https://github.com/elastic/kibana/issues/195481\r\n\r\nFor XY charts only, when opening the breakdown dimension editor, we\r\ndisable the color picker and axis side configuration.\r\n\r\n## Before\r\n\r\n\r\n\r\n\r\n## After\r\n\r\n\r\n => {
|
||||||
|
|
||||||
expect(component.find(EuiColorPicker).prop('color')).toEqual('red');
|
expect(component.find(EuiColorPicker).prop('color')).toEqual('red');
|
||||||
});
|
});
|
||||||
|
test.each<{ collapseFn?: string; shouldDisplay?: boolean }>([
|
||||||
|
// should display color picker
|
||||||
|
{ shouldDisplay: true },
|
||||||
|
// should not display color picker
|
||||||
|
{ collapseFn: 'sum', shouldDisplay: false },
|
||||||
|
])(
|
||||||
|
'should only show color picker when collapseFn is defined for breakdown group',
|
||||||
|
({ collapseFn = undefined, shouldDisplay = true }) => {
|
||||||
|
const state = {
|
||||||
|
...testState(),
|
||||||
|
layers: [
|
||||||
|
{
|
||||||
|
collapseFn,
|
||||||
|
seriesType: 'bar',
|
||||||
|
layerType: LayerTypes.DATA,
|
||||||
|
layerId: 'first',
|
||||||
|
splitAccessor: 'breakdownAccessor',
|
||||||
|
xAccessor: 'foo',
|
||||||
|
accessors: ['bar'],
|
||||||
|
yConfig: [{ forAccessor: 'bar', color: 'red' }],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
} as XYState;
|
||||||
|
|
||||||
|
render(
|
||||||
|
<DataDimensionEditor
|
||||||
|
layerId={state.layers[0].layerId}
|
||||||
|
frame={{
|
||||||
|
...frame,
|
||||||
|
activeData: {
|
||||||
|
first: {
|
||||||
|
type: 'datatable',
|
||||||
|
columns: [],
|
||||||
|
rows: [{ bar: 123 }],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
setState={jest.fn()}
|
||||||
|
accessor="breakdownAccessor"
|
||||||
|
groupId={'breakdown'}
|
||||||
|
state={state}
|
||||||
|
formatFactory={jest.fn()}
|
||||||
|
paletteService={chartPluginMock.createPaletteRegistry()}
|
||||||
|
panelRef={React.createRef()}
|
||||||
|
addLayer={jest.fn()}
|
||||||
|
removeLayer={jest.fn()}
|
||||||
|
datasource={{} as DatasourcePublicAPI}
|
||||||
|
isDarkMode={false}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
const colorPickerUi = screen.queryByLabelText('Edit colors');
|
||||||
|
|
||||||
|
if (shouldDisplay) {
|
||||||
|
expect(colorPickerUi).toBeInTheDocument();
|
||||||
|
} else {
|
||||||
|
expect(colorPickerUi).not.toBeInTheDocument();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
test('does not apply incorrect color', () => {
|
test('does not apply incorrect color', () => {
|
||||||
jest.useFakeTimers();
|
jest.useFakeTimers();
|
||||||
const setState = jest.fn();
|
const setState = jest.fn();
|
||||||
|
|
|
@ -134,8 +134,8 @@ export function DataDimensionEditor(
|
||||||
const { splitAccessor } = layer;
|
const { splitAccessor } = layer;
|
||||||
const splitCategories = getColorCategories(table?.rows ?? [], splitAccessor);
|
const splitCategories = getColorCategories(table?.rows ?? [], splitAccessor);
|
||||||
|
|
||||||
if (props.groupId === 'breakdown' && !layer.collapseFn) {
|
if (props.groupId === 'breakdown') {
|
||||||
return (
|
return !layer.collapseFn ? (
|
||||||
<ColorMappingByTerms
|
<ColorMappingByTerms
|
||||||
isDarkMode={isDarkMode}
|
isDarkMode={isDarkMode}
|
||||||
colorMapping={layer.colorMapping}
|
colorMapping={layer.colorMapping}
|
||||||
|
@ -147,7 +147,7 @@ export function DataDimensionEditor(
|
||||||
panelRef={props.panelRef}
|
panelRef={props.panelRef}
|
||||||
categories={splitCategories}
|
categories={splitCategories}
|
||||||
/>
|
/>
|
||||||
);
|
) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const isHorizontal = isHorizontalChart(state.layers);
|
const isHorizontal = isHorizontalChart(state.layers);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue