Skip to content

Commit

Permalink
type check
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasneirynck committed Jan 28, 2021
1 parent 07ee85e commit 95f658d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ export type TableSourceDescriptor = {
__rows: TableSourceValue[][];
columns: TableSourceColumn[];
term: string;
// metrics: AggDescriptor[];
};

export type TermJoinSourceDescriptor = ESTermSourceDescriptor | TableSourceDescriptor;
11 changes: 9 additions & 2 deletions x-pack/plugins/maps/public/classes/layers/layer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ import {
MB_SOURCE_ID_LAYER_ID_PREFIX_DELIMITER,
MIN_ZOOM,
SOURCE_DATA_REQUEST_ID,
SOURCE_TYPES,
STYLE_TYPE,
} from '../../../common/constants';
import { copyPersistentState } from '../../reducers/util';
import {
AggDescriptor,
ESTermSourceDescriptor,
JoinDescriptor,
LayerDescriptor,
MapExtent,
Expand Down Expand Up @@ -158,6 +160,11 @@ export class AbstractLayer implements ILayer {

if (clonedDescriptor.joins) {
clonedDescriptor.joins.forEach((joinDescriptor: JoinDescriptor) => {
if (joinDescriptor.right && joinDescriptor.right.type === SOURCE_TYPES.TABLE_SOURCE) {
return;
}
const termSourceDescriptor: ESTermSourceDescriptor = joinDescriptor.right as ESTermSourceDescriptor;

// todo: must tie this to generic thing
const originalJoinId = joinDescriptor.right.id!;

Expand All @@ -167,8 +174,8 @@ export class AbstractLayer implements ILayer {
// Update all data driven styling properties using join fields
if (clonedDescriptor.style && 'properties' in clonedDescriptor.style) {
const metrics =
joinDescriptor.right.metrics && joinDescriptor.right.metrics.length
? joinDescriptor.right.metrics
termSourceDescriptor.metrics && termSourceDescriptor.metrics.length
? termSourceDescriptor.metrics
: [{ type: AGG_TYPE.COUNT }];
metrics.forEach((metricsDescriptor: AggDescriptor) => {
const originalJoinKey = getJoinAggKey({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/

import uuid from 'uuid';
import { GeoJsonProperties } from 'geojson';
import { FIELD_ORIGIN, SOURCE_TYPES, VECTOR_SHAPE_TYPE } from '../../../../common/constants';
import {
MapExtent,
Expand All @@ -17,13 +16,10 @@ import {
VectorSourceSyncMeta,
} from '../../../../common/descriptor_types';
import { Adapters } from '../../../../../../../src/plugins/inspector/common/adapters';
import { AbstractSource } from '../source';
import { ITermJoinSource } from '../term_join_source';
import { BucketProperties, PropertiesMap } from '../../../../common/elasticsearch_util';
import { IField } from '../../fields/field';
import { Query } from '../../../../../../../src/plugins/data/common/query';
import { ITooltipProperty } from '../../tooltips/tooltip_property';
import { IESAggField } from '../../fields/agg';
import {
AbstractVectorSource,
BoundsFilters,
Expand Down Expand Up @@ -75,7 +71,7 @@ export class TableSource extends AbstractVectorSource implements ITermJoinSource
for (let i = 0; i < this._descriptor.__rows.length; i++) {
const bucketProperties: BucketProperties = {};
const row: TableSourceValue[] = this._descriptor.__rows[i];
let propKey: string | number;
let propKey: string | number | undefined;
for (let j = 0; j < row.length; j++) {
if (row[j].key === this._descriptor.term) {
propKey = row[j].value;
Expand All @@ -84,7 +80,7 @@ export class TableSource extends AbstractVectorSource implements ITermJoinSource
}
}
if (propKey) {
propertiesMap.set(propKey, bucketProperties);
propertiesMap.set(propKey.toString(), bucketProperties);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,7 @@ import _ from 'lodash';
import { i18n } from '@kbn/i18n';
import { EmbeddableStateTransfer } from 'src/plugins/embeddable/public';
import { MapSavedObjectAttributes } from '../../../../common/map_saved_object_type';
import {
COLOR_MAP_TYPE,
FIELD_ORIGIN,
LABEL_BORDER_SIZES,
MAP_PATH,
MAP_SAVED_OBJECT_TYPE,
SOURCE_TYPES,
STYLE_TYPE,
SYMBOLIZE_AS_TYPES,
} from '../../../../common/constants';
import { MAP_PATH, MAP_SAVED_OBJECT_TYPE } from '../../../../common/constants';
import { createMapStore, MapStore, MapStoreState } from '../../../reducers/store';
import {
getTimeFilters,
Expand Down

0 comments on commit 95f658d

Please sign in to comment.