-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[discover] lazy load actions #211974
Open
nreese
wants to merge
10
commits into
elastic:main
Choose a base branch
from
nreese:discover_actions
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+123
−132
Open
[discover] lazy load actions #211974
Changes from 4 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 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 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 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
57 changes: 57 additions & 0 deletions
57
...latform/plugins/shared/discover/public/embeddable/actions/view_discover_session_action.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,57 @@ | ||
/* | ||
* 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, type Action } from '@kbn/ui-actions-plugin/public'; | ||
|
||
import type { DiscoverAppLocator } from '../../../common'; | ||
import { getDiscoverLocatorParams } from '../utils/get_discover_locator_params'; | ||
import { ACTION_VIEW_SAVED_SEARCH } from './constants'; | ||
import { SEARCH_EMBEDDABLE_TYPE } from '@kbn/discover-utils'; | ||
import { PublishesSavedSearch, apiPublishesSavedSearch } from '../types'; | ||
import { ActionDefinition } from '@kbn/ui-actions-plugin/public/actions'; | ||
|
||
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.
36 changes: 0 additions & 36 deletions
36
...lugins/shared/discover/public/embeddable/actions/view_saved_search_compatibility_check.ts
This file was deleted.
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
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
loadSharingDataHelpers
topublic/index.ts
to avoid loadinggetSortForEmbeddable
in page load bundle.