diff --git a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_alert_types/threshold/expression.tsx b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_alert_types/threshold/expression.tsx index 46eba14593b1d..af8d60e724f0b 100644 --- a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_alert_types/threshold/expression.tsx +++ b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_alert_types/threshold/expression.tsx @@ -259,8 +259,6 @@ export const IndexThresholdAlertTypeExpression: React.FunctionComponent { @@ -374,8 +371,7 @@ export const IndexThresholdAlertTypeExpression: React.FunctionComponent setAlertParams('aggType', selectedAggType) } @@ -412,9 +408,8 @@ export const IndexThresholdAlertTypeExpression: React.FunctionComponent setAlertParams('threshold', selectedThresholds) diff --git a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/common/expression_items/for_the_last.test.tsx b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/common/expression_items/for_the_last.test.tsx index 6097cdf1035dd..6ae3056001c8f 100644 --- a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/common/expression_items/for_the_last.test.tsx +++ b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/common/expression_items/for_the_last.test.tsx @@ -42,9 +42,8 @@ describe('for the last expression', () => { wrapper.contains( ) diff --git a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/common/expression_items/for_the_last.tsx b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/common/expression_items/for_the_last.tsx index e395af5b21172..844551de3171d 100644 --- a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/common/expression_items/for_the_last.tsx +++ b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/common/expression_items/for_the_last.tsx @@ -27,6 +27,19 @@ interface ForLastExpressionProps { errors: { [key: string]: string[] }; onChangeWindowSize: (selectedWindowSize: number | '') => void; onChangeWindowUnit: (selectedWindowUnit: string) => void; + popupPosition?: + | 'upCenter' + | 'upLeft' + | 'upRight' + | 'downCenter' + | 'downLeft' + | 'downRight' + | 'leftCenter' + | 'leftUp' + | 'leftDown' + | 'rightCenter' + | 'rightUp' + | 'rightDown'; } export const ForLastExpression = ({ @@ -35,16 +48,16 @@ export const ForLastExpression = ({ errors, onChangeWindowSize, onChangeWindowUnit, + popupPosition, }: ForLastExpressionProps) => { const [alertDurationPopoverOpen, setAlertDurationPopoverOpen] = useState(false); return (
diff --git a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/common/expression_items/group_by_over.test.tsx b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/common/expression_items/group_by_over.test.tsx index cc3f037f2ee7b..39cca005d5176 100644 --- a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/common/expression_items/group_by_over.test.tsx +++ b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/common/expression_items/group_by_over.test.tsx @@ -63,6 +63,7 @@ describe('group by expression', () => { { }, ] } - value="" /> `); }); diff --git a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/common/expression_items/group_by_over.tsx b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/common/expression_items/group_by_over.tsx index f8e236a714c86..01e454187d398 100644 --- a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/common/expression_items/group_by_over.tsx +++ b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/common/expression_items/group_by_over.tsx @@ -31,6 +31,19 @@ interface GroupByExpressionProps { customGroupByTypes?: { [key: string]: GroupByType; }; + popupPosition?: + | 'upCenter' + | 'upLeft' + | 'upRight' + | 'downCenter' + | 'downLeft' + | 'downRight' + | 'leftCenter' + | 'leftUp' + | 'leftDown' + | 'rightCenter' + | 'rightUp' + | 'rightDown'; } export const GroupByExpression = ({ @@ -43,30 +56,39 @@ export const GroupByExpression = ({ termSize, termField, customGroupByTypes, + popupPosition, }: GroupByExpressionProps) => { const groupByTypes = customGroupByTypes ?? builtInGroupByTypes; const [groupByPopoverOpen, setGroupByPopoverOpen] = useState(false); const MIN_TERM_SIZE = 1; const firstFieldOption = { - text: i18n.translate('xpack.triggersActionsUI.common.groupByType.timeFieldOptionLabel', { - defaultMessage: 'Select a field', - }), + text: i18n.translate( + 'xpack.triggersActionsUI.common.expressionItems.groupByType.timeFieldOptionLabel', + { + defaultMessage: 'Select a field', + } + ), value: '', }; return (
- {i18n.translate('xpack.triggersActionsUI.common.groupByType.overButtonLabel', { - defaultMessage: 'over', - })} + {i18n.translate( + 'xpack.triggersActionsUI.common.expressionItems.groupByType.overButtonLabel', + { + defaultMessage: 'over', + } + )} diff --git a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/common/expression_items/of.test.tsx b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/common/expression_items/of.test.tsx index 25a47e6222647..2e674f4fb47b1 100644 --- a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/common/expression_items/of.test.tsx +++ b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/common/expression_items/of.test.tsx @@ -25,9 +25,10 @@ describe('of expression', () => { { { const [aggFieldPopoverOpen, setAggFieldPopoverOpen] = useState(false); const firstFieldOption = { @@ -63,9 +77,12 @@ export const OfExpression = ({ id="aggFieldPopover" button={ { @@ -78,40 +95,43 @@ export const OfExpression = ({ closePopover={() => { setAggFieldPopoverOpen(false); }} - ownFocus withTitle - anchorPosition="upRight" + anchorPosition={popupPosition ?? 'downRight'} + zIndex={8000} > - - {i18n.translate('xpack.triggersActionsUI.common.of.ofButtonLabel', { - defaultMessage: 'of', - })} - - - - 0 && aggField !== undefined} - error={errors.aggField} - > - + + {i18n.translate('xpack.triggersActionsUI.common.expressionItems.of.popoverTitle', { + defaultMessage: 'of', + })} + + + + 0 && aggField !== undefined} - placeholder={firstFieldOption.text} - options={availablefieldsOptions} - selectedOptions={aggField ? [{ label: aggField }] : []} - onChange={selectedOptions => { - onChangeSelectedAggField( - selectedOptions.length === 1 ? selectedOptions[0].label : undefined - ); - setAggFieldPopoverOpen(false); - }} - /> - - - + error={errors.aggField} + > + 0 && aggField !== undefined} + placeholder={firstFieldOption.text} + options={availablefieldsOptions} + noSuggestions={!availablefieldsOptions.length} + selectedOptions={aggField ? [{ label: aggField }] : []} + onChange={selectedOptions => { + onChangeSelectedAggField( + selectedOptions.length === 1 ? selectedOptions[0].label : undefined + ); + setAggFieldPopoverOpen(false); + }} + /> + + + +
); }; diff --git a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/common/expression_items/threshold.tsx b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/common/expression_items/threshold.tsx index f8de29ac46a70..ecbf0aee63e2d 100644 --- a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/common/expression_items/threshold.tsx +++ b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/common/expression_items/threshold.tsx @@ -22,7 +22,6 @@ import { Comparator } from '../types'; interface ThresholdExpressionProps { thresholdComparator: string; - defaultThresholdComparator: string; errors: { [key: string]: string[] }; onChangeSelectedThresholdComparator: (selectedThresholdComparator?: string) => void; onChangeSelectedThreshold: (selectedThreshold?: number[]) => void; @@ -30,22 +29,35 @@ interface ThresholdExpressionProps { [key: string]: Comparator; }; threshold?: number[]; + popupPosition?: + | 'upCenter' + | 'upLeft' + | 'upRight' + | 'downCenter' + | 'downLeft' + | 'downRight' + | 'leftCenter' + | 'leftUp' + | 'leftDown' + | 'rightCenter' + | 'rightUp' + | 'rightDown'; } export const ThresholdExpression = ({ thresholdComparator, - defaultThresholdComparator, errors, onChangeSelectedThresholdComparator, onChangeSelectedThreshold, customComparators, threshold = [], + popupPosition, }: ThresholdExpressionProps) => { const comparators = customComparators ?? builtInComparators; const [alertThresholdPopoverOpen, setAlertThresholdPopoverOpen] = useState(false); const andThresholdText = i18n.translate( - 'xpack.triggersActionsUI.sections.alertAdd.threshold.andLabel', + 'xpack.triggersActionsUI.common.expressionItems.threshold.andLabel', { defaultMessage: 'AND', } @@ -53,13 +65,12 @@ export const ThresholdExpression = ({ return (
- - {comparators[thresholdComparator || defaultThresholdComparator].text} - + {comparators[thresholdComparator].text} - {Array.from( - Array(comparators[thresholdComparator || defaultThresholdComparator].requiredValues) - ).map((_notUsed, i) => { + {Array.from(Array(comparators[thresholdComparator].requiredValues)).map((_notUsed, i) => { return ( {i > 0 ? ( - + {andThresholdText} ) : null} diff --git a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/common/expression_items/when.test.tsx b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/common/expression_items/when.test.tsx index 31a2adc685a0b..02b6bf24977c9 100644 --- a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/common/expression_items/when.test.tsx +++ b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/common/expression_items/when.test.tsx @@ -12,11 +12,7 @@ describe('when expression', () => { it('renders with builtin aggregation types', () => { const onChangeSelectedAggType = jest.fn(); const wrapper = shallow( - + ); expect(wrapper.find('[data-test-subj="whenExpressionSelect"]')).toMatchInlineSnapshot(` { const wrapper = shallow( { `); }); - it('renders with default aggreagation type preselected if no aggType was set', () => { + it('renders when popover title', () => { const onChangeSelectedAggType = jest.fn(); const wrapper = shallow( - + ); wrapper.simulate('click'); expect(wrapper.find('[value="avg"]').length > 0).toBeTruthy(); diff --git a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/common/expression_items/when.tsx b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/common/expression_items/when.tsx index 932b940f2c6dd..b20040608ed9e 100644 --- a/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/common/expression_items/when.tsx +++ b/x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/common/expression_items/when.tsx @@ -11,37 +11,44 @@ import { builtInAggregationTypes } from '../constants'; import { AggregationType } from '../types'; interface WhenExpressionProps { - aggType?: string; - defaultAggType: string; + aggType: string; customAggTypesOptions?: { [key: string]: AggregationType }; onChangeSelectedAggType: (selectedAggType: string) => void; + popupPosition?: + | 'upCenter' + | 'upLeft' + | 'upRight' + | 'downCenter' + | 'downLeft' + | 'downRight' + | 'leftCenter' + | 'leftUp' + | 'leftDown' + | 'rightCenter' + | 'rightUp' + | 'rightDown'; } export const WhenExpression = ({ aggType, - defaultAggType, customAggTypesOptions, onChangeSelectedAggType, + popupPosition, }: WhenExpressionProps) => { const [aggTypePopoverOpen, setAggTypePopoverOpen] = useState(false); const aggregationTypes = customAggTypesOptions ?? builtInAggregationTypes; return ( { setAggTypePopoverOpen(true); @@ -54,17 +61,17 @@ export const WhenExpression = ({ }} ownFocus withTitle - anchorPosition="downLeft" + anchorPosition={popupPosition ?? 'downLeft'} >
- {i18n.translate('xpack.triggersActionsUI.sections.alertAdd.threshold.whenButtonLabel', { + {i18n.translate('xpack.triggersActionsUI.common.expressionItems.threshold.popoverTitle', { defaultMessage: 'when', })} { onChangeSelectedAggType(e.target.value);