Skip to content

Commit

Permalink
[Discover] leave deprecated param
Browse files Browse the repository at this point in the history
  • Loading branch information
dimaanj committed Aug 10, 2022
1 parent 9560fd7 commit 0d6df61
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/plugins/discover/public/locator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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']);

Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down
7 changes: 7 additions & 0 deletions src/plugins/discover/public/locator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -102,6 +107,7 @@ export class DiscoverAppLocatorDefinition implements LocatorDefinition<DiscoverA
useHash = this.deps.useHash,
filters,
dataViewId,
indexPatternId,
query,
refreshInterval,
savedSearchId,
Expand Down Expand Up @@ -131,6 +137,7 @@ export class DiscoverAppLocatorDefinition implements LocatorDefinition<DiscoverA

if (query) appState.query = query;
if (filters && filters.length) appState.filters = filters?.filter((f) => !isFilterPinned(f));
if (indexPatternId) appState.index = indexPatternId;
if (dataViewId) appState.index = dataViewId;
if (columns) appState.columns = columns;
if (savedQuery) appState.savedQuery = savedQuery;
Expand Down

0 comments on commit 0d6df61

Please sign in to comment.