From d4a0b36b127602ab4bedf6f771b5b341c3949eca Mon Sep 17 00:00:00 2001 From: Shahzad Date: Thu, 6 Oct 2022 10:14:34 +0200 Subject: [PATCH] [Synthetics] Update layout for ping monitor (#142779) --- .../monitor_test_result/single_ping_result.tsx | 2 +- .../monitor_summary/monitor_details_panel.tsx | 2 +- .../monitor_summary/step_duration_panel.tsx | 15 ++++++++++++--- .../apps/synthetics/state/monitor_details/api.ts | 2 +- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/x-pack/plugins/synthetics/public/apps/synthetics/components/common/monitor_test_result/single_ping_result.tsx b/x-pack/plugins/synthetics/public/apps/synthetics/components/common/monitor_test_result/single_ping_result.tsx index 89fb255dc80ef..bb0666abbab26 100644 --- a/x-pack/plugins/synthetics/public/apps/synthetics/components/common/monitor_test_result/single_ping_result.tsx +++ b/x-pack/plugins/synthetics/public/apps/synthetics/components/common/monitor_test_result/single_ping_result.tsx @@ -24,7 +24,7 @@ export const SinglePingResult = ({ ping, loading }: { ping: Ping; loading: boole const responseStatus = !loading ? ping?.http?.response?.status_code : undefined; return ( - + IP {ip} {DURATION_LABEL} diff --git a/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/monitor_summary/monitor_details_panel.tsx b/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/monitor_summary/monitor_details_panel.tsx index 3d8013c79beff..2fd702a187e36 100644 --- a/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/monitor_summary/monitor_details_panel.tsx +++ b/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/monitor_summary/monitor_details_panel.tsx @@ -55,7 +55,7 @@ export const MonitorDetailsPanel = () => { return (
- + {ENABLED_LABEL} {monitor && ( diff --git a/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/monitor_summary/step_duration_panel.tsx b/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/monitor_summary/step_duration_panel.tsx index 671e661f4eb06..120449b88bd04 100644 --- a/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/monitor_summary/step_duration_panel.tsx +++ b/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/monitor_summary/step_duration_panel.tsx @@ -12,6 +12,7 @@ import { ReportTypes } from '@kbn/observability-plugin/public'; import { useParams } from 'react-router-dom'; import { i18n } from '@kbn/i18n'; +import { useSelectedMonitor } from '../hooks/use_selected_monitor'; import { ClientPluginsStart } from '../../../../../plugin'; export const StepDurationPanel = () => { const { observability } = useKibana().services; @@ -20,12 +21,16 @@ export const StepDurationPanel = () => { const { monitorId } = useParams<{ monitorId: string }>(); + const { monitor } = useSelectedMonitor(); + + const isBrowser = monitor?.type === 'browser'; + return ( -

{DURATION_BY_STEP_LABEL}

+

{isBrowser ? DURATION_BY_STEP_LABEL : DURATION_BY_LOCATION}

@@ -43,10 +48,10 @@ export const StepDurationPanel = () => { { name: DURATION_BY_STEP_LABEL, reportDefinitions: { 'monitor.id': [monitorId] }, - selectedMetricField: 'synthetics.step.duration.us', + selectedMetricField: isBrowser ? 'synthetics.step.duration.us' : 'monitor.duration.us', dataType: 'synthetics', time: { from: 'now-24h/h', to: 'now' }, - breakdown: 'synthetics.step.name.keyword', + breakdown: isBrowser ? 'synthetics.step.name.keyword' : 'observer.geo.name', operationType: 'last_value', seriesType: 'area_stacked', }, @@ -60,6 +65,10 @@ const DURATION_BY_STEP_LABEL = i18n.translate('xpack.synthetics.detailsPanel.dur defaultMessage: 'Duration by step', }); +const DURATION_BY_LOCATION = i18n.translate('xpack.synthetics.detailsPanel.durationByLocation', { + defaultMessage: 'Duration by location', +}); + const LAST_24H_LABEL = i18n.translate('xpack.synthetics.detailsPanel.last24Hours', { defaultMessage: 'Last 24 hours', }); diff --git a/x-pack/plugins/synthetics/public/apps/synthetics/state/monitor_details/api.ts b/x-pack/plugins/synthetics/public/apps/synthetics/state/monitor_details/api.ts index f2541b119e56d..80713e587cefa 100644 --- a/x-pack/plugins/synthetics/public/apps/synthetics/state/monitor_details/api.ts +++ b/x-pack/plugins/synthetics/public/apps/synthetics/state/monitor_details/api.ts @@ -51,8 +51,8 @@ export const fetchSyntheticsMonitor = async ({ )) as SavedObject; return { - id: savedObject.id, ...savedObject.attributes, + id: savedObject.id, updated_at: savedObject.updated_at, } as EncryptedSyntheticsSavedMonitor; };