From 9560fd722952180e5f5d3bbbea0f5b532ada4de0 Mon Sep 17 00:00:00 2001 From: Dzmitry Tamashevich Date: Tue, 9 Aug 2022 18:38:57 +0300 Subject: [PATCH 1/3] [Discover] update data view naming for locator --- src/plugins/discover/public/locator.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/plugins/discover/public/locator.ts b/src/plugins/discover/public/locator.ts index b7ca5d78e4ab7..46a245c8841a2 100644 --- a/src/plugins/discover/public/locator.ts +++ b/src/plugins/discover/public/locator.ts @@ -24,7 +24,7 @@ export interface DiscoverAppLocatorParams extends SerializableRecord { /** * Optionally set index pattern / data view ID. */ - indexPatternId?: string; + dataViewId?: string; /** * Optionally set the time range in the time picker. @@ -101,7 +101,7 @@ export class DiscoverAppLocatorDefinition implements LocatorDefinition !isFilterPinned(f)); - if (indexPatternId) appState.index = indexPatternId; + if (dataViewId) appState.index = dataViewId; if (columns) appState.columns = columns; if (savedQuery) appState.savedQuery = savedQuery; if (sort) appState.sort = sort; From 0d6df6119e4acb6529b16cdb6c0a2137b064372b Mon Sep 17 00:00:00 2001 From: Dzmitry Tamashevich Date: Wed, 10 Aug 2022 11:35:27 +0300 Subject: [PATCH 2/3] [Discover] leave deprecated param --- src/plugins/discover/public/locator.test.ts | 10 +++++----- src/plugins/discover/public/locator.ts | 7 +++++++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/plugins/discover/public/locator.test.ts b/src/plugins/discover/public/locator.test.ts index 98e0d7e853b61..edc44946edc59 100644 --- a/src/plugins/discover/public/locator.test.ts +++ b/src/plugins/discover/public/locator.test.ts @@ -58,7 +58,7 @@ describe('Discover url generator', () => { test('can specify specific data view', async () => { const { locator } = await setup(); const { path } = await locator.getLocation({ - indexPatternId: dataViewId, + dataViewId, }); const { _a, _g } = getStatesFromKbnUrl(path, ['_a', '_g']); @@ -229,7 +229,7 @@ describe('Discover url generator', () => { test('when using default, sets data view ID in the generated URL', async () => { const { locator } = await setup(); const { path } = await locator.getLocation({ - indexPatternId: dataViewId, + dataViewId, }); expect(path.indexOf(dataViewId) > -1).toBe(true); @@ -239,7 +239,7 @@ describe('Discover url generator', () => { const { locator } = await setup(); const { path } = await locator.getLocation({ useHash: true, - indexPatternId: dataViewId, + dataViewId, }); expect(path.indexOf(dataViewId) > -1).toBe(false); @@ -250,7 +250,7 @@ describe('Discover url generator', () => { test('when using default, does not set data view ID in the generated URL', async () => { const { locator } = await setup({ useHash: true }); const { path } = await locator.getLocation({ - indexPatternId: dataViewId, + dataViewId, }); expect(path.indexOf(dataViewId) > -1).toBe(false); @@ -260,7 +260,7 @@ describe('Discover url generator', () => { const { locator } = await setup({ useHash: true }); const { path } = await locator.getLocation({ useHash: false, - indexPatternId: dataViewId, + dataViewId, }); expect(path.indexOf(dataViewId) > -1).toBe(true); diff --git a/src/plugins/discover/public/locator.ts b/src/plugins/discover/public/locator.ts index 46a245c8841a2..0fa2195cc246f 100644 --- a/src/plugins/discover/public/locator.ts +++ b/src/plugins/discover/public/locator.ts @@ -25,6 +25,11 @@ export interface DiscoverAppLocatorParams extends SerializableRecord { * Optionally set index pattern / data view ID. */ dataViewId?: string; + /** + * Duplication of dataViewId + * @deprecated + */ + indexPatternId?: string; /** * Optionally set the time range in the time picker. @@ -102,6 +107,7 @@ export class DiscoverAppLocatorDefinition implements LocatorDefinition !isFilterPinned(f)); + if (indexPatternId) appState.index = indexPatternId; if (dataViewId) appState.index = dataViewId; if (columns) appState.columns = columns; if (savedQuery) appState.savedQuery = savedQuery; From c06ece317845ba1b5ab7b26ddf7ca318cce186d9 Mon Sep 17 00:00:00 2001 From: Dzmitry Tamashevich Date: Thu, 11 Aug 2022 16:08:39 +0300 Subject: [PATCH 3/3] [Discover] add legacy param test --- src/plugins/discover/public/locator.test.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/plugins/discover/public/locator.test.ts b/src/plugins/discover/public/locator.test.ts index edc44946edc59..274e339c91343 100644 --- a/src/plugins/discover/public/locator.test.ts +++ b/src/plugins/discover/public/locator.test.ts @@ -57,9 +57,7 @@ describe('Discover url generator', () => { test('can specify specific data view', async () => { const { locator } = await setup(); - const { path } = await locator.getLocation({ - dataViewId, - }); + const { path } = await locator.getLocation({ dataViewId }); const { _a, _g } = getStatesFromKbnUrl(path, ['_a', '_g']); expect(_a).toEqual({ @@ -224,13 +222,19 @@ describe('Discover url generator', () => { ); }); + test('should use legacy locator params', async () => { + const { locator } = await setup(); + const { path } = await locator.getLocation({ dataViewId }); + const { path: legacyParamsPath } = await locator.getLocation({ indexPatternId: dataViewId }); + + expect(path).toEqual(legacyParamsPath); + }); + describe('useHash property', () => { describe('when default useHash is set to false', () => { test('when using default, sets data view ID in the generated URL', async () => { const { locator } = await setup(); - const { path } = await locator.getLocation({ - dataViewId, - }); + const { path } = await locator.getLocation({ dataViewId }); expect(path.indexOf(dataViewId) > -1).toBe(true); });