-
Notifications
You must be signed in to change notification settings - Fork 8.1k
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 map embeddable #61264
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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; |
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.
layerList is unknown[]
|
||
export interface RefreshConfig { | ||
isPaused: boolean; | ||
interval: unknown; |
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.
interval is a number
|
||
export function hideViewControl(hide: boolean): AnyAction; | ||
|
||
export function setHiddenLayers(layer: unknown): AnyAction; |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addFilters: (filters[]) => void
renderTooltipContent: ({ addFilters, closeTooltip, features, isLocked, loadFeatureProperties}) => ReactComponent
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.
What is React.FC
?
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
actually maybe if I do TooltipProperty
it'll work, instead of ITooltipProperty
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.
How about just unknown for loadFeatureProperties
? Might as well define as much as possible.
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.
I worked around it but had to use a cast to unknown in SIEM.
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 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+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: |
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.
Looks great. Thanks
lgtm
code review
@@ -64,7 +64,7 @@ export const MapToolTipComponent = ({ | |||
getLayerName(layerId), | |||
]); | |||
|
|||
setFeatureProps(featureProperties); | |||
setFeatureProps((featureProperties as unknown) as FeatureProperty[]); |
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.
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. 👍
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.
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)). ![image](https://user-images.githubusercontent.com/2946766/82100568-2c0e1480-96c7-11ea-958e-5b1c6b6a3db9.png) ### 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)). ![image](https://user-images.githubusercontent.com/2946766/82100568-2c0e1480-96c7-11ea-958e-5b1c6b6a3db9.png) ### 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)). ![image](https://user-images.githubusercontent.com/2946766/82100568-2c0e1480-96c7-11ea-958e-5b1c6b6a3db9.png) ### 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)). ![image](https://user-images.githubusercontent.com/2946766/82100568-2c0e1480-96c7-11ea-958e-5b1c6b6a3db9.png) ### 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)). ![image](https://user-images.githubusercontent.com/2946766/82100568-2c0e1480-96c7-11ea-958e-5b1c6b6a3db9.png) ### 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)). ![image](https://user-images.githubusercontent.com/2946766/82100568-2c0e1480-96c7-11ea-958e-5b1c6b6a3db9.png) ### 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)). ![image](https://user-images.githubusercontent.com/2946766/82100568-2c0e1480-96c7-11ea-958e-5b1c6b6a3db9.png) ### 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.