Skip to content

Commit dc49b19

Browse files
authored
[7.8] [SIEM] [Maps] Fixes Network Map empty tooltip (#66828) (#66956)
* [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
1 parent d0dbf70 commit dc49b19

File tree

15 files changed

+61
-112
lines changed

15 files changed

+61
-112
lines changed

x-pack/plugins/maps/public/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ export const plugin: PluginInitializer<MapsPluginSetup, MapsPluginStart> = () =>
1212
};
1313

1414
export { MAP_SAVED_OBJECT_TYPE } from '../common/constants';
15+
export { ITooltipProperty } from './layers/tooltips/tooltip_property';

x-pack/plugins/maps/public/layers/fields/es_agg_field.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export class ESAggField implements IESAggField {
8787
return this._esDocField ? this._esDocField.getName() : '';
8888
}
8989

90-
async createTooltipProperty(value: string | undefined): Promise<ITooltipProperty> {
90+
async createTooltipProperty(value: string | string[] | undefined): Promise<ITooltipProperty> {
9191
const indexPattern = await this._source.getIndexPattern();
9292
const tooltipProperty = new TooltipProperty(this.getName(), await this.getLabel(), value);
9393
return new ESAggTooltipProperty(tooltipProperty, indexPattern, this, this.getAggType());

x-pack/plugins/maps/public/layers/fields/es_doc_field.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export class ESDocField extends AbstractField implements IField {
4545
: indexPatternField;
4646
}
4747

48-
async createTooltipProperty(value: string | undefined): Promise<ITooltipProperty> {
48+
async createTooltipProperty(value: string | string[] | undefined): Promise<ITooltipProperty> {
4949
const indexPattern = await this._source.getIndexPattern();
5050
const tooltipProperty = new TooltipProperty(this.getName(), await this.getLabel(), value);
5151
return new ESTooltipProperty(tooltipProperty, indexPattern, this as IField);

x-pack/plugins/maps/public/layers/fields/field.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export interface IField {
1414
canValueBeFormatted(): boolean;
1515
getLabel(): Promise<string>;
1616
getDataType(): Promise<string>;
17-
createTooltipProperty(value: string | undefined): Promise<ITooltipProperty>;
17+
createTooltipProperty(value: string | string[] | undefined): Promise<ITooltipProperty>;
1818
getSource(): IVectorSource;
1919
getOrigin(): FIELD_ORIGIN;
2020
isValid(): boolean;
@@ -60,7 +60,7 @@ export class AbstractField implements IField {
6060
return this._fieldName;
6161
}
6262

63-
async createTooltipProperty(value: string | undefined): Promise<ITooltipProperty> {
63+
async createTooltipProperty(value: string | string[] | undefined): Promise<ITooltipProperty> {
6464
const label = await this.getLabel();
6565
return new TooltipProperty(this.getName(), label, value);
6666
}

x-pack/plugins/maps/public/layers/fields/top_term_percentage_field.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export class TopTermPercentageField implements IESAggField {
4848
return 'number';
4949
}
5050

51-
async createTooltipProperty(value: string | undefined): Promise<ITooltipProperty> {
51+
async createTooltipProperty(value: string | string[] | undefined): Promise<ITooltipProperty> {
5252
return new TooltipProperty(this.getName(), await this.getLabel(), value);
5353
}
5454

x-pack/plugins/maps/public/layers/tooltips/es_tooltip_property.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export class ESTooltipProperty implements ITooltipProperty {
3333
return this._tooltipProperty.getPropertyName();
3434
}
3535

36-
getRawValue(): string | undefined {
36+
getRawValue(): string | string[] | undefined {
3737
return this._tooltipProperty.getRawValue();
3838
}
3939

@@ -48,7 +48,12 @@ export class ESTooltipProperty implements ITooltipProperty {
4848

4949
const indexPatternField = this._getIndexPatternField();
5050
if (!indexPatternField || !this._field.canValueBeFormatted()) {
51-
return _.escape(this.getRawValue());
51+
const rawValue = this.getRawValue();
52+
if (Array.isArray(rawValue)) {
53+
return _.escape(rawValue.join());
54+
} else {
55+
return _.escape(rawValue);
56+
}
5257
}
5358

5459
const htmlConverter = indexPatternField.format.getConverterFor('html');

x-pack/plugins/maps/public/layers/tooltips/join_tooltip_property.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export class JoinTooltipProperty implements ITooltipProperty {
2929
return this._tooltipProperty.getPropertyName();
3030
}
3131

32-
getRawValue(): string | undefined {
32+
getRawValue(): string | string[] | undefined {
3333
return this._tooltipProperty.getRawValue();
3434
}
3535

x-pack/plugins/maps/public/layers/tooltips/tooltip_property.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export interface ITooltipProperty {
1212
getPropertyKey(): string;
1313
getPropertyName(): string;
1414
getHtmlDisplayValue(): string;
15-
getRawValue(): string | undefined;
15+
getRawValue(): string | string[] | undefined;
1616
isFilterable(): boolean;
1717
getESFilters(): Promise<Filter[]>;
1818
}
@@ -41,10 +41,10 @@ export type RenderToolTipContent = (params: RenderTooltipContentParams) => JSX.E
4141

4242
export class TooltipProperty implements ITooltipProperty {
4343
private readonly _propertyKey: string;
44-
private readonly _rawValue: string | undefined;
44+
private readonly _rawValue: string | string[] | undefined;
4545
private readonly _propertyName: string;
4646

47-
constructor(propertyKey: string, propertyName: string, rawValue: string | undefined) {
47+
constructor(propertyKey: string, propertyName: string, rawValue: string | string[] | undefined) {
4848
this._propertyKey = propertyKey;
4949
this._propertyName = propertyName;
5050
this._rawValue = rawValue;
@@ -59,10 +59,10 @@ export class TooltipProperty implements ITooltipProperty {
5959
}
6060

6161
getHtmlDisplayValue(): string {
62-
return _.escape(this._rawValue);
62+
return _.escape(Array.isArray(this._rawValue) ? this._rawValue.join() : this._rawValue);
6363
}
6464

65-
getRawValue(): string | undefined {
65+
getRawValue(): string | string[] | undefined {
6666
return this._rawValue;
6767
}
6868

x-pack/plugins/siem/public/components/embeddables/map_tool_tip/__snapshots__/point_tool_tip_content.test.tsx.snap

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/plugins/siem/public/components/embeddables/map_tool_tip/line_tool_tip_content.test.tsx

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,24 @@
77
import { shallow } from 'enzyme';
88
import React from 'react';
99
import { LineToolTipContentComponent } from './line_tool_tip_content';
10-
import { FeatureProperty } from '../types';
1110
import {
1211
SUM_OF_CLIENT_BYTES,
1312
SUM_OF_DESTINATION_BYTES,
1413
SUM_OF_SERVER_BYTES,
1514
SUM_OF_SOURCE_BYTES,
1615
} from '../map_config';
16+
import { ITooltipProperty } from '../../../../../maps/public';
17+
import { TooltipProperty } from '../../../../../maps/public/layers/tooltips/tooltip_property';
1718

1819
describe('LineToolTipContent', () => {
19-
const mockFeatureProps: FeatureProperty[] = [
20-
{
21-
_propertyKey: SUM_OF_DESTINATION_BYTES,
22-
_rawValue: 'testPropValue',
23-
},
24-
{
25-
_propertyKey: SUM_OF_SOURCE_BYTES,
26-
_rawValue: 'testPropValue',
27-
},
20+
const mockFeatureProps: ITooltipProperty[] = [
21+
new TooltipProperty(SUM_OF_DESTINATION_BYTES, SUM_OF_DESTINATION_BYTES, 'testPropValue'),
22+
new TooltipProperty(SUM_OF_SOURCE_BYTES, SUM_OF_SOURCE_BYTES, 'testPropValue'),
2823
];
2924

30-
const mockClientServerFeatureProps: FeatureProperty[] = [
31-
{
32-
_propertyKey: SUM_OF_SERVER_BYTES,
33-
_rawValue: 'testPropValue',
34-
},
35-
{
36-
_propertyKey: SUM_OF_CLIENT_BYTES,
37-
_rawValue: 'testPropValue',
38-
},
25+
const mockClientServerFeatureProps: ITooltipProperty[] = [
26+
new TooltipProperty(SUM_OF_SERVER_BYTES, SUM_OF_SERVER_BYTES, 'testPropValue'),
27+
new TooltipProperty(SUM_OF_CLIENT_BYTES, SUM_OF_CLIENT_BYTES, 'testPropValue'),
3928
];
4029

4130
test('renders correctly against snapshot', () => {

0 commit comments

Comments
 (0)