Skip to content

Commit

Permalink
Don't show loading screen during auto-reload (elastic#83376)
Browse files Browse the repository at this point in the history
Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
phillipb and kibanamachine committed Nov 17, 2020
1 parent 242eae0 commit 95b51e3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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>
Expand Down Expand Up @@ -130,6 +141,7 @@ export const Layout = () => {
options={options}
nodeType={nodeType}
loading={loading}
showLoading={showLoading}
reload={reload}
onDrilldown={applyFilterQuery}
currentTime={currentTime}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ interface Props {
formatter: InfraFormatter;
bottomMargin: number;
topMargin: number;
showLoading: boolean;
}

export const NodesOverview = ({
Expand All @@ -53,6 +54,7 @@ export const NodesOverview = ({
onDrilldown,
bottomMargin,
topMargin,
showLoading,
}: Props) => {
const handleDrilldown = useCallback(
(filter: string) => {
Expand All @@ -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%"
Expand Down

0 comments on commit 95b51e3

Please sign in to comment.