Skip to content
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

Conversation

stacey-gammon
Copy link
Contributor

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.

@stacey-gammon stacey-gammon force-pushed the 2020-03-25-typescript-map-embeddable branch from b666d90 to 2b06743 Compare March 25, 2020 14:34
@stacey-gammon stacey-gammon added the [Deprecated-Use Team:Presentation]Team:Geo Former Team Label for Geo Team. Now use Team:Presentation label Mar 25, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-gis (Team:Geo)

@stacey-gammon stacey-gammon added chore release_note:skip Skip the PR/issue when compiling release notes v7.8 v8.0.0 labels Mar 25, 2020
@nreese
Copy link
Contributor

nreese commented Mar 25, 2020

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

@stacey-gammon stacey-gammon force-pushed the 2020-03-25-typescript-map-embeddable branch from 2b06743 to bdcd5e0 Compare March 25, 2020 14:48
@stacey-gammon stacey-gammon force-pushed the 2020-03-25-typescript-map-embeddable branch from bdcd5e0 to ce18bb1 Compare March 25, 2020 14:53
@stacey-gammon stacey-gammon marked this pull request as ready for review March 25, 2020 16:49
@stacey-gammon stacey-gammon requested a review from a team as a code owner March 25, 2020 16:49
Copy link
Contributor

@nreese nreese left a 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;
Copy link
Contributor

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;
Copy link
Contributor

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;
Copy link
Contributor

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/actions/map_actions.d.ts Outdated Show resolved Hide resolved
x-pack/legacy/plugins/maps/public/actions/map_actions.d.ts Outdated Show resolved Hide resolved
x-pack/legacy/plugins/maps/public/actions/ui_actions.d.ts Outdated Show resolved Hide resolved

import React from 'react';

export const GisMap: React.FC<{ addFilters: unknown; renderTooltipContent: unknown }>;
Copy link
Contributor

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is React.FC?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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

@stacey-gammon stacey-gammon requested a review from a team as a code owner March 26, 2020 13:52
@stacey-gammon
Copy link
Contributor Author

addressed feedback @nreese. I also switched a couple places in SIEM and uptime that were using there own types to use these ones.

Copy link
Contributor

@nreese nreese left a 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/types.ts Outdated Show resolved Hide resolved
features: MapFeature[];
isLocked: boolean;
getLayerName(layerId: string): Promise<string>;
loadFeatureProperties({ layerId, featureId }: LoadFeatureProps): Promise<FeatureProperty[]>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screen Shot 2020-03-26 at 1 24 58 PM

Copy link
Contributor Author

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

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Member

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?

Copy link
Contributor

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/legacy/plugins/maps/public/embeddable/types.ts Outdated Show resolved Hide resolved
x-pack/plugins/maps/public/index.ts Show resolved Hide resolved
@stacey-gammon stacey-gammon requested a review from a team as a code owner March 26, 2020 17:50
@kibanamachine
Copy link
Contributor

💚 Build Succeeded

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

Copy link
Contributor

@nreese nreese left a 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[]);
Copy link
Member

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. 👍

Copy link
Member

@spong spong left a 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.

@stacey-gammon
Copy link
Contributor Author

Canvas changes are literally a one line import path change so I'm going to go ahead and merge. Thanks!

@stacey-gammon stacey-gammon merged commit 65452bd into elastic:master Mar 26, 2020
stacey-gammon added a commit to stacey-gammon/kibana that referenced this pull request Mar 26, 2020
* 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
stacey-gammon added a commit that referenced this pull request Mar 27, 2020
* 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
@rayafratkina rayafratkina added v7.8.0 and removed v7.8 labels Apr 6, 2020
spong added a commit that referenced this pull request May 18, 2020
## 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
spong added a commit to spong/kibana that referenced this pull request May 19, 2020
## 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
spong added a commit that referenced this pull request May 19, 2020
## 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
spong added a commit to spong/kibana that referenced this pull request May 19, 2020
## 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
spong added a commit to spong/kibana that referenced this pull request May 19, 2020
## 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
spong added a commit that referenced this pull request May 19, 2020
## 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
spong added a commit that referenced this pull request May 19, 2020
* [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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore [Deprecated-Use Team:Presentation]Team:Geo Former Team Label for Geo Team. Now use Team:Presentation release_note:skip Skip the PR/issue when compiling release notes v7.8.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants