1
0
mirror of https://github.com/ansible/awx.git synced 2024-10-30 13:55:31 +03:00

Merge pull request #6381 from jakemcdermott/6380-fix-host-event-errors

Fix host event type and reference errors

Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
softwarefactory-project-zuul[bot] 2020-03-23 22:34:36 +00:00 committed by GitHub
commit c4e50cbf7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -97,7 +97,9 @@ const processCodeMirrorValue = value => {
}; };
const processStdOutValue = hostEvent => { const processStdOutValue = hostEvent => {
const { taskAction, res } = hostEvent.event_data; const taskAction = hostEvent?.event_data?.taskAction;
const res = hostEvent?.event_data?.res;
let stdOut; let stdOut;
if (taskAction === 'debug' && res.result && res.result.stdout) { if (taskAction === 'debug' && res.result && res.result.stdout) {
stdOut = res.result.stdout; stdOut = res.result.stdout;
@ -107,7 +109,7 @@ const processStdOutValue = hostEvent => {
Array.isArray(res.results) Array.isArray(res.results)
) { ) {
[stdOut] = res.results; [stdOut] = res.results;
} else { } else if (res) {
stdOut = res.stdout; stdOut = res.stdout;
} }
return stdOut; return stdOut;
@ -125,8 +127,8 @@ function HostEventModal({ onClose, hostEvent = {}, isOpen = false, i18n }) {
setActiveTabKey(tabIndex); setActiveTabKey(tabIndex);
}; };
const jsonObj = processCodeMirrorValue(hostEvent.event_data.res); const jsonObj = processCodeMirrorValue(hostEvent?.event_data?.res);
const stdErr = processCodeMirrorValue(hostEvent.event_data.res.stderr); const stdErr = processCodeMirrorValue(hostEvent?.event_data?.res?.stderr);
const stdOut = processCodeMirrorValue(processStdOutValue(hostEvent)); const stdOut = processCodeMirrorValue(processStdOutValue(hostEvent));
return ( return (
@ -167,7 +169,7 @@ function HostEventModal({ onClose, hostEvent = {}, isOpen = false, i18n }) {
/> />
<Detail <Detail
label={i18n._(t`Command`)} label={i18n._(t`Command`)}
value={hostEvent.event_data.res.cmd} value={hostEvent?.event_data?.res?.cmd}
/> />
</DetailList> </DetailList>
</Tab> </Tab>