Fix host event type and reference errors

This commit is contained in:
Jake McDermott 2020-03-23 11:44:03 -04:00
parent 4529429e99
commit fe2ebeb872
No known key found for this signature in database
GPG Key ID: 0E56ED990CDFCB4F

View File

@ -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 }) {
/>
<Detail
label={i18n._(t`Command`)}
value={hostEvent.event_data.res.cmd}
value={hostEvent?.event_data?.res?.cmd}
/>
</DetailList>
</Tab>