mirror of
https://github.com/elastic/kibana.git
synced 2025-06-27 18:51:07 -04:00
[Uptime] Supress fetch errors on no data screen (#113458)
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
2b401d06df
commit
fed0dc6563
3 changed files with 12 additions and 7 deletions
|
@ -38,12 +38,14 @@ export const UptimePageTemplateComponent: React.FC<Props> = ({ path, pageHeader,
|
|||
|
||||
const noDataConfig = useNoDataConfig();
|
||||
|
||||
const { loading, error } = useHasData();
|
||||
const { loading, error, data } = useHasData();
|
||||
|
||||
if (error) {
|
||||
return <EmptyStateError errors={[error]} />;
|
||||
}
|
||||
|
||||
const showLoading = loading && path === OVERVIEW_ROUTE && !data;
|
||||
|
||||
return (
|
||||
<>
|
||||
<div data-test-subj={noDataConfig ? 'data-missing' : undefined} />
|
||||
|
@ -51,9 +53,9 @@ export const UptimePageTemplateComponent: React.FC<Props> = ({ path, pageHeader,
|
|||
pageHeader={pageHeader}
|
||||
noDataConfig={path === OVERVIEW_ROUTE && !loading ? noDataConfig : undefined}
|
||||
>
|
||||
{loading && path === OVERVIEW_ROUTE && <EmptyStateLoading />}
|
||||
{showLoading && <EmptyStateLoading />}
|
||||
<div
|
||||
style={{ visibility: loading && path === OVERVIEW_ROUTE ? 'hidden' : 'initial' }}
|
||||
style={{ visibility: showLoading ? 'hidden' : 'initial' }}
|
||||
data-test-subj={noDataConfig ? 'data-missing' : undefined}
|
||||
>
|
||||
{children}
|
||||
|
|
|
@ -13,7 +13,7 @@ import { UptimeRefreshContext } from '../../../contexts';
|
|||
import { getDynamicSettings } from '../../../state/actions/dynamic_settings';
|
||||
|
||||
export const useHasData = () => {
|
||||
const { loading, error } = useSelector(indexStatusSelector);
|
||||
const { loading, error, data } = useSelector(indexStatusSelector);
|
||||
const { lastRefresh } = useContext(UptimeRefreshContext);
|
||||
|
||||
const { settings } = useSelector(selectDynamicSettings);
|
||||
|
@ -29,6 +29,7 @@ export const useHasData = () => {
|
|||
}, [dispatch]);
|
||||
|
||||
return {
|
||||
data,
|
||||
error,
|
||||
loading,
|
||||
settings,
|
||||
|
|
|
@ -9,7 +9,7 @@ import React, { createContext, useContext, useEffect } from 'react';
|
|||
import { useDispatch, useSelector } from 'react-redux';
|
||||
import { useFetcher } from '../../../observability/public';
|
||||
import { DataPublicPluginStart, IndexPattern } from '../../../../../src/plugins/data/public';
|
||||
import { selectDynamicSettings } from '../state/selectors';
|
||||
import { indexStatusSelector, selectDynamicSettings } from '../state/selectors';
|
||||
import { getDynamicSettings } from '../state/actions/dynamic_settings';
|
||||
|
||||
export const UptimeIndexPatternContext = createContext({} as IndexPattern);
|
||||
|
@ -19,6 +19,8 @@ export const UptimeIndexPatternContextProvider: React.FC<{ data: DataPublicPlugi
|
|||
data: { indexPatterns },
|
||||
}) => {
|
||||
const { settings } = useSelector(selectDynamicSettings);
|
||||
const { data: indexStatus } = useSelector(indexStatusSelector);
|
||||
|
||||
const dispatch = useDispatch();
|
||||
|
||||
useEffect(() => {
|
||||
|
@ -30,11 +32,11 @@ export const UptimeIndexPatternContextProvider: React.FC<{ data: DataPublicPlugi
|
|||
const heartbeatIndices = settings?.heartbeatIndices || '';
|
||||
|
||||
const { data } = useFetcher<Promise<IndexPattern | undefined>>(async () => {
|
||||
if (heartbeatIndices) {
|
||||
if (heartbeatIndices && indexStatus?.indexExists) {
|
||||
// this only creates an index pattern in memory, not as saved object
|
||||
return indexPatterns.create({ title: heartbeatIndices });
|
||||
}
|
||||
}, [heartbeatIndices]);
|
||||
}, [heartbeatIndices, indexStatus?.indexExists]);
|
||||
|
||||
return <UptimeIndexPatternContext.Provider value={data!} children={children} />;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue