[Vis Editor] Fix issue with parent pipeline agg (#48756)
* Add error when there is no histogram agg when using parent pipeline * Update error message * Update message * Get rid of let
This commit is contained in:
parent
f8ef2c6a34
commit
17383b82f3
1 changed files with 17 additions and 1 deletions
|
@ -26,7 +26,9 @@ import {
|
||||||
EuiDraggable,
|
EuiDraggable,
|
||||||
EuiSpacer,
|
EuiSpacer,
|
||||||
EuiPanel,
|
EuiPanel,
|
||||||
|
EuiFormErrorText,
|
||||||
} from '@elastic/eui';
|
} from '@elastic/eui';
|
||||||
|
import { i18n } from '@kbn/i18n';
|
||||||
|
|
||||||
import { AggConfig } from '../../../../agg_types/agg_config';
|
import { AggConfig } from '../../../../agg_types/agg_config';
|
||||||
import { aggGroupNamesMap, AggGroupNames } from '../agg_groups';
|
import { aggGroupNamesMap, AggGroupNames } from '../agg_groups';
|
||||||
|
@ -80,7 +82,15 @@ function DefaultEditorAggGroup({
|
||||||
|
|
||||||
const [aggsState, setAggsState] = useReducer(aggGroupReducer, group, initAggsState);
|
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 isAllAggsTouched = isInvalidAggsTouched(aggsState);
|
||||||
const isMetricAggregationDisabled = useMemo(
|
const isMetricAggregationDisabled = useMemo(
|
||||||
() => groupName === AggGroupNames.Metrics && getEnabledMetricAggsCount(group) === 1,
|
() => groupName === AggGroupNames.Metrics && getEnabledMetricAggsCount(group) === 1,
|
||||||
|
@ -144,6 +154,12 @@ function DefaultEditorAggGroup({
|
||||||
<h3>{groupNameLabel}</h3>
|
<h3>{groupNameLabel}</h3>
|
||||||
</EuiTitle>
|
</EuiTitle>
|
||||||
<EuiSpacer size="s" />
|
<EuiSpacer size="s" />
|
||||||
|
{bucketsError && (
|
||||||
|
<>
|
||||||
|
<EuiFormErrorText>{bucketsError}</EuiFormErrorText>
|
||||||
|
<EuiSpacer size="s" />
|
||||||
|
</>
|
||||||
|
)}
|
||||||
<EuiDroppable droppableId={`agg_group_dnd_${groupName}`}>
|
<EuiDroppable droppableId={`agg_group_dnd_${groupName}`}>
|
||||||
<>
|
<>
|
||||||
{group.map((agg: AggConfig, index: number) => (
|
{group.map((agg: AggConfig, index: number) => (
|
||||||
|
|
Loading…
Reference in a new issue