Skip to content

Commit 3ff5b72

Browse files
kibanamachinemarkov00dej611
authored
[8.18] [Inspector]: fix pagination not working (elastic#223537) (elastic#224215)
# Backport This will backport the following commits from `main` to `8.18`: - [[Inspector]: fix pagination not working (elastic#223537)](elastic#223537) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Marco Vettorello","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-06-17T10:33:38Z","message":"[Inspector]: fix pagination not working (elastic#223537)\n\n## Summary\n\nfix https://github.com/elastic/kibana/issues/223536\n\nIt wasn't possible to change the page index in the Inspector Data View.\nThe table was using the `onTableChange` callback, coming from the\n`useEuiTablePersist` hook in the wrapping function, in the `onChange`\nprop of the `EuiTable` instead of being attached to the `onTableChange`\nprop.\n\nWhen using the `onChange` the EuiTable leave all the pagination/size etc\nhandling to the consumer, where the `onTableChange` is just a callback\nrelated to the changes, used within the `useEuiTablePersist` to store\nsome configuration across tabels.\n\nThe PR fixes the `onTableChange` callback to the correct prop.\n\nA functional test was also added to check the pagination works within\nLens. I haven't used the existing `inspector.ts` functional tests\nbecause they where within the Legacy Visualize.\n\nI've checked the usage of `useEuiTablePersist` and the returned\n`onTableChange` and is correctly used everywhere except for ESQL query\nhistory that doesn't seems to have enabled pagination cc @stratoula\n\nhttps://github.com/elastic/kibana/blob/90f65c3dba232e5a8acfc33bd51cdcd269f5fec2/src/platform/packages/private/kbn-esql-editor/src/editor_footer/history_starred_queries.tsx#L383\n\n---------\n\nCo-authored-by: Marco Liberati <[email protected]>","sha":"d4fb29bb2deac21fa88ffb0e69f7ecd0d6baf4f4","branchLabelMapping":{"^v9.1.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","regression","release_note:fix","Team:Visualizations","backport:prev-minor","backport:prev-major","v9.1.0"],"title":"[Inspector]: fix pagination not working","number":223537,"url":"https://github.com/elastic/kibana/pull/223537","mergeCommit":{"message":"[Inspector]: fix pagination not working (elastic#223537)\n\n## Summary\n\nfix https://github.com/elastic/kibana/issues/223536\n\nIt wasn't possible to change the page index in the Inspector Data View.\nThe table was using the `onTableChange` callback, coming from the\n`useEuiTablePersist` hook in the wrapping function, in the `onChange`\nprop of the `EuiTable` instead of being attached to the `onTableChange`\nprop.\n\nWhen using the `onChange` the EuiTable leave all the pagination/size etc\nhandling to the consumer, where the `onTableChange` is just a callback\nrelated to the changes, used within the `useEuiTablePersist` to store\nsome configuration across tabels.\n\nThe PR fixes the `onTableChange` callback to the correct prop.\n\nA functional test was also added to check the pagination works within\nLens. I haven't used the existing `inspector.ts` functional tests\nbecause they where within the Legacy Visualize.\n\nI've checked the usage of `useEuiTablePersist` and the returned\n`onTableChange` and is correctly used everywhere except for ESQL query\nhistory that doesn't seems to have enabled pagination cc @stratoula\n\nhttps://github.com/elastic/kibana/blob/90f65c3dba232e5a8acfc33bd51cdcd269f5fec2/src/platform/packages/private/kbn-esql-editor/src/editor_footer/history_starred_queries.tsx#L383\n\n---------\n\nCo-authored-by: Marco Liberati <[email protected]>","sha":"d4fb29bb2deac21fa88ffb0e69f7ecd0d6baf4f4"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/223537","number":223537,"mergeCommit":{"message":"[Inspector]: fix pagination not working (elastic#223537)\n\n## Summary\n\nfix https://github.com/elastic/kibana/issues/223536\n\nIt wasn't possible to change the page index in the Inspector Data View.\nThe table was using the `onTableChange` callback, coming from the\n`useEuiTablePersist` hook in the wrapping function, in the `onChange`\nprop of the `EuiTable` instead of being attached to the `onTableChange`\nprop.\n\nWhen using the `onChange` the EuiTable leave all the pagination/size etc\nhandling to the consumer, where the `onTableChange` is just a callback\nrelated to the changes, used within the `useEuiTablePersist` to store\nsome configuration across tabels.\n\nThe PR fixes the `onTableChange` callback to the correct prop.\n\nA functional test was also added to check the pagination works within\nLens. I haven't used the existing `inspector.ts` functional tests\nbecause they where within the Legacy Visualize.\n\nI've checked the usage of `useEuiTablePersist` and the returned\n`onTableChange` and is correctly used everywhere except for ESQL query\nhistory that doesn't seems to have enabled pagination cc @stratoula\n\nhttps://github.com/elastic/kibana/blob/90f65c3dba232e5a8acfc33bd51cdcd269f5fec2/src/platform/packages/private/kbn-esql-editor/src/editor_footer/history_starred_queries.tsx#L383\n\n---------\n\nCo-authored-by: Marco Liberati <[email protected]>","sha":"d4fb29bb2deac21fa88ffb0e69f7ecd0d6baf4f4"}}]}] BACKPORT--> Co-authored-by: Marco Vettorello <[email protected]> Co-authored-by: Marco Liberati <[email protected]>
1 parent d73e725 commit 3ff5b72

File tree

4 files changed

+72
-1
lines changed

4 files changed

+72
-1
lines changed

src/platform/packages/shared/shared-ux/table_persist/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ const MyTableComponent: FunctionComponent<Props> = ({ items }) => {
4545
columns={columns}
4646
pagination={pagination}
4747
sorting={sorting}
48+
onTableChange={onTableChange}
4849
/>
4950
);
5051
};

