-
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
TypeScript cleanup in visualizations plugin #78428
Conversation
@elasticmachine merge upstream |
1 similar comment
@elasticmachine merge upstream |
Pinging @elastic/kibana-app (Team:KibanaApp) |
@elasticmachine merge upstream |
1 similar comment
@elasticmachine merge upstream |
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.
Code LGTM 💯
|
||
export const createInputControlVisController = (deps: InputControlVisDependencies) => { | ||
return class InputControlVisController { | ||
private I18nContext?: I18nStart['Context']; | ||
private isLoaded = false; | ||
private _isLoaded = false; |
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.
ℹ️ Since the type is propertly passed through now, this is colling with Visualizatins isLoaded()
function, so I rename this for now.
@@ -71,4 +73,7 @@ export interface VisToExpressionAstParams { | |||
abortSignal?: AbortSignal; | |||
} | |||
|
|||
export type VisToExpressionAst = (vis: Vis, params: VisToExpressionAstParams) => string; | |||
export type VisToExpressionAst = ( |
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.
ℹ️ This was completely wrongly typed :-) This function was never supposed to return a string
. It's used in build_pipeline
and the result is passed in a function expecting an ExpressionAst (also all implementations currently return that).
@@ -35,7 +37,7 @@ export interface VisualizationController { | |||
|
|||
export type VisualizationControllerConstructor = new ( | |||
el: HTMLElement, | |||
vis: Vis | |||
vis: ExprVis |
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.
ℹ️ It seems there is currently two very similar Vis classes around ExprVis
and Vis
and they've got mixed up in a couple of places. ExprVis
is the instance used in the renderer when intatiating the visualizations, while Vis
is the one used by the editor instantiated at a very high level.
visualization: VisualizationControllerConstructor | undefined; | ||
} | ||
|
||
export type BaseVisTypeOptions = ExpressionBaseVisTypeOptions | VisualizationBaseVisTypeOptions; |
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.
ℹ️ Properly splitted this up into two types. It either needs to have a visualization
or a toExpressionAst
, but not both. Technically this COULD still be used that way (since the toExpressionAst
could return an expression containing the visualization
function, that would then go and look for visualization
), but we're not using it this way, since toExpressionAst
is used for the functions using their own renderer, so I rather wanted this state to reflect the refactoring we want to end up with, not what technically theoretically would be possible.
*/ | ||
createBaseVisualization: (config: any) => { | ||
createBaseVisualization: (config: BaseVisTypeOptions): void => { |
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.
ℹ️ This is the most important part of this PR, since it finally puts the proper typings for the visualization registry into the public API we expose.
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
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.
code LGTM
Co-authored-by: Elastic Machine <[email protected]>
* master: (226 commits) [Enterprise Search] Added Logic for the Credentials View (elastic#77626) [CSM] Js errors (elastic#77919) Add the @kbn/apm-config-loader package (elastic#77855) [Security Solution] Refactor useSelector (elastic#75297) Implement tagcloud renderer (elastic#77910) [APM] Alerting: Add global option to create all alert types (elastic#78151) [Ingest pipelines] Upload indexed document to test a pipeline (elastic#77939) TypeScript cleanup in visualizations plugin (elastic#78428) Lazy load metric & mardown visualizations (elastic#78391) [Detections][EQL] EQL rule execution in detection engine (elastic#77419) Update tutorial-full-experience.asciidoc (elastic#75836) Update tutorial-define-index.asciidoc (elastic#75754) Add support for runtime field types to mappings editor. (elastic#77420) [Monitoring] Usage collection (elastic#75878) [Docs][Actions] Add docs for Jira and IBM Resilient (elastic#78316) [Security Solution][Resolver] Update @timestamp formatting (elastic#78166) [Security Solution] Fix app layout (elastic#76668) [Security Solution][Resolver] 2 new functions to DAL (elastic#78477) Adds new elasticsearch client to telemetry plugin (elastic#78046) skip flaky suite (elastic#78512) (elastic#78511) (elastic#78510) (elastic#78509) (elastic#78508) (elastic#78507) (elastic#78506) (elastic#78505) (elastic#78504) (elastic#78503) (elastic#78502) (elastic#78501) (elastic#78500) ...
Co-authored-by: Elastic Machine <[email protected]>
…t tagcloud renderer (#77910) | Fix types (#78619) (#78666) * TypeScript cleanup in visualizations plugin (#78428) Co-authored-by: Elastic Machine <[email protected]> * Implement tagcloud renderer (#77910) * Implement toExpressionAst for tagcloud * Implement tagcloud vis renderer * Use resize observer * Use common no data message * Update build_pipeline.test * Update tag cloud tests * Revert "Use common no data message" This reverts commit fddf019. * Update interpreter functional tests * Add tests for toExpressionAst fn * Use throttled chart update * Update renderer Co-authored-by: Elastic Machine <[email protected]> * Fix types (#78619) Co-authored-by: Elastic Machine <[email protected]> Co-authored-by: Daniil Suleiman <[email protected]>
Summary
This PR cleans up some broken (or not ideal) TypeScript types. See the inline comments for more details.
This PR should not change any functionality.
Checklist
Delete any items that are not applicable to this PR.
[ ] Any text added follows EUI's writing guidelines, uses sentence case text and includes i18n support[ ] Documentation was added for features that require explanation or tutorials[ ] Unit or functional tests were updated or added to match the most common scenarios[ ] This was checked for keyboard-only and screenreader accessibility[ ] This renders correctly on smaller devices using a responsive layout. (You can test this in your browser[ ] This was checked for cross-browser compatibilityFor maintainers
[ ] This was checked for breaking API changes and was labeled appropriately