Skip to content

Commit

Permalink
tslint
Browse files Browse the repository at this point in the history
  • Loading branch information
nreese committed May 17, 2024
1 parent eefc86b commit de91f6e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,6 @@
*/

import { savedMap } from './saved_map';
import { getQueryFilters } from '../../../common/lib/build_embeddable_filters';
import { ExpressionValueFilter } from '../../../types';

const filterContext: ExpressionValueFilter = {
type: 'filter',
and: [
{
type: 'filter',
and: [],
value: 'filter-value',
column: 'filter-column',
filterType: 'exactly',
},
{
type: 'filter',
and: [],
column: 'time-column',
filterType: 'time',
from: '2019-06-04T04:00:00.000Z',
to: '2019-06-05T04:00:00.000Z',
},
],
};

describe('savedMap', () => {
const fn = savedMap().fn;
Expand All @@ -43,13 +20,18 @@ describe('savedMap', () => {
it('accepts null context', () => {
const expression = fn(null, args, {} as any);

expect(expression.input.filters).toEqual([]);
});

it('accepts filter context', () => {
const expression = fn(filterContext, args, {} as any);
const embeddableFilters = getQueryFilters(filterContext.and);

expect(expression.input.filters).toEqual(embeddableFilters);
expect(expression.input).toEqual({
hiddenLayers: [],
hideFilterActions: true,
id: 'some-id',
isLayerTOCOpen: false,
mapCenter: undefined,
savedObjectId: 'some-id',
timeRange: {
from: 'now-15m',
to: 'now',
},
title: undefined,
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import { ExpressionFunctionDefinition } from '@kbn/expressions-plugin/common';
import type { MapSerializedState } from '@kbn/maps-plugin/public';
import { SavedObjectReference } from '@kbn/core/types';
import { getQueryFilters } from '../../../common/lib/build_embeddable_filters';
import { ExpressionValueFilter, MapCenter, TimeRange as TimeRangeArg } from '../../../types';
import {
EmbeddableTypes,
Expand Down Expand Up @@ -72,30 +71,19 @@ export function savedMap(): ExpressionFunctionDefinition<
},
type: EmbeddableExpressionType,
fn: (input, args) => {
const filters = input ? input.and : [];

const center = args.center
? {
lat: args.center.lat,
lon: args.center.lon,
zoom: args.center.zoom,
}
: undefined;

return {
type: EmbeddableExpressionType,
input: {
id: args.id,
attributes: { title: '' },
savedObjectId: args.id,
filters: getQueryFilters(filters),
timeRange: args.timerange || defaultTimeRange,
refreshConfig: {
pause: false,
value: 0,
},

mapCenter: center,
mapCenter: args.center
? {
lat: args.center.lat,
lon: args.center.lon,
zoom: args.center.zoom,
}
: undefined,
hideFilterActions: true,
title: args.title === null ? undefined : args.title,
isLayerTOCOpen: false,
Expand Down

0 comments on commit de91f6e

Please sign in to comment.