From c376db35535964109e85a3193a0cfe4c9717aafe Mon Sep 17 00:00:00 2001 From: Davis McPhee Date: Tue, 24 Oct 2023 18:06:07 -0300 Subject: [PATCH] Revert the change to make the Discover grid row height auto by default --- packages/kbn-unified-data-table/src/constants.ts | 2 +- .../src/hooks/use_row_heights_options.test.tsx | 14 +++++++++----- src/plugins/discover/server/ui_settings.ts | 2 +- .../apps/discover/group2/_data_grid_row_height.ts | 4 ++-- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/packages/kbn-unified-data-table/src/constants.ts b/packages/kbn-unified-data-table/src/constants.ts index f648f09f558f3..c4c236c828fc1 100644 --- a/packages/kbn-unified-data-table/src/constants.ts +++ b/packages/kbn-unified-data-table/src/constants.ts @@ -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; diff --git a/packages/kbn-unified-data-table/src/hooks/use_row_heights_options.test.tsx b/packages/kbn-unified-data-table/src/hooks/use_row_heights_options.test.tsx index 1ef0d9c70d139..2da08c178720a 100644 --- a/packages/kbn-unified-data-table/src/hooks/use_row_heights_options.test.tsx +++ b/packages/kbn-unified-data-table/src/hooks/use_row_heights_options.test.tsx @@ -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, + }); }); }); diff --git a/src/plugins/discover/server/ui_settings.ts b/src/plugins/discover/server/ui_settings.ts index bc5ad09d260c4..d6bbbd0eed9f0 100644 --- a/src/plugins/discover/server/ui_settings.ts +++ b/src/plugins/discover/server/ui_settings.ts @@ -287,7 +287,7 @@ export const getUiSettings: (docLinks: DocLinksServiceSetup) => Record { await dataGrid.clickGridSettings(); - expect(await dataGrid.getCurrentRowHeightValue()).to.be('Auto fit'); + expect(await dataGrid.getCurrentRowHeightValue()).to.be('Custom'); await dataGrid.changeRowHeightValue('Single');