Skip to content

Commit 3e815cc

Browse files
[7.x] [Uptime] Refresh index and also show more info to user r… (#63946)
* [Uptime] Certificate expiration threshold settings (#63682) * update settings * added cert form * update settings * update types * update test * updated tests * updated snapshots * [Uptime] Refresh index and also show more info to user regardi… (#62606) * Refresh index and also show more info to user * updated type * updated type * updated test * updated formatting * update text * updated types * updated translation * update * fixed types * updated code * fixed types Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> * updated snapshots * up snapshots * update trans Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
1 parent 60bc29b commit 3e815cc

File tree

17 files changed

+1276
-780
lines changed

17 files changed

+1276
-780
lines changed

x-pack/legacy/plugins/uptime/public/components/connected/empty_state/empty_state.tsx

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,44 @@
77
import React, { useContext, useEffect } from 'react';
88
import { useDispatch, useSelector } from 'react-redux';
99
import { indexStatusAction } from '../../../state/actions';
10-
import { indexStatusSelector } from '../../../state/selectors';
10+
import { indexStatusSelector, selectDynamicSettings } from '../../../state/selectors';
1111
import { EmptyStateComponent } from '../../functional/empty_state/empty_state';
1212
import { UptimeRefreshContext } from '../../../contexts';
13+
import { getDynamicSettings } from '../../../state/actions/dynamic_settings';
1314

1415
export const EmptyState: React.FC = ({ children }) => {
1516
const { data, loading, error } = useSelector(indexStatusSelector);
1617
const { lastRefresh } = useContext(UptimeRefreshContext);
1718

19+
const { settings } = useSelector(selectDynamicSettings);
20+
21+
const heartbeatIndices = settings?.heartbeatIndices || '';
22+
1823
const dispatch = useDispatch();
1924

2025
useEffect(() => {
21-
dispatch(indexStatusAction.get());
26+
if (!data || data?.docCount === 0 || data?.indexExists === false) {
27+
dispatch(indexStatusAction.get());
28+
}
29+
// Don't add data , it will create endless loop
30+
// eslint-disable-next-line react-hooks/exhaustive-deps
2231
}, [dispatch, lastRefresh]);
2332

33+
useEffect(() => {
34+
dispatch(indexStatusAction.get());
35+
}, [dispatch, heartbeatIndices]);
36+
37+
useEffect(() => {
38+
dispatch(getDynamicSettings());
39+
}, [dispatch]);
40+
2441
return (
2542
<EmptyStateComponent
2643
statesIndexStatus={data}
2744
loading={loading}
2845
errors={error ? [error] : undefined}
2946
children={children as React.ReactElement}
47+
settings={settings}
3048
/>
3149
);
3250
};

x-pack/legacy/plugins/uptime/public/components/functional/empty_state/__tests__/__snapshots__/data_missing.test.tsx.snap

Lines changed: 0 additions & 52 deletions
This file was deleted.

x-pack/legacy/plugins/uptime/public/components/functional/empty_state/__tests__/__snapshots__/data_or_index_missing.test.tsx.snap

Lines changed: 92 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)