[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
|
@ -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';
|
||||
|
@ -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,
|
||||
|
@ -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) => (
|
||||
|
|
Loading…
Reference in a new issue