From fe2ebeb8727e5a76e5845c84a27aafe8a2938be1 Mon Sep 17 00:00:00 2001 From: Jake McDermott Date: Mon, 23 Mar 2020 11:44:03 -0400 Subject: [PATCH] Fix host event type and reference errors --- .../src/screens/Job/JobOutput/HostEventModal.jsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/awx/ui_next/src/screens/Job/JobOutput/HostEventModal.jsx b/awx/ui_next/src/screens/Job/JobOutput/HostEventModal.jsx index b997d0d19f..1d5a10012a 100644 --- a/awx/ui_next/src/screens/Job/JobOutput/HostEventModal.jsx +++ b/awx/ui_next/src/screens/Job/JobOutput/HostEventModal.jsx @@ -97,7 +97,9 @@ const processCodeMirrorValue = value => { }; const processStdOutValue = hostEvent => { - const { taskAction, res } = hostEvent.event_data; + const taskAction = hostEvent?.event_data?.taskAction; + const res = hostEvent?.event_data?.res; + let stdOut; if (taskAction === 'debug' && res.result && res.result.stdout) { stdOut = res.result.stdout; @@ -107,7 +109,7 @@ const processStdOutValue = hostEvent => { Array.isArray(res.results) ) { [stdOut] = res.results; - } else { + } else if (res) { stdOut = res.stdout; } return stdOut; @@ -125,8 +127,8 @@ function HostEventModal({ onClose, hostEvent = {}, isOpen = false, i18n }) { setActiveTabKey(tabIndex); }; - const jsonObj = processCodeMirrorValue(hostEvent.event_data.res); - const stdErr = processCodeMirrorValue(hostEvent.event_data.res.stderr); + const jsonObj = processCodeMirrorValue(hostEvent?.event_data?.res); + const stdErr = processCodeMirrorValue(hostEvent?.event_data?.res?.stderr); const stdOut = processCodeMirrorValue(processStdOutValue(hostEvent)); return ( @@ -167,7 +169,7 @@ function HostEventModal({ onClose, hostEvent = {}, isOpen = false, i18n }) { />