Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
*/

import { ExpressionFunctionDefinition } from 'src/plugins/expressions/common';
import { TimeRange, Filter as DataFilter } from 'src/plugins/data/public';
import { EmbeddableInput } from 'src/plugins/embeddable/public';
import { getQueryFilters } from '../../../public/lib/build_embeddable_filters';
import { Filter, MapCenter, TimeRange as TimeRangeArg } from '../../../types';
import {
Expand All @@ -15,6 +13,7 @@ import {
EmbeddableExpression,
} from '../../expression_types';
import { getFunctionHelp } from '../../../i18n';
import { MapEmbeddableInput } from '../../../../../plugins/maps/public';

interface Arguments {
id: string;
Expand All @@ -24,32 +23,12 @@ interface Arguments {
timerange: TimeRangeArg | null;
}

// Map embeddable is missing proper typings, so type is just to document what we
// are expecting to pass to the embeddable
export type SavedMapInput = EmbeddableInput & {
id: string;
isLayerTOCOpen: boolean;
timeRange?: TimeRange;
refreshConfig: {
isPaused: boolean;
interval: number;
};
hideFilterActions: true;
filters: DataFilter[];
mapCenter?: {
lat: number;
lon: number;
zoom: number;
};
hiddenLayers?: string[];
};

const defaultTimeRange = {
from: 'now-15m',
to: 'now',
};

type Output = EmbeddableExpression<SavedMapInput>;
type Output = EmbeddableExpression<MapEmbeddableInput>;

export function savedMap(): ExpressionFunctionDefinition<
'savedMap',
Expand Down Expand Up @@ -108,8 +87,8 @@ export function savedMap(): ExpressionFunctionDefinition<
filters: getQueryFilters(filters),
timeRange: args.timerange || defaultTimeRange,
refreshConfig: {
isPaused: false,
interval: 0,
pause: false,
value: 0,
},

mapCenter: center,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@
*/

import { toExpression } from './map';
import { SavedMapInput } from '../../../functions/common/saved_map';
import { MapEmbeddableInput } from '../../../../../maps/public';
import { fromExpression, Ast } from '@kbn/interpreter/common';

const baseSavedMapInput = {
id: 'embeddableId',
filters: [],
isLayerTOCOpen: false,
refreshConfig: {
isPaused: true,
interval: 0,
pause: true,
value: 0,
},
hideFilterActions: true as true,
};

describe('toExpression', () => {
it('converts to a savedMap expression', () => {
const input: SavedMapInput = {
const input: MapEmbeddableInput = {
...baseSavedMapInput,
};

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

it('includes optional input values', () => {
const input: SavedMapInput = {
const input: MapEmbeddableInput = {
...baseSavedMapInput,
mapCenter: {
lat: 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { SavedMapInput } from '../../../functions/common/saved_map';
import { MapEmbeddableInput } from '../../../../../maps/public';

export function toExpression(input: SavedMapInput): string {
export function toExpression(input: MapEmbeddableInput): string {
const expressionParts = [] as string[];

expressionParts.push('savedMap');
Expand Down