Skip to content

Commit

Permalink
tslint
Browse files Browse the repository at this point in the history
  • Loading branch information
nreese committed Jun 23, 2020
1 parent 8b7afb5 commit abcb459
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { i18n } from '@kbn/i18n';
import { LAYER_WIZARD_CATEGORY } from '../../../../common/constants';
import { LayerWizard, RenderWizardArguments } from '../layer_wizard_registry';
import { LayerTemplate } from './layer_template';
import { getIndexPatternService } from '../../../kibana_services';

export const choroplethLayerWizardConfig: LayerWizard = {
categories: [LAYER_WIZARD_CATEGORY.ELASTICSEARCH],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,17 @@ import {
STYLE_TYPE,
VECTOR_STYLES,
} from '../../../../common/constants';
import { getJoinAggKey, getSourceAggKey } from '../../../../common/get_agg_key';
import { getJoinAggKey } from '../../../../common/get_agg_key';
import {
AggDescriptor,
ColorDynamicOptions,
EMSFileSourceDescriptor,
ESSearchSourceDescriptor,
JoinDescriptor,
} from '../../../../common/descriptor_types';
import { VectorStyle } from '../../styles/vector/vector_style';
import { VectorLayer } from '../vector_layer/vector_layer';
import { EMSFileSource } from '../../sources/ems_file_source';
// @ts-ignore
import { ESSearchSource } from '../../sources/es_search_source';
import { getDefaultDynamicProperties } from '../../styles/vector/vector_style_defaults';

Expand All @@ -42,7 +43,7 @@ function createChoroplethLayerDescriptor({
rightIndexPatternTitle: string;
rightTermField: string;
}) {
const metricsDescriptor = { type: AGG_TYPE.COUNT };
const metricsDescriptor: AggDescriptor = { type: AGG_TYPE.COUNT };
const joinId = uuid();
const joinKey = getJoinAggKey({
aggType: metricsDescriptor.type,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import React, { Component, Fragment } from 'react';
import React, { Component } from 'react';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
import { FileLayer } from '@elastic/ems-client';
Expand All @@ -18,7 +18,7 @@ import {
EuiTitle,
} from '@elastic/eui';
import { IFieldType, IndexPattern } from 'src/plugins/data/public';
import { RenderWizardArguments } from '../../layer_wizard_registry';
import { RenderWizardArguments } from '../layer_wizard_registry';
import { EMSFileSelect } from '../../../components/ems_file_select';
import { GeoIndexPatternSelect } from '../../../components/geo_index_pattern_select';
import { SingleFieldSelect } from '../../../components/single_field_select';
Expand Down Expand Up @@ -91,7 +91,7 @@ export class LayerTemplate extends Component<RenderWizardArguments, State> {
this._isMounted = true;
}

_loadRightFields = async (indexPatternId) => {
_loadRightFields = async (indexPatternId: string) => {
this.setState({ rightTermsFields: [], rightIndexPatternTitle: null });

let indexPattern;
Expand Down Expand Up @@ -140,7 +140,7 @@ export class LayerTemplate extends Component<RenderWizardArguments, State> {

_onLeftSourceChange = (optionId: string) => {
this.setState(
{ leftSource: optionId, leftJoinField: null, rightJoinField: null },
{ leftSource: optionId as BOUNDARIES_SOURCE, leftJoinField: null, rightJoinField: null },
this._previewLayer
);
};
Expand All @@ -158,17 +158,24 @@ export class LayerTemplate extends Component<RenderWizardArguments, State> {
() => {
// make default geo field selection
if (this.state.leftGeoFields.length) {
// @ts-expect-error - avoid wrong "Property 'name' does not exist on type 'never'." compile error
this._onLeftGeoFieldSelect(this.state.leftGeoFields[0].name);
}
}
);
};

_onLeftGeoFieldSelect = (geoField: string) => {
_onLeftGeoFieldSelect = (geoField?: string) => {
if (!geoField) {
return;
}
this.setState({ leftGeoField: geoField }, this._previewLayer);
};

_onLeftJoinFieldSelect = (joinField: string) => {
_onLeftJoinFieldSelect = (joinField?: string) => {
if (!joinField) {
return;
}
this.setState({ leftJoinField: joinField }, this._previewLayer);
};

Expand All @@ -184,7 +191,7 @@ export class LayerTemplate extends Component<RenderWizardArguments, State> {
return;
}

this.setState({ leftJoinField: selectedOptions[0].value }, this._previewLayer);
this.setState({ leftJoinField: selectedOptions[0].value! }, this._previewLayer);
};

_onRightIndexPatternChange = (indexPatternId: string) => {
Expand All @@ -204,7 +211,10 @@ export class LayerTemplate extends Component<RenderWizardArguments, State> {
);
};

_onRightJoinFieldSelect = (joinField: string) => {
_onRightJoinFieldSelect = (joinField?: string) => {
if (!joinField) {
return;
}
this.setState({ rightJoinField: joinField }, this._previewLayer);
};

Expand All @@ -231,19 +241,20 @@ export class LayerTemplate extends Component<RenderWizardArguments, State> {
const layerDescriptor =
this.state.leftSource === BOUNDARIES_SOURCE.ELASTICSEARCH
? createEsChoroplethLayerDescriptor({
leftIndexPatternId: this.state.leftIndexPattern.id,
leftGeoField: this.state.leftGeoField,
leftJoinField: this.state.leftJoinField,
rightIndexPatternId: this.state.rightIndexPatternId,
rightIndexPatternTitle: this.state.rightIndexPatternTitle,
rightTermField: this.state.rightJoinField,
// @ts-expect-error - avoid wrong "Property 'id' does not exist on type 'never'." compile error
leftIndexPatternId: this.state.leftIndexPattern!.id,
leftGeoField: this.state.leftGeoField!,
leftJoinField: this.state.leftJoinField!,
rightIndexPatternId: this.state.rightIndexPatternId!,
rightIndexPatternTitle: this.state.rightIndexPatternTitle!,
rightTermField: this.state.rightJoinField!,
})
: createEmsChoroplethLayerDescriptor({
leftEmsFileId: this.state.leftEmsFileId,
leftEmsField: this.state.leftJoinField,
rightIndexPatternId: this.state.rightIndexPatternId,
rightIndexPatternTitle: this.state.rightIndexPatternTitle,
rightTermField: this.state.rightJoinField,
leftEmsFileId: this.state.leftEmsFileId!,
leftEmsField: this.state.leftJoinField!,
rightIndexPatternId: this.state.rightIndexPatternId!,
rightIndexPatternTitle: this.state.rightIndexPatternTitle!,
rightTermField: this.state.rightJoinField!,
});

this.props.previewLayers([layerDescriptor]);
Expand Down Expand Up @@ -294,7 +305,8 @@ export class LayerTemplate extends Component<RenderWizardArguments, State> {
return (
<>
<GeoIndexPatternSelect
value={this.state.leftIndexPattern ? this.state.leftIndexPattern.id : ''}
// @ts-expect-error - avoid wrong "Property 'id' does not exist on type 'never'." compile error
value={this.state.leftIndexPattern ? this.state.leftIndexPattern!.id : ''}
onChange={this._onLeftIndexPatternChange}
/>
{geoFieldSelect}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,7 @@
*/

import React, { Component } from 'react';
import { EuiComboBox, EuiComboBoxOptionOption, EuiFormRow, EuiPanel } from '@elastic/eui';

import { i18n } from '@kbn/i18n';
import { FileLayer } from '@elastic/ems-client';
import { getEmsFileLayers } from '../../../meta';
import { getEmsUnavailableMessage } from '../ems_unavailable_message';
import { EuiPanel } from '@elastic/eui';
import { EMSFileSourceDescriptor } from '../../../../common/descriptor_types';
import { EMSFileSelect } from '../../../components/ems_file_select';

Expand All @@ -28,6 +23,7 @@ export class EMSFileCreateSourceEditor extends Component<Props, State> {
};

_onChange = (emsFileId: string) => {
this.setState({ emsFileId });
this.props.onSourceConfigChange({ id: emsFileId });
};

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const defaultProps = {
scalingType: SCALING_TYPES.LIMIT,
supportsClustering: true,
termFields: [],
topHitsSplitField: null,
topHitsSize: 1,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ interface Props {
supportsClustering: boolean;
clusteringDisabledReason?: string | null;
termFields: IFieldType[];
topHitsSplitField?: string;
topHitsSplitField: string | null;
topHitsSize: number;
}

Expand Down Expand Up @@ -90,6 +90,9 @@ export class ScalingForm extends Component<Props, State> {
};

_onTopHitsSplitFieldChange = (topHitsSplitField?: string) => {
if (!topHitsSplitField) {
return;
}
this.props.onChange({ propName: 'topHitsSplitField', value: topHitsSplitField });
};

Expand Down Expand Up @@ -141,6 +144,7 @@ export class ScalingForm extends Component<Props, State> {
value={this.props.topHitsSplitField}
onChange={this._onTopHitsSplitFieldChange}
fields={this.props.termFields}
isClearable={false}
compressed
/>
</EuiFormRow>
Expand Down
5 changes: 2 additions & 3 deletions x-pack/plugins/maps/public/components/ems_file_select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ import { i18n } from '@kbn/i18n';
import { FileLayer } from '@elastic/ems-client';
import { getEmsFileLayers } from '../meta';
import { getEmsUnavailableMessage } from './ems_unavailable_message';
import { EMSFileSourceDescriptor } from '../../common/descriptor_types';

interface Props {
onChange: (emsFileId: string) => void;
value: string;
value: string | null;
}

interface State {
Expand Down Expand Up @@ -61,7 +60,7 @@ export class EMSFileSelect extends Component<Props, State> {
return;
}

this.props.onChange(selectedOptions[0].value);
this.props.onChange(selectedOptions[0].value!);
};

_renderSelect() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ interface Props {
}

interface State {
noGeoIndexPatternsExist: Array<EuiComboBoxOptionOption<string>>;
noGeoIndexPatternsExist: boolean;
}

export class GeoIndexPatternSelect extends Component<Props, State> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ type Props = Omit<
> & {
fields?: IFieldType[];
onChange: (fieldName?: string) => void;
value?: string; // index pattern field name
value: string | null; // index pattern field name
isFieldDisabled?: (field: IFieldType) => boolean;
getFieldDisabledReason?: (field: IFieldType) => string | null;
};
Expand Down

0 comments on commit abcb459

Please sign in to comment.