Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Maps] Convert AbstractSource and AbstractLayer to TS #63533

Merged
merged 31 commits into from
Apr 22, 2020
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
aa2243a
initial commit
thomasneirynck Apr 14, 2020
331db51
fix more typing errors
thomasneirynck Apr 14, 2020
039da8b
more fixes
thomasneirynck Apr 14, 2020
e86a98b
fixes
thomasneirynck Apr 14, 2020
fea5eb2
compile issues
thomasneirynck Apr 14, 2020
1da66d6
tmp commit
thomasneirynck Apr 15, 2020
e0d6027
Merge branch 'master' of github.com:elastic/kibana into maps/ts_sourc…
thomasneirynck Apr 15, 2020
37668b6
simplify typing
thomasneirynck Apr 15, 2020
39aafdc
cleanup sigs in selectors
thomasneirynck Apr 15, 2020
ffa3364
feedback
thomasneirynck Apr 15, 2020
46cb60f
Merge branch 'master' of github.com:elastic/kibana into maps/ts_sourc…
thomasneirynck Apr 16, 2020
a07bccc
feedback
thomasneirynck Apr 16, 2020
b0cfd08
feedback
thomasneirynck Apr 16, 2020
74921aa
dont make optional
thomasneirynck Apr 16, 2020
7e179a5
Merge branch 'master' into maps/ts_source_layer
thomasneirynck Apr 16, 2020
674a440
Merge branch 'master' of github.com:elastic/kibana into maps/ts_sourc…
thomasneirynck Apr 16, 2020
5632680
fix faulty merge
thomasneirynck Apr 16, 2020
0a38ad1
fix tests
thomasneirynck Apr 16, 2020
431c702
fix typing
thomasneirynck Apr 16, 2020
a9cbf10
Merge branch 'master' into maps/ts_source_layer
elasticmachine Apr 17, 2020
eb9a691
Merge branch 'master' into maps/ts_source_layer
elasticmachine Apr 20, 2020
0877b61
Feedback
thomasneirynck Apr 20, 2020
28ffcc9
Merge branch 'master' of github.com:elastic/kibana into maps/ts_sourc…
thomasneirynck Apr 20, 2020
9db3ae8
Merge branch 'master' of github.com:elastic/kibana into maps/ts_sourc…
thomasneirynck Apr 20, 2020
3e9decc
Merge branch 'master' into maps/ts_source_layer
thomasneirynck Apr 21, 2020
908dca6
rename for consistency
thomasneirynck Apr 21, 2020
0818769
custom deep-equls
thomasneirynck Apr 21, 2020
8b49807
Revert "custom deep-equls"
thomasneirynck Apr 21, 2020
7d79866
init tile-style
thomasneirynck Apr 21, 2020
237d7ed
allow null
thomasneirynck Apr 21, 2020
0151cd2
fix test to reflect normalization
thomasneirynck Apr 22, 2020
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
8 changes: 5 additions & 3 deletions x-pack/legacy/plugins/maps/public/selectors/map_selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import { createSelector } from 'reselect';
import _ from 'lodash';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { TileStyle } from '../../../../../plugins/maps/public/layers/styles/tile/tile_style';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { TileLayer } from '../../../../../plugins/maps/public/layers/tile_layer';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { VectorTileLayer } from '../../../../../plugins/maps/public/layers/vector_tile_layer';
Expand Down Expand Up @@ -34,7 +36,7 @@ function createLayerInstance(layerDescriptor, inspectorAdapters) {

switch (layerDescriptor.type) {
case TileLayer.type:
return new TileLayer({ layerDescriptor, source });
return new TileLayer({ layerDescriptor, source, style: new TileStyle() });
thomasneirynck marked this conversation as resolved.
Show resolved Hide resolved
case VectorLayer.type:
const joins = [];
if (layerDescriptor.joins) {
Expand All @@ -45,11 +47,11 @@ function createLayerInstance(layerDescriptor, inspectorAdapters) {
}
return new VectorLayer({ layerDescriptor, source, joins });
case VectorTileLayer.type:
return new VectorTileLayer({ layerDescriptor, source });
return new VectorTileLayer({ layerDescriptor, source, style: new TileStyle() });
thomasneirynck marked this conversation as resolved.
Show resolved Hide resolved
case HeatmapLayer.type:
return new HeatmapLayer({ layerDescriptor, source });
case BlendedVectorLayer.type:
return new BlendedVectorLayer({ layerDescriptor, source });
return new BlendedVectorLayer({ layerDescriptor, source, joins: [] });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does BlendedVectorLayer take joins? BlendedVectorLayer does not support joins so this seams like a strange thing to expose in the constructor.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consequence of requiring VectorLayerArguments as param. Can create new param-type

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or just make joins optional?

default:
throw new Error(`Unrecognized layerType ${layerDescriptor.type}`);
}
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/maps/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ export enum STYLE_TYPE {
export enum LAYER_STYLE_TYPE {
VECTOR = 'VECTOR',
HEATMAP = 'HEATMAP',
TILE = 'TILE',
}

export const COLOR_MAP_TYPE = {
Expand Down
24 changes: 17 additions & 7 deletions x-pack/plugins/maps/common/descriptor_types/descriptor_types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* eslint-disable @typescript-eslint/consistent-type-definitions */

import { AGG_TYPE, GRID_RESOLUTION, RENDER_AS, SORT_ORDER, SCALING_TYPES } from '../constants';
import { VectorStyleDescriptor } from './style_property_descriptor_types';
import { StyleDescriptor, VectorStyleDescriptor } from './style_property_descriptor_types';
import { DataRequestDescriptor } from './data_request_descriptor_types';

export type AttributionDescriptor = {
Expand All @@ -17,6 +17,7 @@ export type AttributionDescriptor = {
export type AbstractSourceDescriptor = {
id?: string;
type: string;
applyGlobalQuery?: boolean;
};

export type EMSTMSSourceDescriptor = AbstractSourceDescriptor & {
Expand Down Expand Up @@ -71,16 +72,15 @@ export type ESTermSourceDescriptor = AbstractESAggSourceDescriptor & {
term: string; // term field name
};

export type KibanaRegionmapSourceDescriptor = {
type: string;
export type KibanaRegionmapSourceDescriptor = AbstractSourceDescriptor & {
name: string;
};

export type KibanaTilemapSourceDescriptor = {
export type KibanaTilemapSourceDescriptor = AbstractSourceDescriptor & {
type: string;
thomasneirynck marked this conversation as resolved.
Show resolved Hide resolved
};

export type WMSSourceDescriptor = {
export type WMSSourceDescriptor = AbstractSourceDescriptor & {
type: string;
thomasneirynck marked this conversation as resolved.
Show resolved Hide resolved
serviceUrl: string;
layers: string;
Expand All @@ -99,6 +99,8 @@ export type JoinDescriptor = {
right: ESTermSourceDescriptor;
};

// todo : this union type is incompatible with dynamic extensibility of sources.
// Reconsider using SourceDescriptor in type signatures for top-level classes
export type SourceDescriptor =
| XYZTMSSourceDescriptor
| WMSSourceDescriptor
Expand All @@ -107,20 +109,28 @@ export type SourceDescriptor =
| ESTermSourceDescriptor
| ESSearchSourceDescriptor
| ESGeoGridSourceDescriptor
| EMSTMSSourceDescriptor
| EMSFileSourceDescriptor;

export type Query = {
thomasneirynck marked this conversation as resolved.
Show resolved Hide resolved
query?: string;
thomasneirynck marked this conversation as resolved.
Show resolved Hide resolved
language?: string;
};

export type LayerDescriptor = {
__dataRequests?: DataRequestDescriptor[];
__isInErrorState?: boolean;
__errorMessage?: string;
alpha?: number;
id: string;
label?: string;
label?: string | null;
minZoom?: number;
maxZoom?: number;
sourceDescriptor: SourceDescriptor;
sourceDescriptor: SourceDescriptor | null;
type?: string;
visible?: boolean;
style?: StyleDescriptor | null;
query?: Query;
};

export type VectorLayerDescriptor = LayerDescriptor & {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,11 @@ export type VectorStylePropertiesDescriptor = {
[VECTOR_STYLES.LABEL_BORDER_SIZE]?: LabelBorderSizeStylePropertyDescriptor;
};

export type VectorStyleDescriptor = {
export type StyleDescriptor = {
type: string;
};

export type VectorStyleDescriptor = StyleDescriptor & {
nreese marked this conversation as resolved.
Show resolved Hide resolved
type: LAYER_STYLE_TYPE.VECTOR;
properties: VectorStylePropertiesDescriptor;
};
Expand Down
12 changes: 7 additions & 5 deletions x-pack/plugins/maps/public/layers/blended_vector_layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ import {
DynamicStylePropertyOptions,
VectorLayerDescriptor,
} from '../../common/descriptor_types';
import { IStyle } from './styles/abstract_style';
import { IVectorSource } from './sources/vector_source';

const ACTIVE_COUNT_DATA_ID = 'ACTIVE_COUNT_DATA_ID';

Expand Down Expand Up @@ -167,7 +169,7 @@ export class BlendedVectorLayer extends VectorLayer implements IVectorLayer {
super(options);

this._documentSource = this._source as IESSource; // VectorLayer constructor sets _source as document source
this._documentStyle = this._style; // VectorLayer constructor sets _style as document source
this._documentStyle = this._style as IVectorStyle; // VectorLayer constructor sets _style as document source

this._clusterSource = getClusterSource(this._documentSource, this._documentStyle);
const clusterStyleDescriptor = getClusterStyleDescriptor(
Expand Down Expand Up @@ -229,11 +231,11 @@ export class BlendedVectorLayer extends VectorLayer implements IVectorLayer {
return this._documentSource;
}

getCurrentStyle() {
getCurrentStyle(): IStyle {
return this._isClustered ? this._clusterStyle : this._documentStyle;
}

getStyleForEditing() {
getStyleForEditing(): IStyle {
return this._documentStyle;
}

Expand All @@ -242,8 +244,8 @@ export class BlendedVectorLayer extends VectorLayer implements IVectorLayer {
const requestToken = Symbol(`layer-active-count:${this.getId()}`);
const searchFilters = this._getSearchFilters(
syncContext.dataFilters,
this.getSource(),
this.getCurrentStyle()
this.getSource() as IVectorSource,
this.getCurrentStyle() as IVectorStyle
);
const canSkipFetch = await canSkipSourceUpdate({
source: this.getSource(),
Expand Down
38 changes: 0 additions & 38 deletions x-pack/plugins/maps/public/layers/layer.d.ts

This file was deleted.

Loading