src/platform/plugins/shared/data/public/utils/table_inspector_view/components/data_table.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ class DataTableFormatClass extends Component<
210210
items={rows}
211211
sorting={sorting}
212212
pagination={pagination}
213-
onChange={onTableChange}
213+
onTableChange={onTableChange}
214214
css={css`
215215
// Set a min width on each column - you can use [data-test-subj] to target specific columns
216216
.euiTableHeaderCell {

x-pack/test/functional/apps/lens/group1/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ export default ({ getService, loadTestFile, getPageObjects }: FtrProviderContext
7878
loadTestFile(require.resolve('./smokescreen')); // 12m 12s
7979
loadTestFile(require.resolve('./ad_hoc_data_view')); // 3m 40s
8080
loadTestFile(require.resolve('./multiple_data_views'));
81+
loadTestFile(require.resolve('./inspector'));
8182
}
8283
});
8384
};
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
6+
*/
7+
8+
import { FtrProviderContext } from '../../../ftr_provider_context';
9+
10+
export default function ({ getService, getPageObjects }: FtrProviderContext) {
11+
const { visualize, lens, timePicker } = getPageObjects(['visualize', 'lens', 'timePicker']);
12+
const testSubjects = getService('testSubjects');
13+
const inspector = getService('inspector');
14+
15+
describe('Inspector', () => {
16+
it('should allow switch between table page', async () => {
17+
await visualize.navigateToNewVisualization();
18+
await visualize.clickVisType('lens');
19+
await timePicker.setDefaultAbsoluteRange();
20+
21+
await lens.configureDimension({
22+
dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension',
23+
operation: 'date_histogram',
24+
field: '@timestamp',
25+
});
26+
27+
await lens.configureDimension({
28+
dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension',
29+
operation: 'average',
30+
field: 'bytes',
31+
});
32+
33+
await lens.configureDimension({
34+
dimension: 'lnsXY_splitDimensionPanel > lns-empty-dimension',
35+
operation: 'terms',
36+
field: 'geo.dest',
37+
});
38+
39+
await inspector.open('lnsApp_inspectButton');
40+
await inspector.setTablePageSize(10);
41+
42+
await inspector.expectTableData([
43+
['BT', '2015-09-19 06:00', '-'],
44+
['BT', '2015-09-19 09:00', '-'],
45+
['BT', '2015-09-19 12:00', '-'],
46+
['BT', '2015-09-19 15:00', '-'],
47+
['BT', '2015-09-19 18:00', '-'],
48+
['BT', '2015-09-19 21:00', '-'],
49+
['BT', '2015-09-20 00:00', '-'],
50+
['BT', '2015-09-20 03:00', '-'],
51+
['BT', '2015-09-20 06:00', '-'],
52+
['BT', '2015-09-20 09:00', '-'],
53+
]);
54+
await testSubjects.click('pagination-button-1');
55+
await inspector.expectTableData([
56+
['BT', '2015-09-20 12:00', '-'],
57+
['BT', '2015-09-20 15:00', '-'],
58+
['BT', '2015-09-20 18:00', '-'],
59+
['BT', '2015-09-20 21:00', '-'],
60+
['BT', '2015-09-21 00:00', '-'],
61+
['BT', '2015-09-21 03:00', '-'],
62+
['BT', '2015-09-21 06:00', '-'],
63+
['BT', '2015-09-21 09:00', '-'],
64+
['BT', '2015-09-21 12:00', '-'],
65+
['BT', '2015-09-21 15:00', '-'],
66+
]);
67+
});
68+
});
69+
}

0 commit comments

Comments
 (0)