Skip to content

Commit

Permalink
[7.17] [Lens] Fixes error on table when there is no data (#161953) (#…
Browse files Browse the repository at this point in the history
…162018)

# Backport

This will backport the following commits from `main` to `7.17`:
- [[Lens] Fixes error on table when there is no data
(#161953)](#161953)

<!--- Backport version: 8.9.7 -->

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

<!--BACKPORT [{"author":{"name":"Stratoula
Kalafateli","email":"efstratia.kalafateli@elastic.co"},"sourceCommit":{"committedDate":"2023-07-17T07:45:22Z","message":"[Lens]
Fixes error on table when there is no data (#161953)\n\n##
Summary\r\n\r\nCloses
#161948 the bug
described in the issue. The bug is happening only for the\r\ntable
viz.\r\n\r\n<img width=\"1664\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/17003240/9646edcc-005d-4d2c-919a-097a673d730e\">\r\n\r\n\r\n###
Checklist\r\n\r\n- [ ] [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","sha":"6550793b4fe793ad53072bddc51118e43414e7ad","branchLabelMapping":{"^v8.10.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:Visualizations","Feature:Lens","backport:prev-MAJOR","v8.10.0","v7.17.12"],"number":161953,"url":"#161953
Fixes error on table when there is no data (#161953)\n\n##
Summary\r\n\r\nCloses
#161948 the bug
described in the issue. The bug is happening only for the\r\ntable
viz.\r\n\r\n<img width=\"1664\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/17003240/9646edcc-005d-4d2c-919a-097a673d730e\">\r\n\r\n\r\n###
Checklist\r\n\r\n- [ ] [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","sha":"6550793b4fe793ad53072bddc51118e43414e7ad"}},"sourceBranch":"main","suggestedTargetBranches":["7.17"],"targetPullRequestStates":[{"branch":"main","label":"v8.10.0","labelRegex":"^v8.10.0$","isSourceBranch":true,"state":"MERGED","url":"#161953
Fixes error on table when there is no data (#161953)\n\n##
Summary\r\n\r\nCloses
#161948 the bug
described in the issue. The bug is happening only for the\r\ntable
viz.\r\n\r\n<img width=\"1664\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/17003240/9646edcc-005d-4d2c-919a-097a673d730e\">\r\n\r\n\r\n###
Checklist\r\n\r\n- [ ] [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","sha":"6550793b4fe793ad53072bddc51118e43414e7ad"}},{"branch":"7.17","label":"v7.17.12","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>
  • Loading branch information
kibanamachine and stratoula committed Jul 17, 2023
1 parent 38a6c84 commit 3545ce4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
Expand Up @@ -11,7 +11,7 @@ import { DatatableArgs } from './datatable';

import { transposeTable } from './transpose_helpers';

describe('transpose_helpes', () => {
describe('transpose_helpers', () => {
function buildTable(): Datatable {
// 3 buckets, 2 metrics
// first bucket goes A/B/C
Expand Down Expand Up @@ -290,4 +290,26 @@ describe('transpose_helpes', () => {
1 + 18 - 2
);
});

it('should not fail for no data', () => {
const table = buildTable();
const updatedTable = {
...table,
rows: [],
};
const args = buildArgs();
const updatedArgs = {
...args,
columns: [
{
type: 'lens_datatable_column',
columnId: 'bucket1',
isTransposed: true,
transposable: false,
},
],
} as DatatableArgs;
transposeTable(updatedArgs, updatedTable, buildFormatters());
expect(args.columns.length).toEqual(5);
});
});
Expand Up @@ -121,7 +121,7 @@ function updateColumnArgs(
) {
args.columns = [...bucketsColumnArgs];
// add first column from each group, then add second column for each group, ...
transposedColumnGroups[0].forEach((_, index) => {
transposedColumnGroups[0]?.forEach((_, index) => {
transposedColumnGroups.forEach((transposedColumnGroup) => {
args.columns.push(transposedColumnGroup[index]);
});
Expand Down

0 comments on commit 3545ce4

Please sign in to comment.