Skip to content

Commit

Permalink
Fix error rendering logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Zizhou Wang committed Nov 22, 2021
1 parent 0307447 commit 16ac6ad
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions x-pack/plugins/session_view/public/components/SessionView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,16 @@ export const SessionView = ({ sessionEntityId, height }: SessionViewDeps) => {
}
};

const { isLoading, data: getData } = useQuery<ProcessEventResults, Error>(
['process-tree', 'process_tree'],
() =>
http.get<ProcessEventResults>(PROCESS_EVENTS_ROUTE, {
query: {
sessionEntityId,
},
})
const {
isLoading,
isError,
data: getData,
} = useQuery<ProcessEventResults, Error>(['process-tree', 'process_tree'], () =>
http.get<ProcessEventResults>(PROCESS_EVENTS_ROUTE, {
query: {
sessionEntityId,
},
})
);

const sortEvents = (a: ProcessEvent, b: ProcessEvent) => {
Expand Down Expand Up @@ -118,7 +120,18 @@ export const SessionView = ({ sessionEntityId, height }: SessionViewDeps) => {
/>
</SectionLoading>
);
} else if (data) {
}
if (isError) {
return (
<EuiEmptyPrompt
iconType="alert"
color="danger"
title={<h2>Error loading Session View</h2>}
body={<p>There was an error loading the Session View.</p>}
/>
);
}
if (data) {
return (
<div css={styles.processTree}>
<ProcessTree
Expand All @@ -131,17 +144,9 @@ export const SessionView = ({ sessionEntityId, height }: SessionViewDeps) => {
</div>
);
}
return (
<EuiEmptyPrompt
iconType="alert"
color="danger"
title={<h2>Error loading Session View</h2>}
body={<p>There was an error loading the Session View.</p>}
/>
);
};

if (!(isLoading || data.length)) {
if (!(isLoading || isError || data.length)) {
return renderNoData();
}

Expand Down

0 comments on commit 16ac6ad

Please sign in to comment.