From 16a88b2a0e33b407b7c3cef8e41865f6b4f00280 Mon Sep 17 00:00:00 2001 From: Ashwin P Chandran Date: Wed, 7 Feb 2024 10:27:34 +0000 Subject: [PATCH] renames datagrid settng to newDiscover setting Signed-off-by: Ashwin P Chandran --- .../components/data_grid/data_grid_table.tsx | 10 +++++----- .../components/top_nav/get_top_nav_links.tsx | 10 +++++----- .../application/components/utils/local_storage.ts | 10 +++++----- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/plugins/discover/public/application/components/data_grid/data_grid_table.tsx b/src/plugins/discover/public/application/components/data_grid/data_grid_table.tsx index 58eb1e10befe..edfc7f1a2d40 100644 --- a/src/plugins/discover/public/application/components/data_grid/data_grid_table.tsx +++ b/src/plugins/discover/public/application/components/data_grid/data_grid_table.tsx @@ -26,7 +26,7 @@ import { } from '../../../../common'; import { UI_SETTINGS } from '../../../../../data/common'; import { LegacyDiscoverTable } from '../default_discover_table/default_discover_table'; -import { getDataGridTableSetting } from '../utils/local_storage'; +import { getNewDiscoverSetting } from '../utils/local_storage'; import { SortDirection, SortOrder } from '../../../saved_searches/types'; import { useToolbarOptions } from './data_grid_toolbar'; @@ -160,7 +160,7 @@ export const DataGridTable = ({ ]; }, []); - const datagridActive = getDataGridTableSetting(services.storage); + const newDiscoverEnabled = getNewDiscoverSetting(services.storage); const legacyDiscoverTable = useMemo( () => ( @@ -232,7 +232,7 @@ export const DataGridTable = ({ ] ); - const tablePanelProps = datagridActive + const tablePanelProps = newDiscoverEnabled ? { paddingSize: 'none' as const, style: { @@ -267,9 +267,9 @@ export const DataGridTable = ({ className="eui-xScrollWithShadows" > - {datagridActive ? dataGridTable : legacyDiscoverTable} + {newDiscoverEnabled ? dataGridTable : legacyDiscoverTable} - {datagridActive && inspectedHit && ( + {newDiscoverEnabled && inspectedHit && ( { // Read the current state from localStorage - const newDiscoverEnabled = getDataGridTableSetting(storage); + const newDiscoverEnabled = getNewDiscoverSetting(storage); if (newDiscoverEnabled) { const confirmed = await services.overlays.openConfirm( toMountPoint( @@ -275,12 +275,12 @@ export const getTopNavLinks = ( ); if (confirmed) { - setDataGridTableSetting(false, storage); + setNewDiscoverSetting(false, storage); window.location.reload(); } } else { // Save the new setting to localStorage - setDataGridTableSetting(true, storage); + setNewDiscoverSetting(true, storage); window.location.reload(); } }, diff --git a/src/plugins/discover/public/application/components/utils/local_storage.ts b/src/plugins/discover/public/application/components/utils/local_storage.ts index ae2d8218c3c6..5e812de8e97d 100644 --- a/src/plugins/discover/public/application/components/utils/local_storage.ts +++ b/src/plugins/discover/public/application/components/utils/local_storage.ts @@ -5,13 +5,13 @@ import { Storage } from '../../../../../opensearch_dashboards_utils/public'; -export const DATA_GRID_TABLE_KEY = 'discover:dataGridTable'; +export const NEW_DISCOVER_KEY = 'discover:newExpereince'; -export const getDataGridTableSetting = (storage: Storage): boolean => { - const storedValue = storage.get(DATA_GRID_TABLE_KEY); +export const getNewDiscoverSetting = (storage: Storage): boolean => { + const storedValue = storage.get(NEW_DISCOVER_KEY); return storedValue !== null ? JSON.parse(storedValue) : false; }; -export const setDataGridTableSetting = (value: boolean, storage: Storage) => { - storage.set(DATA_GRID_TABLE_KEY, JSON.stringify(value)); +export const setNewDiscoverSetting = (value: boolean, storage: Storage) => { + storage.set(NEW_DISCOVER_KEY, JSON.stringify(value)); };