Skip to content

Commit

Permalink
Revert "feat: Show loading panel immediately for deephaven UI"
Browse files Browse the repository at this point in the history
This reverts commit dcbfdab.
  • Loading branch information
mattrunyon committed Nov 16, 2024
1 parent dcbfdab commit f6ca5b9
Showing 1 changed file with 30 additions and 22 deletions.
52 changes: 30 additions & 22 deletions plugins/ui/src/js/src/widget/WidgetHandler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ import WidgetStatusContext, {
WidgetStatus,
} from '../layout/WidgetStatusContext';
import WidgetErrorView from './WidgetErrorView';
import ReactPanel from '../layout/ReactPanel';

const log = Log.module('@deephaven/js-plugin-ui/WidgetHandler');

Expand Down Expand Up @@ -78,12 +77,7 @@ function WidgetHandler({
setIsLoading(true);
}

// Default to a single panel so we can immediately show a loading spinner
// The panel will be replaced with the first actual panel when the document loads
// Dashboards already have a loader and the placeholder panel causes an error
const [document, setDocument] = useState<ReactNode>(
widgetDescriptor.type === 'deephaven.ui.Dashboard' ? null : <ReactPanel />
);
const [document, setDocument] = useState<ReactNode>();

// We want to update the initial data if the widget changes, as we'll need to re-fetch the widget and want to start with a fresh state.
// eslint-disable-next-line react-hooks/exhaustive-deps
Expand Down Expand Up @@ -364,21 +358,35 @@ function WidgetHandler({
if (isLoading) {
return { status: 'loading', descriptor: widgetDescriptor };
}
return { status: 'ready', descriptor: widgetDescriptor };
}, [error, widgetDescriptor, isLoading]);

return renderedDocument ? (
<WidgetStatusContext.Provider value={widgetStatus}>
<DocumentHandler
widget={widgetDescriptor}
initialData={initialData}
onDataChange={onDataChange}
onClose={onClose}
>
{renderedDocument}
</DocumentHandler>
</WidgetStatusContext.Provider>
) : null;
if (renderedDocument != null) {
return { status: 'ready', descriptor: widgetDescriptor };
}
return { status: 'loading', descriptor: widgetDescriptor };
}, [error, renderedDocument, widgetDescriptor, isLoading]);

return useMemo(
() =>
renderedDocument ? (
<WidgetStatusContext.Provider value={widgetStatus}>
<DocumentHandler
widget={widgetDescriptor}
initialData={initialData}
onDataChange={onDataChange}
onClose={onClose}
>
{renderedDocument}
</DocumentHandler>
</WidgetStatusContext.Provider>
) : null,
[
widgetDescriptor,
renderedDocument,
initialData,
onClose,
onDataChange,
widgetStatus,
]
);
}

WidgetHandler.displayName = '@deephaven/js-plugin-ui/WidgetHandler';
Expand Down

0 comments on commit f6ca5b9

Please sign in to comment.