-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Discover] Provide direct link from sample data UI to Discover (#130108)
* [Discover] Allow to view sample data in Discover * [Discover] Update deps format * [Discover] Define order of items in the context menu * [Discover] Update for tests * [Discover] Add upgrade tests * [Discover] Add a test for ordering appLinks * [Discover] Use existing helpers * [Discover] Add 7 days time range to Discover link * [Discover] Rename the helper Co-authored-by: Kibana Machine <[email protected]>
- Loading branch information
1 parent
0650bd3
commit 58bc0f7
Showing
17 changed files
with
298 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
export { getSavedSearchUrl, getSavedSearchFullPathUrl } from './saved_searches_url'; |
25 changes: 25 additions & 0 deletions
25
src/plugins/discover/common/services/saved_searches/saved_searches_url.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { getSavedSearchUrl, getSavedSearchFullPathUrl } from './saved_searches_url'; | ||
|
||
describe('saved_searches_url', () => { | ||
describe('getSavedSearchUrl', () => { | ||
test('should return valid saved search url', () => { | ||
expect(getSavedSearchUrl()).toBe('#/'); | ||
expect(getSavedSearchUrl('id')).toBe('#/view/id'); | ||
}); | ||
}); | ||
|
||
describe('getSavedSearchFullPathUrl', () => { | ||
test('should return valid full path url', () => { | ||
expect(getSavedSearchFullPathUrl()).toBe('/app/discover#/'); | ||
expect(getSavedSearchFullPathUrl('id')).toBe('/app/discover#/view/id'); | ||
}); | ||
}); | ||
}); |
11 changes: 11 additions & 0 deletions
11
src/plugins/discover/common/services/saved_searches/saved_searches_url.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
export const getSavedSearchUrl = (id?: string) => (id ? `#/view/${encodeURIComponent(id)}` : '#/'); | ||
|
||
export const getSavedSearchFullPathUrl = (id?: string) => `/app/discover${getSavedSearchUrl(id)}`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
export { registerSampleData } from './register_sample_data'; |
44 changes: 44 additions & 0 deletions
44
src/plugins/discover/server/sample_data/register_sample_data.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { i18n } from '@kbn/i18n'; | ||
import type { SampleDataRegistrySetup } from '@kbn/home-plugin/server'; | ||
import { APP_ICON } from '../../common'; | ||
import { getSavedSearchFullPathUrl } from '../../common/services/saved_searches'; | ||
|
||
function getDiscoverPathForSampleDataset(objId: string) { | ||
// TODO: remove the time range from the URL query when saved search objects start supporting time range configuration | ||
// https://github.com/elastic/kibana/issues/9761 | ||
return `${getSavedSearchFullPathUrl(objId)}?_g=(time:(from:now-7d,to:now))`; | ||
} | ||
|
||
export function registerSampleData(sampleDataRegistry: SampleDataRegistrySetup) { | ||
const linkLabel = i18n.translate('discover.sampleData.viewLinkLabel', { | ||
defaultMessage: 'Discover', | ||
}); | ||
const { addAppLinksToSampleDataset, getSampleDatasets } = sampleDataRegistry; | ||
const sampleDatasets = getSampleDatasets(); | ||
|
||
sampleDatasets.forEach((sampleDataset) => { | ||
const sampleSavedSearchObject = sampleDataset.savedObjects.find( | ||
(object) => object.type === 'search' | ||
); | ||
|
||
if (sampleSavedSearchObject) { | ||
addAppLinksToSampleDataset(sampleDataset.id, [ | ||
{ | ||
sampleObject: sampleSavedSearchObject, | ||
getPath: getDiscoverPathForSampleDataset, | ||
label: linkLabel, | ||
icon: APP_ICON, | ||
order: -1, | ||
}, | ||
]); | ||
} | ||
}); | ||
} |
84 changes: 84 additions & 0 deletions
84
...ome/public/application/components/__snapshots__/sample_data_view_data_button.test.js.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.