Don't show loading screen during auto-reload (#83376)

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Phillip Burch 2020-11-17 14:40:02 -06:00 committed by GitHub
parent 62436e3f03
commit bcc2afa9e2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 2 deletions

View file

@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
import React, { useCallback, useEffect } from 'react';
import React, { useCallback, useEffect, useState } from 'react';
import useInterval from 'react-use/lib/useInterval';
import { EuiFlexGroup, EuiFlexItem, EuiSpacer } from '@elastic/eui';
@ -32,6 +32,7 @@ import { BottomDrawer } from './bottom_drawer';
import { Legend } from './waffle/legend';
export const Layout = () => {
const [showLoading, setShowLoading] = useState(true);
const { sourceId, source } = useSourceContext();
const { currentView, shouldLoadDefault } = useSavedViewContext();
const {
@ -100,6 +101,16 @@ export const Layout = () => {
}
}, [reload, currentView, shouldLoadDefault]);
useEffect(() => {
setShowLoading(true);
}, [options.metric, nodeType]);
useEffect(() => {
const hasNodes = nodes && nodes.length;
// Don't show loading screen when we're auto-reloading
setShowLoading(!hasNodes);
}, [nodes]);
return (
<>
<PageContent>
@ -130,6 +141,7 @@ export const Layout = () => {
options={options}
nodeType={nodeType}
loading={loading}
showLoading={showLoading}
reload={reload}
onDrilldown={applyFilterQuery}
currentTime={currentTime}

View file

@ -37,6 +37,7 @@ interface Props {
formatter: InfraFormatter;
bottomMargin: number;
topMargin: number;
showLoading: boolean;
}
export const NodesOverview = ({
@ -53,6 +54,7 @@ export const NodesOverview = ({
onDrilldown,
bottomMargin,
topMargin,
showLoading,
}: Props) => {
const handleDrilldown = useCallback(
(filter: string) => {
@ -66,7 +68,8 @@ export const NodesOverview = ({
);
const noData = !loading && nodes && nodes.length === 0;
if (loading) {
if (loading && showLoading) {
// Don't show loading screen when we're auto-reloading
return (
<InfraLoadingPanel
height="100%"