Skip to content

Commit

Permalink
[Vis Editor] Fix issue with parent pipeline agg (#48756)
Browse files Browse the repository at this point in the history
* Add error when there is no histogram agg when using parent pipeline

* Update error message

* Update message

* Get rid of let
  • Loading branch information
maryia-lapata committed Nov 6, 2019
1 parent f8ef2c6 commit 17383b8
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ import {
EuiDraggable,
EuiSpacer,
EuiPanel,
EuiFormErrorText,
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';

import { AggConfig } from '../../../../agg_types/agg_config';
import { aggGroupNamesMap, AggGroupNames } from '../agg_groups';
Expand Down Expand Up @@ -80,7 +82,15 @@ function DefaultEditorAggGroup({

const [aggsState, setAggsState] = useReducer(aggGroupReducer, group, initAggsState);

const isGroupValid = Object.values(aggsState).every(item => item.valid);
const bucketsError =
lastParentPipelineAggTitle && groupName === AggGroupNames.Buckets && !group.length
? i18n.translate('common.ui.aggTypes.buckets.mustHaveBucketErrorMessage', {
defaultMessage: 'Add a bucket with "Date Histogram" or "Histogram" aggregation.',
description: 'Date Histogram and Histogram should not be translated',
})
: undefined;

const isGroupValid = !bucketsError && Object.values(aggsState).every(item => item.valid);
const isAllAggsTouched = isInvalidAggsTouched(aggsState);
const isMetricAggregationDisabled = useMemo(
() => groupName === AggGroupNames.Metrics && getEnabledMetricAggsCount(group) === 1,
Expand Down Expand Up @@ -144,6 +154,12 @@ function DefaultEditorAggGroup({
<h3>{groupNameLabel}</h3>
</EuiTitle>
<EuiSpacer size="s" />
{bucketsError && (
<>
<EuiFormErrorText>{bucketsError}</EuiFormErrorText>
<EuiSpacer size="s" />
</>
)}
<EuiDroppable droppableId={`agg_group_dnd_${groupName}`}>
<>
{group.map((agg: AggConfig, index: number) => (
Expand Down

0 comments on commit 17383b8

Please sign in to comment.