Skip to content

Commit

Permalink
[Lens] Fix table alignment (#173908)
Browse files Browse the repository at this point in the history
## Summary

Fixes #173902

Fix issue and introduces also a unit test.


![text_alignment_table_fix](https://github.com/elastic/kibana/assets/924948/201f70cd-6fc6-41e9-bf87-8e87f9906052)


### 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>
  • Loading branch information
3 people authored Jan 2, 2024
1 parent 10d94e4 commit 2cddc60
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
2 changes: 1 addition & 1 deletion NOTICE.txt
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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!,
Expand Down

0 comments on commit 2cddc60

Please sign in to comment.