Typescript map embeddable#61264
Conversation
b666d90 to
2b06743
Compare
|
Pinging @elastic/kibana-gis (Team:Geo) |
|
We are putting this on our roadmap for 7.8 so if you wanted to hold off, we could tackle this in the next few weeks |
2b06743 to
bdcd5e0
Compare
bdcd5e0 to
ce18bb1
Compare
There was a problem hiding this comment.
Thanks for typescripting the MapEmbeddable
Here is some documentation that may clear up some typing questions https://github.com/elastic/kibana/blob/7.7/x-pack/legacy/plugins/maps/public/embeddable/README.md
|
|
||
| export function setGotoWithCenter(config: MapCenter): AnyAction; | ||
|
|
||
| export function replaceLayerList(layerList: unknown): AnyAction; |
|
|
||
| export interface RefreshConfig { | ||
| isPaused: boolean; | ||
| interval: unknown; |
|
|
||
| export function hideViewControl(hide: boolean): AnyAction; | ||
|
|
||
| export function setHiddenLayers(layer: unknown): AnyAction; |
There was a problem hiding this comment.
Can you make this setHiddenLayers(hiddenLayerIds: string[])
x-pack/legacy/plugins/maps/public/angular/get_initial_layers.d.ts
Outdated
Show resolved
Hide resolved
|
|
||
| import React from 'react'; | ||
|
|
||
| export const GisMap: React.FC<{ addFilters: unknown; renderTooltipContent: unknown }>; |
There was a problem hiding this comment.
addFilters: (filters[]) => void
renderTooltipContent: ({ addFilters, closeTooltip, features, isLocked, loadFeatureProperties}) => ReactComponent
There was a problem hiding this comment.
Functional Component. I can just change it to Component. For renderToolTip params, since I don't know the types of all those params, I'm going to just do params: unknown for now.
There was a problem hiding this comment.
actually I found the types in SIEM so moved them over
…e to the new types
|
addressed feedback @nreese. I also switched a couple places in SIEM and uptime that were using there own types to use these ones. |
...legacy/plugins/uptime/public/components/functional/location_map/embeddables/embedded_map.tsx
Show resolved
Hide resolved
…pescript-map-embeddable
nreese
left a comment
There was a problem hiding this comment.
thanks for all the updates.
x-pack/legacy/plugins/maps/public/embeddable/map_embeddable.tsx
Outdated
Show resolved
Hide resolved
x-pack/legacy/plugins/maps/public/embeddable/map_embeddable.tsx
Outdated
Show resolved
Hide resolved
| features: MapFeature[]; | ||
| isLocked: boolean; | ||
| getLayerName(layerId: string): Promise<string>; | ||
| loadFeatureProperties({ layerId, featureId }: LoadFeatureProps): Promise<FeatureProperty[]>; |
There was a problem hiding this comment.
return type is Promise<ITooltipProperty[]>, https://github.com/elastic/kibana/blob/master/x-pack/legacy/plugins/maps/public/layers/tooltips/tooltip_property.ts#L10
There was a problem hiding this comment.
This change is causing some big repercussions. Doesn't seem to match what Siem is passing in. I think I will switch back to unknown for this PR.
There was a problem hiding this comment.
actually maybe if I do TooltipProperty it'll work, instead of ITooltipProperty
There was a problem hiding this comment.
How about just unknown for loadFeatureProperties? Might as well define as much as possible.
There was a problem hiding this comment.
I worked around it but had to use a cast to unknown in SIEM.
There was a problem hiding this comment.
This looks to be a by-product of SIEM accessing _propertyKey & _rawValue directly off of TooltipProperty (getPropertyKey() & getRawValue() interface wasn't around at the time). For this I think we can just update featureProps to be ITooltipProperty in MapToolTipComponent, LineToolTipContent, and PointToolTipContent, and then use getPropertyKey() & getRawValue() instead of accessing those props directly.
Feel free to leave the unknown @stacey-gammon and I can loop back to refactor after this PR is merged -- many thanks for helping clean things up here! 🙂
Though one question for @nreese -- I had typed _rawValue as string | string[], but I see it's string | undefined in ITooltipProperty. Iirc I was indeed seeing string[] for fields like host.ip and such within the tooltip -- should _rawValue and getRawValue() include string[] as well?
There was a problem hiding this comment.
+1 for adding string[] to the value type
x-pack/plugins/maps/public/reducers/non_serializable_instances.d.ts
Outdated
Show resolved
Hide resolved
…pescript-map-embeddable
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
nreese
left a comment
There was a problem hiding this comment.
Looks great. Thanks
lgtm
code review
| ]); | ||
|
|
||
| setFeatureProps(featureProperties); | ||
| setFeatureProps((featureProperties as unknown) as FeatureProperty[]); |
There was a problem hiding this comment.
Commented on a potential cleanup here #61264 (comment), but since this involves additional SIEM refactoring I can take care of this in a follow PR, so feel free to leave as is. 👍
spong
left a comment
There was a problem hiding this comment.
SIEM changes LGTM! 👍 Thanks @stacey-gammon! 🙂
Once merged, I'll loop back around to refactor a little more on the SIEM side as mentioned here.
|
Canvas changes are literally a one line import path change so I'm going to go ahead and merge. Thanks! |
* typescript map embeddable * Address code review comments and update some usages in SIEM and uptime to the new types * More clean up - carry over some of the SIEM types to maps for render tool tip * Address more review comments
## Summary Resolves #63474, and expands `ITooltipProperty`'s `rawValue` type to include `string[]` as mentioned [here](#61264 (comment)).  ### Checklist Delete any items that are not applicable to this PR. - [X] [Unit or functional tests](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#cross-browser-compatibility) were updated or added to match the most common scenarios
## Summary Resolves elastic#63474, and expands `ITooltipProperty`'s `rawValue` type to include `string[]` as mentioned [here](elastic#61264 (comment)).  ### Checklist Delete any items that are not applicable to this PR. - [X] [Unit or functional tests](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#cross-browser-compatibility) were updated or added to match the most common scenarios
## Summary Resolves #63474, and expands `ITooltipProperty`'s `rawValue` type to include `string[]` as mentioned [here](#61264 (comment)).  ### Checklist Delete any items that are not applicable to this PR. - [X] [Unit or functional tests](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#cross-browser-compatibility) were updated or added to match the most common scenarios
## Summary Resolves elastic#63474, and expands `ITooltipProperty`'s `rawValue` type to include `string[]` as mentioned [here](elastic#61264 (comment)).  ### Checklist Delete any items that are not applicable to this PR. - [X] [Unit or functional tests](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#cross-browser-compatibility) were updated or added to match the most common scenarios # Conflicts: # x-pack/plugins/maps/public/classes/fields/es_agg_field.ts # x-pack/plugins/maps/public/classes/fields/es_doc_field.ts # x-pack/plugins/maps/public/classes/fields/field.ts # x-pack/plugins/maps/public/classes/tooltips/es_tooltip_property.ts # x-pack/plugins/maps/public/classes/tooltips/join_tooltip_property.ts # x-pack/plugins/maps/public/classes/tooltips/tooltip_property.ts # x-pack/plugins/maps/public/index.ts # x-pack/plugins/siem/public/network/components/embeddables/map_tool_tip/line_tool_tip_content.tsx # x-pack/plugins/siem/public/network/components/embeddables/map_tool_tip/map_tool_tip.tsx # x-pack/plugins/siem/public/network/components/embeddables/map_tool_tip/point_tool_tip_content.test.tsx # x-pack/plugins/siem/public/network/components/embeddables/map_tool_tip/point_tool_tip_content.tsx # x-pack/plugins/siem/public/network/components/embeddables/types.ts
## Summary Resolves elastic#63474, and expands `ITooltipProperty`'s `rawValue` type to include `string[]` as mentioned [here](elastic#61264 (comment)).  ### Checklist Delete any items that are not applicable to this PR. - [X] [Unit or functional tests](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#cross-browser-compatibility) were updated or added to match the most common scenarios # Conflicts: # x-pack/plugins/siem/public/network/components/embeddables/map_tool_tip/map_tool_tip.tsx # x-pack/plugins/siem/public/network/components/embeddables/map_tool_tip/point_tool_tip_content.test.tsx # x-pack/plugins/siem/public/network/components/embeddables/map_tool_tip/point_tool_tip_content.tsx # x-pack/plugins/siem/public/network/components/embeddables/types.ts
## Summary Resolves #63474, and expands `ITooltipProperty`'s `rawValue` type to include `string[]` as mentioned [here](#61264 (comment)).  ### Checklist Delete any items that are not applicable to this PR. - [X] [Unit or functional tests](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#cross-browser-compatibility) were updated or added to match the most common scenarios # Conflicts: # x-pack/plugins/maps/public/classes/fields/es_agg_field.ts # x-pack/plugins/maps/public/classes/fields/es_doc_field.ts # x-pack/plugins/maps/public/classes/fields/field.ts # x-pack/plugins/maps/public/classes/tooltips/es_tooltip_property.ts # x-pack/plugins/maps/public/classes/tooltips/join_tooltip_property.ts # x-pack/plugins/maps/public/classes/tooltips/tooltip_property.ts # x-pack/plugins/maps/public/index.ts # x-pack/plugins/siem/public/network/components/embeddables/map_tool_tip/line_tool_tip_content.tsx # x-pack/plugins/siem/public/network/components/embeddables/map_tool_tip/map_tool_tip.tsx # x-pack/plugins/siem/public/network/components/embeddables/map_tool_tip/point_tool_tip_content.test.tsx # x-pack/plugins/siem/public/network/components/embeddables/map_tool_tip/point_tool_tip_content.tsx # x-pack/plugins/siem/public/network/components/embeddables/types.ts
* [SIEM] [Maps] Fixes Network Map empty tooltip (#66828) ## Summary Resolves #63474, and expands `ITooltipProperty`'s `rawValue` type to include `string[]` as mentioned [here](#61264 (comment)).  ### Checklist Delete any items that are not applicable to this PR. - [X] [Unit or functional tests](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#cross-browser-compatibility) were updated or added to match the most common scenarios # Conflicts: # x-pack/plugins/siem/public/network/components/embeddables/map_tool_tip/map_tool_tip.tsx # x-pack/plugins/siem/public/network/components/embeddables/map_tool_tip/point_tool_tip_content.test.tsx # x-pack/plugins/siem/public/network/components/embeddables/map_tool_tip/point_tool_tip_content.tsx # x-pack/plugins/siem/public/network/components/embeddables/types.ts * Updating imports... * And another

Every time I refactor something in embeddables, I miss typescript in these files. Biting the bullet and converting them over to help me out with some of my future refactorings in the pipeline.