Skip to content

Commit ba2ad7d

Browse files
nreesekibanamachine
andcommitted
[Maps] show icon when layer is filtered by time and allow layers to ignore global time range (#83006)
* [Maps] show icon when layer is filtered by time and allow layers to ignore global time range * show icon if layer is narrowed by time fitler * tslint * apply global time to source check box * apply global time to join check box * tslint and jest expect updates * one more tslint fix * tslint, fix apm jest test, update time filter icon when disabling applyGlobalTime Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
1 parent 33fdc42 commit ba2ad7d

32 files changed

Lines changed: 553 additions & 376 deletions

File tree

x-pack/plugins/apm/public/components/app/RumDashboard/VisitorBreakdownMap/__tests__/__mocks__/regions_layer.mock.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ export const mockLayerList = [
2121
{
2222
leftField: 'iso2',
2323
right: {
24+
applyGlobalQuery: true,
25+
applyGlobalTime: true,
2426
type: 'ES_TERM_SOURCE',
2527
id: '3657625d-17b0-41ef-99ba-3a2b2938655c',
2628
indexPatternTitle: 'apm-*',
@@ -38,15 +40,13 @@ export const mockLayerList = [
3840
},
3941
],
4042
indexPatternId: 'apm_static_index_pattern_id',
41-
applyGlobalQuery: true,
4243
},
4344
},
4445
],
4546
sourceDescriptor: {
4647
type: 'EMS_FILE',
4748
id: 'world_countries',
4849
tooltipProperties: ['name'],
49-
applyGlobalQuery: true,
5050
},
5151
style: {
5252
type: 'VECTOR',
@@ -96,6 +96,8 @@ export const mockLayerList = [
9696
{
9797
leftField: 'region_iso_code',
9898
right: {
99+
applyGlobalQuery: true,
100+
applyGlobalTime: true,
99101
type: 'ES_TERM_SOURCE',
100102
id: 'e62a1b9c-d7ff-4fd4-a0f6-0fdc44bb9e41',
101103
indexPatternTitle: 'apm-*',

x-pack/plugins/apm/public/components/app/RumDashboard/VisitorBreakdownMap/useLayerList.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ const ES_TERM_SOURCE_COUNTRY: ESTermSourceDescriptor = {
4343
],
4444
indexPatternId: APM_STATIC_INDEX_PATTERN_ID,
4545
applyGlobalQuery: true,
46+
applyGlobalTime: true,
4647
};
4748

4849
const ES_TERM_SOURCE_REGION: ESTermSourceDescriptor = {
@@ -56,6 +57,8 @@ const ES_TERM_SOURCE_REGION: ESTermSourceDescriptor = {
5657
language: 'kuery',
5758
},
5859
indexPatternId: APM_STATIC_INDEX_PATTERN_ID,
60+
applyGlobalQuery: true,
61+
applyGlobalTime: true,
5962
};
6063

6164
const getWhereQuery = (serviceName: string) => {
@@ -158,7 +161,6 @@ export function useLayerList() {
158161
type: 'EMS_FILE',
159162
id: 'world_countries',
160163
tooltipProperties: [COUNTRY_NAME],
161-
applyGlobalQuery: true,
162164
},
163165
style: getLayerStyle(TRANSACTION_DURATION_COUNTRY),
164166
id: 'e8d1d974-eed8-462f-be2c-f0004b7619b2',

x-pack/plugins/maps/common/descriptor_types/data_request_descriptor_types.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,17 @@ export type VectorSourceSyncMeta = ESSearchSourceSyncMeta | ESGeoGridSourceSyncM
3838

3939
export type VectorSourceRequestMeta = MapFilters & {
4040
applyGlobalQuery: boolean;
41+
applyGlobalTime: boolean;
4142
fieldNames: string[];
4243
geogridPrecision?: number;
4344
sourceQuery?: MapQuery;
4445
sourceMeta: VectorSourceSyncMeta;
4546
};
4647

47-
export type VectorJoinSourceRequestMeta = MapFilters & {
48-
applyGlobalQuery: boolean;
49-
fieldNames: string[];
50-
sourceQuery?: Query;
51-
};
48+
export type VectorJoinSourceRequestMeta = Omit<
49+
VectorSourceRequestMeta,
50+
'geogridPrecision' | 'sourceMeta'
51+
> & { sourceQuery?: Query };
5252

5353
export type VectorStyleRequestMeta = MapFilters & {
5454
dynamicStyleFields: string[];

x-pack/plugins/maps/common/descriptor_types/source_descriptor_types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ export type AttributionDescriptor = {
1818
export type AbstractSourceDescriptor = {
1919
id?: string;
2020
type: string;
21-
applyGlobalQuery?: boolean;
2221
};
2322

2423
export type EMSTMSSourceDescriptor = AbstractSourceDescriptor & {
@@ -37,6 +36,8 @@ export type AbstractESSourceDescriptor = AbstractSourceDescriptor & {
3736
id: string;
3837
indexPatternId: string;
3938
geoField?: string;
39+
applyGlobalQuery: boolean;
40+
applyGlobalTime: boolean;
4041
};
4142

4243
export type AggDescriptor = {

x-pack/plugins/maps/public/classes/layers/choropleth_layer_wizard/create_choropleth_layer_descriptor.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ function createChoroplethLayerDescriptor({
6161
indexPatternTitle: rightIndexPatternTitle,
6262
term: rightTermField,
6363
metrics: [metricsDescriptor],
64+
applyGlobalQuery: true,
65+
applyGlobalTime: true,
6466
},
6567
},
6668
],

x-pack/plugins/maps/public/classes/layers/create_region_map_layer_descriptor.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ export function createRegionMapLayerDescriptor({
8787
indexPatternTitle: indexPatternTitle ? indexPatternTitle : indexPatternId,
8888
term: termsFieldName,
8989
metrics: [metricsDescriptor],
90+
applyGlobalQuery: true,
91+
applyGlobalTime: true,
9092
},
9193
},
9294
],

x-pack/plugins/maps/public/classes/layers/layer.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ describe('cloneDescriptor', () => {
7474
metrics: [{ type: AGG_TYPE.COUNT }],
7575
term: 'myTermField',
7676
type: 'joinSource',
77+
applyGlobalQuery: true,
78+
applyGlobalTime: true,
7779
},
7880
},
7981
],

x-pack/plugins/maps/public/classes/layers/layer.tsx

Lines changed: 8 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@
88
import { Query } from 'src/plugins/data/public';
99
import _ from 'lodash';
1010
import React, { ReactElement } from 'react';
11-
import { EuiIcon, EuiLoadingSpinner } from '@elastic/eui';
11+
import { EuiIcon } from '@elastic/eui';
1212
import uuid from 'uuid/v4';
13-
import { i18n } from '@kbn/i18n';
1413
import { FeatureCollection } from 'geojson';
1514
import { DataRequest } from '../util/data_request';
1615
import {
@@ -49,8 +48,6 @@ export interface ILayer {
4948
supportsFitToBounds(): Promise<boolean>;
5049
getAttributions(): Promise<Attribution[]>;
5150
getLabel(): string;
52-
getCustomIconAndTooltipContent(): CustomIconAndTooltipContent;
53-
getIconAndTooltipContent(zoomLevel: number, isUsingSearch: boolean): IconAndTooltipContent;
5451
renderLegendDetails(): ReactElement<any> | null;
5552
showAtZoomLevel(zoom: number): boolean;
5653
getMinZoom(): number;
@@ -64,6 +61,7 @@ export interface ILayer {
6461
getImmutableSourceProperties(): Promise<ImmutableSourceProperty[]>;
6562
renderSourceSettingsEditor({ onChange }: SourceEditorArgs): ReactElement<any> | null;
6663
isLayerLoading(): boolean;
64+
isFilteredByGlobalTime(): Promise<boolean>;
6765
hasErrors(): boolean;
6866
getErrors(): string;
6967
getMbLayerIds(): string[];
@@ -93,16 +91,9 @@ export interface ILayer {
9391
getJoinsDisabledReason(): string | null;
9492
isFittable(): Promise<boolean>;
9593
getLicensedFeatures(): Promise<LICENSED_FEATURES[]>;
94+
getCustomIconAndTooltipContent(): CustomIconAndTooltipContent;
9695
}
97-
export type Footnote = {
98-
icon: ReactElement<any>;
99-
message?: string | null;
100-
};
101-
export type IconAndTooltipContent = {
102-
icon?: ReactElement<any> | null;
103-
tooltipContent?: string | null;
104-
footnotes: Footnote[];
105-
};
96+
10697
export type CustomIconAndTooltipContent = {
10798
icon: ReactElement<any> | null;
10899
tooltipContent?: string | null;
@@ -237,6 +228,10 @@ export class AbstractLayer implements ILayer {
237228
return (await this.supportsFitToBounds()) && this.isVisible();
238229
}
239230

231+
async isFilteredByGlobalTime(): Promise<boolean> {
232+
return false;
233+
}
234+
240235
async getDisplayName(source?: ISource): Promise<string> {
241236
if (this._descriptor.label) {
242237
return this._descriptor.label;
@@ -277,68 +272,6 @@ export class AbstractLayer implements ILayer {
277272
};
278273
}
279274

280-
getIconAndTooltipContent(zoomLevel: number, isUsingSearch: boolean): IconAndTooltipContent {
281-
let icon;
282-
let tooltipContent = null;
283-
const footnotes = [];
284-
if (this.hasErrors()) {
285-
icon = (
286-
<EuiIcon
287-
aria-label={i18n.translate('xpack.maps.layer.loadWarningAriaLabel', {
288-
defaultMessage: 'Load warning',
289-
})}
290-
size="m"
291-
type="alert"
292-
color="warning"
293-
/>
294-
);
295-
tooltipContent = this.getErrors();
296-
} else if (this.isLayerLoading()) {
297-
icon = <EuiLoadingSpinner size="m" />;
298-
} else if (!this.isVisible()) {
299-
icon = <EuiIcon size="m" type="eyeClosed" />;
300-
tooltipContent = i18n.translate('xpack.maps.layer.layerHiddenTooltip', {
301-
defaultMessage: `Layer is hidden.`,
302-
});
303-
} else if (!this.showAtZoomLevel(zoomLevel)) {
304-
const minZoom = this.getMinZoom();
305-
const maxZoom = this.getMaxZoom();
306-
icon = <EuiIcon size="m" type="expand" />;
307-
tooltipContent = i18n.translate('xpack.maps.layer.zoomFeedbackTooltip', {
308-
defaultMessage: `Layer is visible between zoom levels {minZoom} and {maxZoom}.`,
309-
values: { minZoom, maxZoom },
310-
});
311-
} else {
312-
const customIconAndTooltipContent = this.getCustomIconAndTooltipContent();
313-
if (customIconAndTooltipContent) {
314-
icon = customIconAndTooltipContent.icon;
315-
if (!customIconAndTooltipContent.areResultsTrimmed) {
316-
tooltipContent = customIconAndTooltipContent.tooltipContent;
317-
} else {
318-
footnotes.push({
319-
icon: <EuiIcon color="subdued" type="partial" size="s" />,
320-
message: customIconAndTooltipContent.tooltipContent,
321-
});
322-
}
323-
}
324-
325-
if (isUsingSearch && this.getQueryableIndexPatternIds().length) {
326-
footnotes.push({
327-
icon: <EuiIcon color="subdued" type="filter" size="s" />,
328-
message: i18n.translate('xpack.maps.layer.isUsingSearchMsg', {
329-
defaultMessage: 'Results narrowed by search bar',
330-
}),
331-
});
332-
}
333-
}
334-
335-
return {
336-
icon,
337-
tooltipContent,
338-
footnotes,
339-
};
340-
}
341-
342275
async hasLegendDetails(): Promise<boolean> {
343276
return false;
344277
}

x-pack/plugins/maps/public/classes/layers/solution_layers/observability/create_layer_descriptor.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ describe('createLayerDescriptor', () => {
3939
{
4040
leftField: 'iso2',
4141
right: {
42+
applyGlobalQuery: true,
43+
applyGlobalTime: true,
4244
id: '12345',
4345
indexPatternId: 'apm_static_index_pattern_id',
4446
indexPatternTitle: 'apm-*',
@@ -176,6 +178,7 @@ describe('createLayerDescriptor', () => {
176178
},
177179
sourceDescriptor: {
178180
applyGlobalQuery: true,
181+
applyGlobalTime: true,
179182
geoField: 'client.geo.location',
180183
id: '12345',
181184
indexPatternId: 'apm_static_index_pattern_id',
@@ -218,6 +221,7 @@ describe('createLayerDescriptor', () => {
218221
},
219222
sourceDescriptor: {
220223
applyGlobalQuery: true,
224+
applyGlobalTime: true,
221225
geoField: 'client.geo.location',
222226
id: '12345',
223227
indexPatternId: 'apm_static_index_pattern_id',

x-pack/plugins/maps/public/classes/layers/solution_layers/observability/create_layer_descriptor.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,8 @@ export function createLayerDescriptor({
177177
term: 'client.geo.country_iso_code',
178178
metrics: [metricsDescriptor],
179179
whereQuery: apmSourceQuery,
180+
applyGlobalQuery: true,
181+
applyGlobalTime: true,
180182
},
181183
},
182184
],

0 commit comments

Comments
 (0)