Skip to content

Commit

Permalink
Fixed merge issues
Browse files Browse the repository at this point in the history
  • Loading branch information
YulNaumenko committed Feb 4, 2020
1 parent a110f9e commit db7678b
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ import {
EuiFormRow,
EuiCallOut,
} from '@elastic/eui';
import { AlertTypeModel, ValidationResult } from '../../../../types';
import { COMPARATORS, buildinGroupByTypes, buildinComparators } from '../../../../common/constants';
import { COMPARATORS, buildinComparators } from '../../../../common/constants';
import {
getMatchingIndicesForThresholdAlertType,
getThresholdAlertTypeFields,
Expand All @@ -37,7 +36,7 @@ import {
ForLastExpression,
GroupByExpression,
} from '../../../../common';
import { buildInAggregationTypes } from '../../../../common/constants';
import { buildinAggregationTypes } from '../../../../common/constants';
import { IndexThresholdAlertParams } from '../types';

const DEFAULT_VALUES = {
Expand Down Expand Up @@ -113,7 +112,7 @@ export const IndexThresholdAlertTypeExpression: React.FunctionComponent<IndexThr
errorKey =>
expressionFieldsWithValidation.includes(errorKey) &&
errors[errorKey].length >= 1 &&
alert.params[errorKey] !== undefined
(alertParams as { [key: string]: any })[errorKey] !== undefined
);

const canShowVizualization = !!Object.keys(errors).find(
Expand Down Expand Up @@ -382,7 +381,7 @@ export const IndexThresholdAlertTypeExpression: React.FunctionComponent<IndexThr
}
/>
</EuiFlexItem>
{aggType && buildInAggregationTypes[aggType].fieldRequired ? (
{aggType && buildinAggregationTypes[aggType].fieldRequired ? (
<EuiFlexItem grow={false}>
<OfExpression
aggField={aggField}
Expand Down Expand Up @@ -444,7 +443,7 @@ export const IndexThresholdAlertTypeExpression: React.FunctionComponent<IndexThr
<Fragment>
<ThresholdVisualization
alertParams={alertParams}
aggregationTypes={buildInAggregationTypes}
aggregationTypes={buildinAggregationTypes}
comparators={buildinComparators}
/>
</Fragment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@
* you may not use this file except in compliance with the Elastic License.
*/
import { i18n } from '@kbn/i18n';
import { Alert, AlertTypeModel, ValidationResult } from '../../../../types';
import { IndexThresholdAlertTypeExpression, aggregationTypes, groupByTypes } from './expression';
import { AlertTypeModel, ValidationResult } from '../../../../types';
import { IndexThresholdAlertTypeExpression } from './expression';
import { IndexThresholdAlertParams } from '../types';
import { buildinGroupByTypes, buildinAggregationTypes } from '../../../../common/constants';

export function getAlertType(): AlertTypeModel {
return {
id: 'threshold',
name: 'Index Threshold',
iconClass: 'alert',
alertParamsExpression: IndexThresholdAlertTypeExpression,
validate: (alert: Alert): ValidationResult => {
validate: (alertParams: IndexThresholdAlertParams): ValidationResult => {
const {
index,
timeField,
Expand All @@ -24,7 +26,7 @@ export function getAlertType(): AlertTypeModel {
termField,
threshold,
timeWindowSize,
} = alert.params;
} = alertParams;
const validationResult = { errors: {} };
const errors = {
aggField: new Array<string>(),
Expand All @@ -51,7 +53,7 @@ export function getAlertType(): AlertTypeModel {
})
);
}
if (aggType && aggregationTypes[aggType].fieldRequired && !aggField) {
if (aggType && buildinAggregationTypes[aggType].fieldRequired && !aggField) {
errors.aggField.push(
i18n.translate('xpack.triggersActionsUI.sections.addAlert.error.requiredAggFieldText', {
defaultMessage: 'Aggregation field is required.',
Expand All @@ -65,7 +67,7 @@ export function getAlertType(): AlertTypeModel {
})
);
}
if (groupBy && groupByTypes[groupBy].sizeRequired && !termField) {
if (groupBy && buildinGroupByTypes[groupBy].sizeRequired && !termField) {
errors.termField.push(
i18n.translate('xpack.triggersActionsUI.sections.addAlert.error.requiredtTermFieldText', {
defaultMessage: 'Term field is required.',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ import {
ActionConnector,
AlertTypeIndex,
} from '../../../types';
import { getTimeOptions } from '../../lib/get_time_options';
import { SectionLoading } from '../../components/section_loading';
import { ConnectorAddModal } from '../action_connector_form/connector_add_modal';
import { getTimeOptions } from '../../../common/lib/get_time_options';

export function validateBaseProperties(alertObject: Alert) {
const validationResult = { errors: {} };
Expand Down Expand Up @@ -609,7 +609,7 @@ export const AlertForm = ({
</EuiFlexGroup>
{AlertParamsExpressionComponent ? (
<AlertParamsExpressionComponent
alert={alert}
alertParams={alert.params}
errors={errors}
setAlertParams={setAlertParams}
setAlertProperty={setAlertProperty}
Expand Down Expand Up @@ -774,7 +774,7 @@ export const AlertForm = ({
fullWidth
compressed
value={alertIntervalUnit}
options={getTimeOptions((alertInterval ? alertInterval : 1).toString())}
options={getTimeOptions(alertInterval ?? 1)}
onChange={e => {
setAlertIntervalUnit(e.target.value);
setScheduleProperty('interval', `${alertInterval}${e.target.value}`);
Expand Down Expand Up @@ -806,7 +806,7 @@ export const AlertForm = ({
<EuiSelect
compressed
value={alertThrottleUnit}
options={getTimeOptions((alertThrottle ? alertThrottle : 1).toString())}
options={getTimeOptions(alertThrottle ?? 1)}
onChange={e => {
setAlertThrottleUnit(e.target.value);
setAlertProperty('throttle', `${alertThrottle}${e.target.value}`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export enum AGGREGATION_TYPES {
MAX = 'max',
}

export const buildInAggregationTypes: { [key: string]: AggregationType } = {
export const buildinAggregationTypes: { [key: string]: AggregationType } = {
count: {
text: 'count()',
fieldRequired: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
*/

export { COMPARATORS, buildinComparators } from './comparators';
export { AGGREGATION_TYPES, buildInAggregationTypes } from './aggregation_types';
export { AGGREGATION_TYPES, buildinAggregationTypes } from './aggregation_types';
export { buildinGroupByTypes } from './group_by_types';
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
EuiFormRow,
EuiComboBox,
} from '@elastic/eui';
import { buildInAggregationTypes } from '../constants';
import { buildinAggregationTypes } from '../constants';
import { AggregationType } from '../types';

interface OfExpressionProps {
Expand Down Expand Up @@ -47,7 +47,7 @@ export const OfExpression = ({
),
value: '',
};
const aggregationTypes = customAggTypesOptions ?? buildInAggregationTypes;
const aggregationTypes = customAggTypesOptions ?? buildinAggregationTypes;

const availablefieldsOptions = fields.reduce((esFieldOptions: any[], field: any) => {
if (aggregationTypes[aggType].validNormalizedTypes.includes(field.normalizedType)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import React, { useState } from 'react';
import { i18n } from '@kbn/i18n';
import { EuiExpression, EuiPopover, EuiPopoverTitle, EuiSelect } from '@elastic/eui';
import { buildInAggregationTypes } from '../constants';
import { buildinAggregationTypes } from '../constants';
import { AggregationType } from '../types';

interface WhenExpressionProps {
Expand All @@ -24,7 +24,7 @@ export const WhenExpression = ({
onChangeSelectedAggType,
}: WhenExpressionProps) => {
const [aggTypePopoverOpen, setAggTypePopoverOpen] = useState(false);
const aggregationTypes = customAggTypesOptions ?? buildInAggregationTypes;
const aggregationTypes = customAggTypesOptions ?? buildinAggregationTypes;
return (
<EuiPopover
id="aggTypePopover"
Expand Down

0 comments on commit db7678b

Please sign in to comment.