mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
# Backport This will backport the following commits from `main` to `8.9`: - [[Lens] Fixes error on table when there is no data (#161953)](https://github.com/elastic/kibana/pull/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 https://github.com/elastic/kibana/issues/161948\r\n\r\nFixes 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=\"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":"https://github.com/elastic/kibana/pull/161953","mergeCommit":{"message":"[Lens] Fixes error on table when there is no data (#161953)\n\n## Summary\r\n\r\nCloses https://github.com/elastic/kibana/issues/161948\r\n\r\nFixes 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=\"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":"https://github.com/elastic/kibana/pull/161953","number":161953,"mergeCommit":{"message":"[Lens] Fixes error on table when there is no data (#161953)\n\n## Summary\r\n\r\nCloses https://github.com/elastic/kibana/issues/161948\r\n\r\nFixes 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=\"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>
This commit is contained in:
parent
782c3b4247
commit
a2eda904dd
2 changed files with 24 additions and 2 deletions
|
@ -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
|
||||
|
@ -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);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -118,7 +118,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]);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue