Skip to content

Commit 3e0e2f2

Browse files
author
Corey Robertson
committed
Use MapInput type from Maps plugin
1 parent df9f2ac commit 3e0e2f2

File tree

3 files changed

+11
-33
lines changed

3 files changed

+11
-33
lines changed

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

Lines changed: 4 additions & 26 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 } from 'src/plugins/data/public';
9-
import { EmbeddableInput } from 'src/legacy/core_plugins/embeddable_api/public/np_ready/public';
108
import { getQueryFilters } from '../../../public/lib/build_embeddable_filters';
119
import { Filter, MapCenter, TimeRange as TimeRangeArg } from '../../../types';
1210
import {
@@ -15,7 +13,7 @@ import {
1513
EmbeddableExpression,
1614
} from '../../expression_types';
1715
import { getFunctionHelp } from '../../../i18n';
18-
import { Filter as DataFilter } from '../../../../../../../src/plugins/data/public';
16+
import { MapEmbeddableInput } from '../../../../../plugins/maps/public';
1917

2018
interface Arguments {
2119
id: string;
@@ -25,32 +23,12 @@ interface Arguments {
2523
timerange: TimeRangeArg | null;
2624
}
2725

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

53-
type Output = EmbeddableExpression<SavedMapInput>;
31+
type Output = EmbeddableExpression<MapEmbeddableInput>;
5432

5533
export function savedMap(): ExpressionFunctionDefinition<
5634
'savedMap',
@@ -109,8 +87,8 @@ export function savedMap(): ExpressionFunctionDefinition<
10987
filters: getQueryFilters(filters),
11088
timeRange: args.timerange || defaultTimeRange,
11189
refreshConfig: {
112-
isPaused: false,
113-
interval: 0,
90+
pause: false,
91+
value: 0,
11492
},
11593

11694
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)