Skip to content

Commit cee4537

Browse files
Corey Robertsonelasticmachine
andauthored
Use MapInput type from Maps plugin (#61539) (#63706)
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
1 parent c9375a5 commit cee4537

File tree

3 files changed

+11
-32
lines changed

3 files changed

+11
-32
lines changed

x-pack/legacy/plugins/canvas/canvas_plugin_src/functions/common/saved_map.ts

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
*/
66

77
import { ExpressionFunctionDefinition } from 'src/plugins/expressions/common';
8-
import { TimeRange, Filter as DataFilter } from 'src/plugins/data/public';
9-
import { EmbeddableInput } from 'src/plugins/embeddable/public';
108
import { getQueryFilters } from '../../../public/lib/build_embeddable_filters';
119
import { Filter, MapCenter, TimeRange as TimeRangeArg } from '../../../types';
1210
import {
@@ -15,6 +13,7 @@ import {
1513
EmbeddableExpression,
1614
} from '../../expression_types';
1715
import { getFunctionHelp } from '../../../i18n';
16+
import { MapEmbeddableInput } from '../../../../../plugins/maps/public';
1817

1918
interface Arguments {
2019
id: string;
@@ -24,32 +23,12 @@ interface Arguments {
2423
timerange: TimeRangeArg | null;
2524
}
2625

27-
// Map embeddable is missing proper typings, so type is just to document what we
28-
// are expecting to pass to the embeddable
29-
export type SavedMapInput = EmbeddableInput & {
30-
id: string;
31-
isLayerTOCOpen: boolean;
32-
timeRange?: TimeRange;
33-
refreshConfig: {
34-
isPaused: boolean;
35-
interval: number;
36-
};
37-
hideFilterActions: true;
38-
filters: DataFilter[];
39-
mapCenter?: {
40-
lat: number;
41-
lon: number;
42-
zoom: number;
43-
};
44-
hiddenLayers?: string[];
45-
};
46-
4726
const defaultTimeRange = {
4827
from: 'now-15m',
4928
to: 'now',
5029
};
5130

52-
type Output = EmbeddableExpression<SavedMapInput>;
31+
type Output = EmbeddableExpression<MapEmbeddableInput>;
5332

5433
export function savedMap(): ExpressionFunctionDefinition<
5534
'savedMap',
@@ -108,8 +87,8 @@ export function savedMap(): ExpressionFunctionDefinition<
10887
filters: getQueryFilters(filters),
10988
timeRange: args.timerange || defaultTimeRange,
11089
refreshConfig: {
111-
isPaused: false,
112-
interval: 0,
90+
pause: false,
91+
value: 0,
11392
},
11493

11594
mapCenter: center,

x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/embeddable/input_type_to_expression/map.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,23 @@
55
*/
66

77
import { toExpression } from './map';
8-
import { SavedMapInput } from '../../../functions/common/saved_map';
8+
import { MapEmbeddableInput } from '../../../../../maps/public';
99
import { fromExpression, Ast } from '@kbn/interpreter/common';
1010

1111
const baseSavedMapInput = {
1212
id: 'embeddableId',
1313
filters: [],
1414
isLayerTOCOpen: false,
1515
refreshConfig: {
16-
isPaused: true,
17-
interval: 0,
16+
pause: true,
17+
value: 0,
1818
},
1919
hideFilterActions: true as true,
2020
};
2121

2222
describe('toExpression', () => {
2323
it('converts to a savedMap expression', () => {
24-
const input: SavedMapInput = {
24+
const input: MapEmbeddableInput = {
2525
...baseSavedMapInput,
2626
};
2727

@@ -39,7 +39,7 @@ describe('toExpression', () => {
3939
});
4040

4141
it('includes optional input values', () => {
42-
const input: SavedMapInput = {
42+
const input: MapEmbeddableInput = {
4343
...baseSavedMapInput,
4444
mapCenter: {
4545
lat: 1,

x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/embeddable/input_type_to_expression/map.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66

7-
import { SavedMapInput } from '../../../functions/common/saved_map';
7+
import { MapEmbeddableInput } from '../../../../../maps/public';
88

9-
export function toExpression(input: SavedMapInput): string {
9+
export function toExpression(input: MapEmbeddableInput): string {
1010
const expressionParts = [] as string[];
1111

1212
expressionParts.push('savedMap');

0 commit comments

Comments
 (0)