-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[controls] lazy load control actions #206876
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
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
98b5cc9
move floating actions into controls plugin
nreese 3363f7a
controls module
nreese a93a68e
async action registry
nreese 00575c1
replace PANEL_HOVER_TRIGGER with CONTROL_HOVER_TRIGGER
nreese a566cdd
remove export of action ides
nreese 77b9263
[CI] Auto-commit changed files from 'node scripts/notice'
kibanamachine eeafc7c
Merge branch 'main' into control_actions
elasticmachine fde16bf
remove async compatability code
nreese 6937e77
consolidate chunks
nreese fccf72b
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine 33dd6bb
fix jest test
nreese 223ab06
update limits.yml
nreese dcc5b3b
embeddable plugin limit
nreese 829764b
eslint
nreese 8b7d343
Merge branch 'main' into control_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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,15 +11,43 @@ import React, { SyntheticEvent } from 'react'; | |
|
|
||
| import { EuiButtonIcon, EuiToolTip } from '@elastic/eui'; | ||
| import { i18n } from '@kbn/i18n'; | ||
| import type { EmbeddableApiContext, HasUniqueId } from '@kbn/presentation-publishing'; | ||
| import { | ||
| apiCanAccessViewMode, | ||
| apiHasParentApi, | ||
| apiHasType, | ||
| apiHasUniqueId, | ||
| apiIsOfType, | ||
| HasParentApi, | ||
| type EmbeddableApiContext, | ||
| type HasUniqueId, | ||
| HasType, | ||
| } from '@kbn/presentation-publishing'; | ||
| import { | ||
| IncompatibleActionError, | ||
| FrequentCompatibilityChangeAction, | ||
| type Action, | ||
| } from '@kbn/ui-actions-plugin/public'; | ||
| import { isClearableControl } from '../types'; | ||
| import { PresentationContainer, apiIsPresentationContainer } from '@kbn/presentation-containers'; | ||
| import { CONTROL_GROUP_TYPE } from '../../common'; | ||
| import { CanClearSelections, isClearableControl } from '../types'; | ||
|
|
||
| import { ACTION_CLEAR_CONTROL } from './constants'; | ||
|
|
||
| type ClearControlActionApi = HasType & | ||
| HasUniqueId & | ||
| CanClearSelections & | ||
| HasParentApi<PresentationContainer & HasType>; | ||
|
|
||
| import { ACTION_CLEAR_CONTROL } from '.'; | ||
| const compatibilityCheck = (api: unknown | null): api is ClearControlActionApi => | ||
| Boolean( | ||
| apiHasType(api) && | ||
| apiHasUniqueId(api) && | ||
| isClearableControl(api) && | ||
| apiHasParentApi(api) && | ||
| apiCanAccessViewMode(api.parentApi) && | ||
| apiIsOfType(api.parentApi, CONTROL_GROUP_TYPE) && | ||
| apiIsPresentationContainer(api.parentApi) | ||
| ); | ||
|
|
||
| export class ClearControlAction | ||
| implements Action<EmbeddableApiContext>, FrequentCompatibilityChangeAction<EmbeddableApiContext> | ||
|
|
@@ -73,12 +101,10 @@ export class ClearControlAction | |
| } | ||
|
|
||
| public async isCompatible({ embeddable }: EmbeddableApiContext) { | ||
| const { isCompatible } = await import('./clear_control_action_compatibility_check'); | ||
| return isCompatible(embeddable); | ||
| return compatibilityCheck(embeddable); | ||
| } | ||
|
|
||
| public async execute({ embeddable }: EmbeddableApiContext) { | ||
| const { compatibilityCheck } = await import('./clear_control_action_compatibility_check'); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So much better for developer experience to have this defined in the same file. |
||
| if (!compatibilityCheck(embeddable)) throw new IncompatibleActionError(); | ||
|
|
||
| embeddable.clearSelections(); | ||
|
|
||
42 changes: 0 additions & 42 deletions
42
...atform/plugins/shared/controls/public/actions/clear_control_action_compatibility_check.ts
This file was deleted.
Oops, something went wrong.
File renamed without changes.
22 changes: 22 additions & 0 deletions
22
src/platform/plugins/shared/controls/public/actions/controls_hover_trigger.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,22 @@ | ||
| /* | ||
| * 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 { i18n } from '@kbn/i18n'; | ||
| import { Trigger } from '@kbn/ui-actions-plugin/public'; | ||
|
|
||
| export const CONTROL_HOVER_TRIGGER = 'CONTROL_HOVER_TRIGGER'; | ||
| export const controlHoverTrigger: Trigger = { | ||
| id: CONTROL_HOVER_TRIGGER, | ||
| title: i18n.translate('controls.hoverTrigger.title', { | ||
| defaultMessage: 'Control hover', | ||
| }), | ||
| description: i18n.translate('controls.hoverTrigger.description', { | ||
| defaultMessage: "Add action to controls's hover menu", | ||
| }), | ||
| }; |
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
42 changes: 0 additions & 42 deletions
42
...tform/plugins/shared/controls/public/actions/delete_control_action_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
43 changes: 0 additions & 43 deletions
43
...latform/plugins/shared/controls/public/actions/edit_control_action_compatibility_check.ts
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
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.
Great to see this moved & renamed.