mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[Lens] Fix table alignment (#173908)
## Summary
Fixes https://github.com/elastic/kibana/issues/173902
Fix issue and introduces also a unit test.

### 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
---------
Co-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
10d94e4532
commit
2cddc60368
3 changed files with 43 additions and 1 deletions
|
@ -1,5 +1,5 @@
|
|||
Kibana source code with Kibana X-Pack source code
|
||||
Copyright 2012-2023 Elasticsearch B.V.
|
||||
Copyright 2012-2024 Elasticsearch B.V.
|
||||
|
||||
---
|
||||
Pretty handling of logarithmic axes.
|
||||
|
|
|
@ -759,6 +759,47 @@ describe('Datatable Visualization', () => {
|
|||
}).headerRowHeightLines
|
||||
).toEqual([2]);
|
||||
});
|
||||
|
||||
it('sets alignment correctly', () => {
|
||||
datasource.publicAPIMock.getOperationForColumnId.mockReturnValue({
|
||||
dataType: 'string',
|
||||
isBucketed: false, // <= make them metrics
|
||||
label: 'label',
|
||||
isStaticValue: false,
|
||||
hasTimeShift: false,
|
||||
hasReducedTimeRange: false,
|
||||
});
|
||||
const expression = datatableVisualization.toExpression(
|
||||
{
|
||||
...defaultExpressionTableState,
|
||||
columns: [
|
||||
{ columnId: 'b', alignment: 'center' },
|
||||
{ columnId: 'c', alignment: 'left' },
|
||||
{ columnId: 'a' },
|
||||
],
|
||||
},
|
||||
frame.datasourceLayers,
|
||||
{},
|
||||
{ '1': { type: 'expression', chain: [] } }
|
||||
) as Ast;
|
||||
|
||||
const columnArgs = buildExpression(expression).findFunction('lens_datatable_column');
|
||||
expect(columnArgs[0].arguments).toEqual(
|
||||
expect.objectContaining({
|
||||
alignment: ['left'],
|
||||
})
|
||||
);
|
||||
expect(columnArgs[1].arguments).toEqual(
|
||||
expect.objectContaining({
|
||||
alignment: ['center'],
|
||||
})
|
||||
);
|
||||
expect(columnArgs[2].arguments).toEqual(
|
||||
expect.not.objectContaining({
|
||||
alignment: [],
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#onEditAction', () => {
|
||||
|
|
|
@ -496,6 +496,7 @@ export const getDatatableVisualization = ({
|
|||
width: column.width,
|
||||
isTransposed: column.isTransposed,
|
||||
transposable: isTransposable,
|
||||
alignment: column.alignment,
|
||||
colorMode: canColor && column.colorMode ? column.colorMode : 'none',
|
||||
palette: paletteService.get(CUSTOM_PALETTE).toExpression(paletteParams),
|
||||
summaryRow: hasNoSummaryRow ? undefined : column.summaryRow!,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue