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 @@ -132,6 +132,7 @@ export type LayerDescriptor = {
__dataRequests?: DataRequestDescriptor[];
__isInErrorState?: boolean;
__errorMessage?: string;
__trackedLayerDescriptor?: LayerDescriptor;
alpha?: number;
id: string;
label?: string | null;
Expand Down
18 changes: 18 additions & 0 deletions x-pack/plugins/maps/public/classes/joins/inner_join.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { IESTermSource } from '../sources/es_term_source';
import { IJoin } from './join';
import { JoinDescriptor } from '../../../common/descriptor_types';
import { ISource } from '../sources/source';

export class InnerJoin implements IJoin {
constructor(joinDescriptor: JoinDescriptor, leftSource: ISource);

getRightJoinSource(): IESTermSource;

toDescriptor(): JoinDescriptor;
}
3 changes: 3 additions & 0 deletions x-pack/plugins/maps/public/classes/joins/join.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
*/

import { IESTermSource } from '../sources/es_term_source';
import { JoinDescriptor } from '../../../common/descriptor_types';

export interface IJoin {
getRightJoinSource(): IESTermSource;

toDescriptor(): JoinDescriptor;
}
4 changes: 1 addition & 3 deletions x-pack/plugins/maps/public/classes/layers/layer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ import {
MIN_ZOOM,
SOURCE_DATA_ID_ORIGIN,
} from '../../../common/constants';
// @ts-ignore
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { copyPersistentState } from '../../reducers/util.js';
import { copyPersistentState } from '../../reducers/util';
import {
LayerDescriptor,
MapExtent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ interface ITileLayerArguments {
}

export class TileLayer extends AbstractLayer {
static type: string;
constructor(args: ITileLayerArguments);
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ export interface IVectorLayer extends ILayer {
}

export class VectorLayer extends AbstractLayer implements IVectorLayer {
static type: string;

protected readonly _style: IVectorStyle;
static createDescriptor(
options: Partial<VectorLayerDescriptor>,
Expand Down
2 changes: 0 additions & 2 deletions x-pack/plugins/maps/public/classes/sources/source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
import { ReactElement } from 'react';

import { Adapters } from 'src/plugins/inspector/public';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
// @ts-ignore
import { copyPersistentState } from '../../reducers/util';

import { SourceDescriptor } from '../../../common/descriptor_types';
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/maps/public/reducers/map.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export type MapContext = {
zoom?: number;
center?: MapCenter;
scrollZoom: boolean;
buffer?: MapExtent;
extent?: MapExtent;
mouseCoordinates?: {
lat: number;
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/maps/public/reducers/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ const updateLayerSourceDescriptorProp = (state, layerId, propName, value) => {
return { ...state, layerList: updatedList };
};

const INITIAL_STATE = {
export const DEFAULT_MAP_STATE = {
ready: false,
mapInitError: null,
goto: null,
Expand Down Expand Up @@ -133,7 +133,7 @@ const INITIAL_STATE = {
__rollbackSettings: null,
};

export function map(state = INITIAL_STATE, action) {
export function map(state = DEFAULT_MAP_STATE, action) {
switch (action.type) {
case UPDATE_DRAW_STATE:
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ interface EventHandlers {

export function setEventHandlers(eventHandlers?: EventHandlers): AnyAction;

export function getInspectorAdapters(args: unknown): Adapters | undefined;
export function getInspectorAdapters(args: unknown): Adapters;
2 changes: 2 additions & 0 deletions x-pack/plugins/maps/public/reducers/store.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ export interface MapStoreState {
export type MapStore = Store<MapStoreState>;

export function createMapStore(): MapStore;

export const DEFAULT_MAP_STORE_STATE: MapStoreState;
9 changes: 7 additions & 2 deletions x-pack/plugins/maps/public/reducers/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@

import { combineReducers, applyMiddleware, createStore, compose } from 'redux';
import thunk from 'redux-thunk';
import { ui } from './ui';
import { map } from './map';
import { ui, DEFAULT_MAP_UI_STATE } from './ui';
import { map, DEFAULT_MAP_STATE } from './map'; // eslint-disable-line import/named
import { nonSerializableInstances } from './non_serializable_instances';

export const DEFAULT_MAP_STORE_STATE = {
ui: { ...DEFAULT_MAP_UI_STATE },
map: { ...DEFAULT_MAP_STATE },
};

export function createMapStore() {
const enhancers = [applyMiddleware(thunk)];
const rootReducer = combineReducers({
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/maps/public/reducers/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export type MapUiState = {

export const DEFAULT_IS_LAYER_TOC_OPEN = true;

const INITIAL_STATE = {
export const DEFAULT_MAP_UI_STATE = {
flyoutDisplay: FLYOUT_STATE.NONE,
isFullScreen: false,
isReadOnly: false,
Expand All @@ -57,7 +57,7 @@ const INITIAL_STATE = {
};

// Reducer
export function ui(state: MapUiState = INITIAL_STATE, action: any) {
export function ui(state: MapUiState = DEFAULT_MAP_UI_STATE, action: any) {
switch (action.type) {
case UPDATE_FLYOUT:
return { ...state, flyoutDisplay: action.display };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@

export const TRACKED_LAYER_DESCRIPTOR = '__trackedLayerDescriptor';

export function copyPersistentState(input) {
export function copyPersistentState(input: any) {
if (typeof input !== 'object' || input === null) {
//primitive
// primitive
return input;
}
const copyInput = Array.isArray(input) ? [] : {};
for (const key in input) {
if (!key.startsWith('__')) {
// @ts-ignore
copyInput[key] = copyPersistentState(input[key]);
}
}
Expand Down
34 changes: 0 additions & 34 deletions x-pack/plugins/maps/public/selectors/map_selectors.d.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,17 @@ jest.mock('../kibana_services', () => ({
}),
}));

import { DEFAULT_MAP_STORE_STATE } from '../reducers/store';
import { getTimeFilters } from './map_selectors';

describe('getTimeFilters', () => {
it('should return timeFilters when contained in state', () => {
const state = {
...DEFAULT_MAP_STORE_STATE,
map: {
...DEFAULT_MAP_STORE_STATE.map,
mapState: {
...DEFAULT_MAP_STORE_STATE.map.mapState,
timeFilters: {
to: '2001-01-01',
from: '2001-12-31',
Expand All @@ -45,9 +49,12 @@ describe('getTimeFilters', () => {

it('should return kibana time filters when not contained in state', () => {
const state = {
...DEFAULT_MAP_STORE_STATE,
map: {
...DEFAULT_MAP_STORE_STATE.map,
mapState: {
timeFilters: null,
...DEFAULT_MAP_STORE_STATE.map.mapState,
timeFilters: undefined,
},
},
};
Expand Down
Loading