Skip to content

Commit

Permalink
[Uptime] Refresh index and also show more info to user regardi… (#62606)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
shahzad31 and elasticmachine authored Apr 18, 2020
1 parent 73548bd commit c59320c
Show file tree
Hide file tree
Showing 18 changed files with 1,277 additions and 779 deletions.
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

0 comments on commit c59320c

Please sign in to comment.