-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[discover] lazy load actions #211974
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
[discover] lazy load actions #211974
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
4888649
[discover] lazy load actions
nreese fcec303
update limits
nreese dbf2dfb
clean up
nreese 9d79161
clean up
nreese 9208e61
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine 6d6bad9
limits
nreese aa4317d
merge with main
nreese 68a9eef
discoverEnhanced
nreese 33ea431
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine aec6e89
Merge branch 'main' into discover_actions
elasticmachine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
10 changes: 10 additions & 0 deletions
10
src/platform/plugins/shared/discover/public/embeddable/actions/constants.ts
This file contains hidden or 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,10 @@ | ||
| /* | ||
| * 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", the "GNU Affero General Public License v3.0 only", 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", the "GNU Affero General Public | ||
| * License v3.0 only", or the "Server Side Public License, v 1". | ||
| */ | ||
|
|
||
| export const ACTION_VIEW_SAVED_SEARCH = 'ACTION_VIEW_SAVED_SEARCH'; |
This file contains hidden or 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
68 changes: 68 additions & 0 deletions
68
...latform/plugins/shared/discover/public/embeddable/actions/view_discover_session_action.ts
This file contains hidden or 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,68 @@ | ||
| /* | ||
| * 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", the "GNU Affero General Public License v3.0 only", 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", the "GNU Affero General Public | ||
| * License v3.0 only", or the "Server Side Public License, v 1". | ||
| */ | ||
|
|
||
| import type { ApplicationStart } from '@kbn/core/public'; | ||
| import { i18n } from '@kbn/i18n'; | ||
| import { | ||
| apiCanAccessViewMode, | ||
| getInheritedViewMode, | ||
| type EmbeddableApiContext, | ||
| apiIsOfType, | ||
| CanAccessViewMode, | ||
| HasType, | ||
| } from '@kbn/presentation-publishing'; | ||
| import { IncompatibleActionError } from '@kbn/ui-actions-plugin/public'; | ||
|
|
||
| import { SEARCH_EMBEDDABLE_TYPE } from '@kbn/discover-utils'; | ||
| import { ActionDefinition } from '@kbn/ui-actions-plugin/public/actions'; | ||
| import type { DiscoverAppLocator } from '../../../common'; | ||
| import { getDiscoverLocatorParams } from '../utils/get_discover_locator_params'; | ||
| import { ACTION_VIEW_SAVED_SEARCH } from './constants'; | ||
| import { PublishesSavedSearch, apiPublishesSavedSearch } from '../types'; | ||
|
|
||
| type ViewSavedSearchActionApi = CanAccessViewMode & HasType & PublishesSavedSearch; | ||
|
|
||
| export const compatibilityCheck = ( | ||
| api: EmbeddableApiContext['embeddable'] | ||
| ): api is ViewSavedSearchActionApi => { | ||
| return ( | ||
| apiCanAccessViewMode(api) && | ||
| getInheritedViewMode(api) === 'view' && | ||
| apiIsOfType(api, SEARCH_EMBEDDABLE_TYPE) && | ||
| apiPublishesSavedSearch(api) | ||
| ); | ||
| }; | ||
|
|
||
| export function getViewDiscoverSessionAction( | ||
| application: ApplicationStart, | ||
| locator: DiscoverAppLocator | ||
| ) { | ||
| return { | ||
| id: ACTION_VIEW_SAVED_SEARCH, | ||
| type: ACTION_VIEW_SAVED_SEARCH, | ||
| order: 20, // Same order as ACTION_OPEN_IN_DISCOVER | ||
| execute: async ({ embeddable }: EmbeddableApiContext) => { | ||
| if (!compatibilityCheck(embeddable)) throw new IncompatibleActionError(); | ||
|
|
||
| const locatorParams = getDiscoverLocatorParams(embeddable); | ||
| await locator.navigate(locatorParams); | ||
| }, | ||
| getDisplayName: () => | ||
| i18n.translate('discover.savedSearchEmbeddable.action.viewSavedSearch.displayName', { | ||
| defaultMessage: 'Open in Discover', | ||
| }), | ||
| getIconType: () => 'discoverApp', | ||
| isCompatible: async ({ embeddable }: EmbeddableApiContext) => { | ||
| const { capabilities } = application; | ||
| const hasDiscoverPermissions = | ||
| (capabilities.discover_v2.show as boolean) || (capabilities.discover_v2.save as boolean); | ||
| return hasDiscoverPermissions && compatibilityCheck(embeddable); | ||
| }, | ||
| } as ActionDefinition<EmbeddableApiContext>; | ||
| } |
59 changes: 0 additions & 59 deletions
59
src/platform/plugins/shared/discover/public/embeddable/actions/view_saved_search_action.ts
This file was deleted.
Oops, something went wrong.
35 changes: 0 additions & 35 deletions
35
...lugins/shared/discover/public/embeddable/actions/view_saved_search_compatibility_check.ts
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved
loadSharingDataHelperstopublic/index.tsto avoid loadinggetSortForEmbeddablein page load bundle.