Skip to content

Commit

Permalink
Review feedback. Update delete resp code, add endpoint test, misc.
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Caldwell committed Jun 23, 2021
1 parent 3f2bcf0 commit e8e2018
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export interface TimesliceMaskConfig {
}

export const EXCLUDE_TOO_MANY_FEATURES_BOX = ['!=', ['get', KBN_TOO_MANY_FEATURES_PROPERTY], true];
const EXCLUDE_CENTROID_FEATURES = ['!=', ['get', KBN_IS_CENTROID_FEATURE], true];
export const EXCLUDE_CENTROID_FEATURES = ['!=', ['get', KBN_IS_CENTROID_FEATURE], true];

function getFilterExpression(
filters: unknown[],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,9 @@ export class DrawControl extends Component<Props> {
this.props.mbMap.getCanvas().style.cursor = 'crosshair';
this.props.mbMap.on('draw.modechange', this._onModeChange);
this.props.mbMap.on('draw.create', this._onDraw);
this.props.mbMap.on('click', this._onClick);
if (this.props.onClick) {
this.props.mbMap.on('click', this._onClick);
}
}

const { DRAW_LINE_STRING, DRAW_POLYGON, DRAW_POINT, SIMPLE_SELECT } = this._mbDrawControl.modes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import React, { Component } from 'react';
import {Map as MbMap, Point as MbPoint} from 'mapbox-gl';
import { Map as MbMap, Point as MbPoint } from 'mapbox-gl';
// @ts-expect-error
import MapboxDraw from '@mapbox/mapbox-gl-draw';
import { Feature, Geometry, Position } from 'geojson';
Expand All @@ -18,7 +18,10 @@ import { getToasts } from '../../../../kibana_services';
import { DrawControl } from '../';
import { DRAW_MODE, DRAW_SHAPE } from '../../../../../common';
import { ILayer } from '../../../../classes/layers/layer';
import {EXCLUDE_TOO_MANY_FEATURES_BOX} from "../../../../classes/util/mb_filter_expressions";
import {
EXCLUDE_CENTROID_FEATURES,
EXCLUDE_TOO_MANY_FEATURES_BOX,
} from '../../../../classes/util/mb_filter_expressions';

const geoJSONReader = new jsts.io.GeoJSONReader();

Expand Down Expand Up @@ -101,7 +104,7 @@ export class DrawFeatureControl extends Component<Props, {}> {
] as [MbPoint, MbPoint];
const selectedFeatures = this.props.mbMap.queryRenderedFeatures(mbBbox, {
layers: mbEditLayerIds,
filter: EXCLUDE_TOO_MANY_FEATURES_BOX,
filter: [EXCLUDE_TOO_MANY_FEATURES_BOX, EXCLUDE_CENTROID_FEATURES],
});
if (!selectedFeatures.length) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { getDrawMode } from '../../../../selectors/ui_selectors';

function mapStateToProps(state: MapStoreState): ReduxStateProps {
const editState = getEditState(state);
const editLayer = getLayerById(editState ? editState.layerId : null, state);
const editLayer = editState ? getLayerById(editState.layerId, state) : undefined;
return {
drawShape: editState ? editState.drawShape : undefined,
drawMode: getDrawMode(state),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export function initIndexingRoutes({
logger.error(error);
return response.custom({
body: error.message,
statusCode: 500,
statusCode: 404,
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/translations/translations/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -24333,4 +24333,4 @@
"xpack.watcher.watchEdit.thresholdWatchExpression.aggType.fieldIsRequiredValidationMessage": "フィールドを選択してください。",
"xpack.watcher.watcherDescription": "アラートの作成、管理、監視によりデータへの変更を検知します。"
}
}
}
2 changes: 1 addition & 1 deletion x-pack/plugins/translations/translations/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -24709,4 +24709,4 @@
"xpack.watcher.watchEdit.thresholdWatchExpression.aggType.fieldIsRequiredValidationMessage": "此字段必填。",
"xpack.watcher.watcherDescription": "通过创建、管理和监测警报来检测数据中的更改。"
}
}
}
12 changes: 11 additions & 1 deletion x-pack/test/api_integration/apis/maps/delete_feature.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,24 @@ export default function ({ getService }) {
.expect(200);
});

it('previously deleted document no longer exists in index', async () => {
await supertest
.delete(`/api/maps/feature/999`)
.set('kbn-xsrf', 'kibana')
.send({
index: 'geo_shapes',
})
.expect(404);
});

it('should fail if not a valid document', async () => {
await supertest
.delete(`/api/maps/feature/998`)
.set('kbn-xsrf', 'kibana')
.send({
index: 'geo_shapes',
})
.expect(500);
.expect(404);
});
});
}

0 comments on commit e8e2018

Please sign in to comment.