Skip to content

Commit

Permalink
Refines hasAnyData check for alerts (#117499) (#117578)
Browse files Browse the repository at this point in the history
* Refines hasAnyData check for alerts

* Fixes type refinements

* Applies review feedback

* Naming is hard

Co-authored-by: Claudio Procida <[email protected]>
  • Loading branch information
kibanamachine and claudiopro authored Nov 10, 2021
1 parent f4be80f commit 6cafc35
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ describe('HasDataContextProvider', () => {
status: 'success',
},
},
hasAnyData: false,
hasAnyData: true,
isAllRequestsComplete: true,
forceUpdate: expect.any(String),
onRefreshTimeRange: expect.any(Function),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,12 @@ export function HasDataContextProvider({ children }: { children: React.ReactNode
return appStatus !== undefined && appStatus !== FETCH_STATUS.LOADING;
});

const hasAnyData = (Object.keys(hasDataMap) as ObservabilityFetchDataPlugins[]).some(
(app) => hasDataMap[app]?.hasData === true
);
const hasAnyData = (Object.keys(hasDataMap) as ObservabilityFetchDataPlugins[]).some((app) => {
const appHasData = hasDataMap[app]?.hasData;
return (
appHasData === true || (Array.isArray(appHasData) && (appHasData as Alert[])?.length > 0)
);
});

return (
<HasDataContext.Provider
Expand Down

0 comments on commit 6cafc35

Please sign in to comment.