-
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
[Dashboard] [Controls] Improve async controls flyout behaviour #154004
Merged
Heenawter
merged 11 commits into
elastic:main
from
Heenawter:improve-async-controls-flyout-behaviour_2023-03-28
Apr 5, 2023
Merged
Changes from 7 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
fc0ea21
Remove unnecessary wrapper for popover
Heenawter b68982a
Speed up field registry creation with promises
Heenawter cf520af
Clean up using `useAsync`
Heenawter 4a18b61
Clean up
Heenawter 2ca669b
Improve loading state
Heenawter 3b1d23a
Remove unnecessary `?` check
Heenawter 1622dd4
Merge branch 'main' into improve-async-controls-flyout-behaviour_2023…
Heenawter 9d29b33
Return a single large promise
Heenawter afb1718
Switched to `for` loop
Heenawter 8e852cb
Make loading message fill vertical space
Heenawter c9be3a2
Merge branch 'main' into improve-async-controls-flyout-behaviour_2023…
Heenawter 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
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 |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
import deepEqual from 'fast-deep-equal'; | ||
|
||
import { i18n } from '@kbn/i18n'; | ||
import { DataViewField } from '@kbn/data-views-plugin/common'; | ||
import { lazyLoadReduxEmbeddablePackage } from '@kbn/presentation-util-plugin/public'; | ||
import { EmbeddableFactoryDefinition, IContainer } from '@kbn/embeddable-plugin/public'; | ||
|
||
|
@@ -21,7 +22,7 @@ import { | |
OPTIONS_LIST_CONTROL, | ||
} from '../../../common/options_list/types'; | ||
import { OptionsListEditorOptions } from '../components/options_list_editor_options'; | ||
import { ControlEmbeddable, DataControlField, IEditableControlFactory } from '../../types'; | ||
import { ControlEmbeddable, IEditableControlFactory } from '../../types'; | ||
|
||
export class OptionsListEmbeddableFactory | ||
implements EmbeddableFactoryDefinition, IEditableControlFactory<OptionsListEmbeddableInput> | ||
|
@@ -57,15 +58,13 @@ export class OptionsListEmbeddableFactory | |
return newInput; | ||
}; | ||
|
||
public isFieldCompatible = (dataControlField: DataControlField) => { | ||
if ( | ||
!dataControlField.field.spec.scripted && | ||
((dataControlField.field.aggregatable && dataControlField.field.type === 'string') || | ||
dataControlField.field.type === 'boolean' || | ||
dataControlField.field.type === 'ip') | ||
) { | ||
dataControlField.compatibleControlTypes.push(this.type); | ||
} | ||
public isFieldCompatible = (field: DataViewField) => { | ||
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. Nice cleanup! |
||
return ( | ||
!field.spec.scripted && | ||
((field.aggregatable && field.type === 'string') || | ||
field.type === 'boolean' || | ||
field.type === 'ip') | ||
); | ||
}; | ||
|
||
public controlEditorOptionsComponent = OptionsListEditorOptions; | ||
|
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.
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.
One other performance consideration is to use
for
loop for iterating through large collections. Each timemap
is run, a new function is created and this creates a large garbage collection penalty.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.
True! I bet we could increase this performance even further, cause the code snipped that I suggested also uses
map
unnecessarily.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.
Changed toforEach
in 9d29b33Changed to for loop in afb1718