diff --git a/x-pack/plugins/synthetics/public/legacy_uptime/components/monitor_management/action_bar/action_bar.tsx b/x-pack/plugins/synthetics/public/legacy_uptime/components/monitor_management/action_bar/action_bar.tsx index 0cae34a05e35b..6823206dc4b8c 100644 --- a/x-pack/plugins/synthetics/public/legacy_uptime/components/monitor_management/action_bar/action_bar.tsx +++ b/x-pack/plugins/synthetics/public/legacy_uptime/components/monitor_management/action_bar/action_bar.tsx @@ -14,6 +14,7 @@ import { EuiButtonEmpty, EuiText, EuiPopover, + EuiOutsideClickDetector, } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; @@ -71,8 +72,10 @@ export const ActionBar = ({ const mouseMoveTimeoutIds = useRef<[number, number]>([0, 0]); const isReadOnly = monitor[ConfigKey.MONITOR_SOURCE_TYPE] === SourceType.PROJECT; - const hasServiceManagedLocation = monitor.locations?.some((loc) => loc.isServiceManaged); - const isOnlyPrivateLocations = !locations.some((loc) => loc.isServiceManaged); + const isAnyPublicLocationSelected = monitor.locations?.some((loc) => loc.isServiceManaged); + const isOnlyPrivateLocations = + !locations.some((loc) => loc.isServiceManaged) || + ((monitor.locations?.length ?? 0) > 0 && !isAnyPublicLocationSelected); const { data, status } = useFetcher(() => { if (!isSaving || !isValid) { @@ -150,55 +153,61 @@ export const ActionBar = ({ {onTestNow && ( {/* Popover is used instead of EuiTooltip until the resolution of https://github.com/elastic/eui/issues/5604 */} - onTestNow()} - onMouseOver={() => { - // We need this custom logic to display a popover even when button is disabled. - clearTimeout(mouseMoveTimeoutIds.current[1]); - if (mouseMoveTimeoutIds.current[0] === 0) { - mouseMoveTimeoutIds.current[0] = setTimeout(() => { - clearTimeout(mouseMoveTimeoutIds.current[1]); - setIsPopoverOpen(true); - }, 250) as unknown as number; - } - }} - onMouseOut={() => { - // We need this custom logic to display a popover even when button is disabled. - clearTimeout(mouseMoveTimeoutIds.current[1]); - mouseMoveTimeoutIds.current[1] = setTimeout(() => { - clearTimeout(mouseMoveTimeoutIds.current[0]); - setIsPopoverOpen(false); - mouseMoveTimeoutIds.current = [0, 0]; - }, 100) as unknown as number; - }} - > - {testRun ? RE_RUN_TEST_LABEL : RUN_TEST_LABEL} - - } - isOpen={isPopoverOpen} + { + setIsPopoverOpen(false); + }} > - -

- {isTestRunInProgress - ? TEST_SCHEDULED_LABEL - : isOnlyPrivateLocations || (isValid && !hasServiceManagedLocation) - ? PRIVATE_AVAILABLE_LABEL - : TEST_NOW_DESCRIPTION} -

-
-
+ onTestNow()} + onMouseOver={() => { + // We need this custom logic to display a popover even when button is disabled. + clearTimeout(mouseMoveTimeoutIds.current[1]); + if (mouseMoveTimeoutIds.current[0] === 0) { + mouseMoveTimeoutIds.current[0] = setTimeout(() => { + clearTimeout(mouseMoveTimeoutIds.current[1]); + setIsPopoverOpen(true); + }, 250) as unknown as number; + } + }} + onMouseOut={() => { + // We need this custom logic to display a popover even when button is disabled. + clearTimeout(mouseMoveTimeoutIds.current[1]); + mouseMoveTimeoutIds.current[1] = setTimeout(() => { + clearTimeout(mouseMoveTimeoutIds.current[0]); + setIsPopoverOpen(false); + mouseMoveTimeoutIds.current = [0, 0]; + }, 100) as unknown as number; + }} + > + {testRun ? RE_RUN_TEST_LABEL : RUN_TEST_LABEL} + + } + isOpen={isPopoverOpen} + > + +

+ {isTestRunInProgress + ? TEST_SCHEDULED_LABEL + : isOnlyPrivateLocations || (isValid && !isAnyPublicLocationSelected) + ? PRIVATE_AVAILABLE_LABEL + : TEST_NOW_DESCRIPTION} +

+
+
+
)} diff --git a/x-pack/plugins/synthetics/public/legacy_uptime/components/overview/monitor_list/columns/test_now_col.tsx b/x-pack/plugins/synthetics/public/legacy_uptime/components/overview/monitor_list/columns/test_now_col.tsx index 17e8047ac64c7..390994646d08a 100644 --- a/x-pack/plugins/synthetics/public/legacy_uptime/components/overview/monitor_list/columns/test_now_col.tsx +++ b/x-pack/plugins/synthetics/public/legacy_uptime/components/overview/monitor_list/columns/test_now_col.tsx @@ -5,8 +5,8 @@ * 2.0. */ +import React, { useMemo } from 'react'; import { EuiButtonIcon, EuiLoadingSpinner, EuiToolTip } from '@elastic/eui'; -import React from 'react'; import { useDispatch, useSelector } from 'react-redux'; import { Ping } from '../../../../../../common/runtime_types'; import { testNowMonitorAction } from '../../../../state/actions'; @@ -16,17 +16,21 @@ import * as labels from '../translations'; export const TestNowColumn = ({ monitorId, configId, - selectedMonitor, + summaryPings, }: { monitorId: string; configId?: string; - selectedMonitor: Ping; + summaryPings: Ping[]; }) => { const dispatch = useDispatch(); const testNowRun = useSelector(testNowRunSelector(configId)); - if (selectedMonitor.monitor.fleet_managed) { + const isOnFleetManaged = useMemo(() => { + return summaryPings.every((ping) => !!ping.monitor.fleet_managed); + }, [summaryPings]); + + if (isOnFleetManaged) { return ( <>-- diff --git a/x-pack/plugins/synthetics/public/legacy_uptime/components/overview/monitor_list/monitor_list.tsx b/x-pack/plugins/synthetics/public/legacy_uptime/components/overview/monitor_list/monitor_list.tsx index 4ca114264feca..e0cc20d963a85 100644 --- a/x-pack/plugins/synthetics/public/legacy_uptime/components/overview/monitor_list/monitor_list.tsx +++ b/x-pack/plugins/synthetics/public/legacy_uptime/components/overview/monitor_list/monitor_list.tsx @@ -212,7 +212,7 @@ export const MonitorListComponent: ({ ), },