Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.x] [Uptime] Refresh index and also show more info to user regardi… (#62606) #63946

Merged
merged 10 commits into from
Apr 23, 2020
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,44 @@
import React, { useContext, useEffect } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { indexStatusAction } from '../../../state/actions';
import { indexStatusSelector } from '../../../state/selectors';
import { indexStatusSelector, selectDynamicSettings } from '../../../state/selectors';
import { EmptyStateComponent } from '../../functional/empty_state/empty_state';
import { UptimeRefreshContext } from '../../../contexts';
import { getDynamicSettings } from '../../../state/actions/dynamic_settings';

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

const { settings } = useSelector(selectDynamicSettings);

const heartbeatIndices = settings?.heartbeatIndices || '';

const dispatch = useDispatch();

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

useEffect(() => {
dispatch(indexStatusAction.get());
}, [dispatch, heartbeatIndices]);

useEffect(() => {
dispatch(getDynamicSettings());
}, [dispatch]);

return (
<EmptyStateComponent
statesIndexStatus={data}
loading={loading}
errors={error ? [error] : undefined}
children={children as React.ReactElement}
settings={settings}
/>
);
};

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading