Skip to content

Commit

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

This will backport the following commits from `main` to `8.12`:
- [[Lens] Fix table alignment
(#173908)](#173908)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Marco
Liberati","email":"dej611@users.noreply.github.com"},"sourceCommit":{"committedDate":"2024-01-02T12:54:07Z","message":"[Lens]
Fix table alignment (#173908)\n\n## Summary\r\n\r\nFixes
https://github.com/elastic/kibana/issues/173902\r\n\r\nFix issue and
introduces also a unit
test.\r\n\r\n\r\n![text_alignment_table_fix](https://github.com/elastic/kibana/assets/924948/201f70cd-6fc6-41e9-bf87-8e87f9906052)\r\n\r\n\r\n###
Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios\r\n\r\n---------\r\n\r\nCo-authored-by: Stratoula Kalafateli
<efstratia.kalafateli@elastic.co>\r\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"2cddc6036879380723e3c3a6b382fb84217070aa","branchLabelMapping":{"^v8.13.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:Visualizations","Feature:Lens","backport:prev-minor","v8.12.0","v8.13.0"],"title":"[Lens]
Fix table
alignment","number":173908,"url":"https://github.com/elastic/kibana/pull/173908","mergeCommit":{"message":"[Lens]
Fix table alignment (#173908)\n\n## Summary\r\n\r\nFixes
https://github.com/elastic/kibana/issues/173902\r\n\r\nFix issue and
introduces also a unit
test.\r\n\r\n\r\n![text_alignment_table_fix](https://github.com/elastic/kibana/assets/924948/201f70cd-6fc6-41e9-bf87-8e87f9906052)\r\n\r\n\r\n###
Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios\r\n\r\n---------\r\n\r\nCo-authored-by: Stratoula Kalafateli
<efstratia.kalafateli@elastic.co>\r\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"2cddc6036879380723e3c3a6b382fb84217070aa"}},"sourceBranch":"main","suggestedTargetBranches":["8.12"],"targetPullRequestStates":[{"branch":"8.12","label":"v8.12.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.13.0","branchLabelMappingKey":"^v8.13.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/173908","number":173908,"mergeCommit":{"message":"[Lens]
Fix table alignment (#173908)\n\n## Summary\r\n\r\nFixes
https://github.com/elastic/kibana/issues/173902\r\n\r\nFix issue and
introduces also a unit
test.\r\n\r\n\r\n![text_alignment_table_fix](https://github.com/elastic/kibana/assets/924948/201f70cd-6fc6-41e9-bf87-8e87f9906052)\r\n\r\n\r\n###
Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios\r\n\r\n---------\r\n\r\nCo-authored-by: Stratoula Kalafateli
<efstratia.kalafateli@elastic.co>\r\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"2cddc6036879380723e3c3a6b382fb84217070aa"}}]}]
BACKPORT-->

Co-authored-by: Marco Liberati <dej611@users.noreply.github.com>
  • Loading branch information
kibanamachine and dej611 authored Jan 2, 2024
1 parent 1fb8965 commit c8e877a
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 c8e877a

Please sign in to comment.