[8.11] [Discover] Revert data table row height to 3 by default (#169724) (#170187)

# Backport

This will backport the following commits from `main` to `8.11`:
- [[Discover] Revert data table row height to 3 by default
(#169724)](https://github.com/elastic/kibana/pull/169724)

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

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

<!--BACKPORT [{"author":{"name":"Davis
McPhee","email":"davis.mcphee@elastic.co"},"sourceCommit":{"committedDate":"2023-10-30T20:36:32Z","message":"[Discover]
Revert data table row height to 3 by default (#169724)\n\n##
Summary\r\n\r\nThis PR reverts the changes from #164218 that updated the
default\r\nDiscover grid row height to \"auto\", and changes it back to
\"3\".\r\n\r\n### Checklist\r\n\r\n- [ ] Any text added follows [EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n-
[
]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas
added for features that require explanation or tutorials\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- [ ] Any UI
touched in this PR is usable by keyboard only (learn more\r\nabout
[keyboard accessibility](https://webaim.org/techniques/keyboard/))\r\n-
[ ] Any UI touched in this PR does not create any new axe
failures\r\n(run axe in
browser:\r\n[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),\r\n[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))\r\n-
[ ] If a plugin configuration key changed, check if it needs to
be\r\nallowlisted in the cloud and added to the
[docker\r\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\r\n-
[ ] This renders correctly on smaller devices using a
responsive\r\nlayout. (You can test this [in
your\r\nbrowser](https://www.browserstack.com/guide/responsive-testing-on-local-server))\r\n-
[ ] This was checked for
[cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\r\n\r\n###
For maintainers\r\n\r\n- [ ] This was checked for breaking API changes
and was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"788d30239640e4f549eaeedebad766072de45a05","branchLabelMapping":{"^v8.12.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:DataDiscovery","v8.11.0","v8.12.0"],"number":169724,"url":"https://github.com/elastic/kibana/pull/169724","mergeCommit":{"message":"[Discover]
Revert data table row height to 3 by default (#169724)\n\n##
Summary\r\n\r\nThis PR reverts the changes from #164218 that updated the
default\r\nDiscover grid row height to \"auto\", and changes it back to
\"3\".\r\n\r\n### Checklist\r\n\r\n- [ ] Any text added follows [EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n-
[
]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas
added for features that require explanation or tutorials\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- [ ] Any UI
touched in this PR is usable by keyboard only (learn more\r\nabout
[keyboard accessibility](https://webaim.org/techniques/keyboard/))\r\n-
[ ] Any UI touched in this PR does not create any new axe
failures\r\n(run axe in
browser:\r\n[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),\r\n[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))\r\n-
[ ] If a plugin configuration key changed, check if it needs to
be\r\nallowlisted in the cloud and added to the
[docker\r\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\r\n-
[ ] This renders correctly on smaller devices using a
responsive\r\nlayout. (You can test this [in
your\r\nbrowser](https://www.browserstack.com/guide/responsive-testing-on-local-server))\r\n-
[ ] This was checked for
[cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\r\n\r\n###
For maintainers\r\n\r\n- [ ] This was checked for breaking API changes
and was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"788d30239640e4f549eaeedebad766072de45a05"}},"sourceBranch":"main","suggestedTargetBranches":["8.11"],"targetPullRequestStates":[{"branch":"8.11","label":"v8.11.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.12.0","labelRegex":"^v8.12.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/169724","number":169724,"mergeCommit":{"message":"[Discover]
Revert data table row height to 3 by default (#169724)\n\n##
Summary\r\n\r\nThis PR reverts the changes from #164218 that updated the
default\r\nDiscover grid row height to \"auto\", and changes it back to
\"3\".\r\n\r\n### Checklist\r\n\r\n- [ ] Any text added follows [EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n-
[
]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas
added for features that require explanation or tutorials\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- [ ] Any UI
touched in this PR is usable by keyboard only (learn more\r\nabout
[keyboard accessibility](https://webaim.org/techniques/keyboard/))\r\n-
[ ] Any UI touched in this PR does not create any new axe
failures\r\n(run axe in
browser:\r\n[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),\r\n[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))\r\n-
[ ] If a plugin configuration key changed, check if it needs to
be\r\nallowlisted in the cloud and added to the
[docker\r\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\r\n-
[ ] This renders correctly on smaller devices using a
responsive\r\nlayout. (You can test this [in
your\r\nbrowser](https://www.browserstack.com/guide/responsive-testing-on-local-server))\r\n-
[ ] This was checked for
[cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\r\n\r\n###
For maintainers\r\n\r\n- [ ] This was checked for breaking API changes
and was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"788d30239640e4f549eaeedebad766072de45a05"}}]}]
BACKPORT-->

---------

Co-authored-by: Davis McPhee <davis.mcphee@elastic.co>
This commit is contained in:
Kibana Machine 2023-10-31 00:02:35 -04:00 committed by GitHub
parent 5c42f0f281
commit 50926434e9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 19 additions and 13 deletions

View file

@ -20,7 +20,7 @@ export const ROWS_PER_PAGE_OPTIONS = [10, 25, 50, DEFAULT_ROWS_PER_PAGE, 250, 50
export const ROWS_HEIGHT_OPTIONS = {
auto: -1,
single: 0,
default: -1,
default: 3,
};
export const defaultRowLineHeight = '1.6em';
export const defaultMonacoEditorWidth = 370;

View file

@ -11,6 +11,8 @@ import { Storage } from '@kbn/kibana-utils-plugin/public';
import { LocalStorageMock } from '../../__mocks__/local_storage_mock';
import { useRowHeightsOptions } from './use_row_heights_options';
const CONFIG_ROW_HEIGHT = 3;
describe('useRowHeightsOptions', () => {
test('should apply rowHeight from savedSearch', () => {
const { result } = renderHook(() => {
@ -30,7 +32,7 @@ describe('useRowHeightsOptions', () => {
storage: new LocalStorageMock({
['discover:dataGridRowHeight']: {
previousRowHeight: 5,
previousConfigRowHeight: -1,
previousConfigRowHeight: 3,
},
}) as unknown as Storage,
consumer: 'discover',
@ -50,7 +52,7 @@ describe('useRowHeightsOptions', () => {
});
expect(result.current.defaultHeight).toEqual({
lineCount: 3,
lineCount: CONFIG_ROW_HEIGHT,
});
});
@ -59,8 +61,8 @@ describe('useRowHeightsOptions', () => {
return useRowHeightsOptions({
storage: new LocalStorageMock({
['discover:dataGridRowHeight']: {
previousRowHeight: 5,
// different from uiSettings (config), now user changed it to -1, but prev was 4
previousRowHeight: 4,
// different from uiSettings (config), now user changed it to 3, but prev was 4
previousConfigRowHeight: 4,
},
}) as unknown as Storage,
@ -68,6 +70,8 @@ describe('useRowHeightsOptions', () => {
});
});
expect(result.current.defaultHeight).toEqual('auto');
expect(result.current.defaultHeight).toEqual({
lineCount: CONFIG_ROW_HEIGHT,
});
});
});

View file

@ -34,6 +34,8 @@ const serializeRowHeight = (rowHeight?: EuiDataGridRowHeightOption): number => {
return ROWS_HEIGHT_OPTIONS.auto;
} else if (typeof rowHeight === 'object' && rowHeight.lineCount) {
return rowHeight.lineCount; // custom
} else if (typeof rowHeight === 'number') {
return rowHeight;
}
return ROWS_HEIGHT_OPTIONS.single;

View file

@ -287,7 +287,7 @@ export const getUiSettings: (docLinks: DocLinksServiceSetup) => Record<string, U
name: i18n.translate('discover.advancedSettings.params.rowHeightTitle', {
defaultMessage: 'Row height in the Document Explorer',
}),
value: -1,
value: 3,
category: ['discover'],
description: i18n.translate('discover.advancedSettings.params.rowHeightText', {
defaultMessage:

View file

@ -44,12 +44,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
expect(rows.length).to.be.above(0);
await dataGrid.clickGridSettings();
expect(await dataGrid.getCurrentRowHeightValue()).to.be('Auto fit');
expect(await dataGrid.getCurrentRowHeightValue()).to.be('Custom');
});
it('should allow to change row height and reset it', async () => {
await dataGrid.clickGridSettings();
expect(await dataGrid.getCurrentRowHeightValue()).to.be('Auto fit');
expect(await dataGrid.getCurrentRowHeightValue()).to.be('Custom');
await dataGrid.changeRowHeightValue('Single');
@ -61,18 +61,18 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await dataGrid.resetRowHeightValue();
expect(await dataGrid.getCurrentRowHeightValue()).to.be('Auto fit');
expect(await dataGrid.getCurrentRowHeightValue()).to.be('Custom');
await dataGrid.changeRowHeightValue('Custom');
await dataGrid.changeRowHeightValue('Auto fit');
await dataGrid.resetRowHeightValue();
expect(await dataGrid.getCurrentRowHeightValue()).to.be('Auto fit');
expect(await dataGrid.getCurrentRowHeightValue()).to.be('Custom');
});
it('should persist the selection after reloading the page', async () => {
await dataGrid.clickGridSettings();
expect(await dataGrid.getCurrentRowHeightValue()).to.be('Auto fit');
expect(await dataGrid.getCurrentRowHeightValue()).to.be('Custom');
await dataGrid.changeRowHeightValue('Single');