Skip to content
Snippets Groups Projects
Unverified Commit 8f2a077d authored by Mahatthana (Kelvin) Nomsawadi's avatar Mahatthana (Kelvin) Nomsawadi Committed by GitHub
Browse files

Fix main page show indefinite loading spinner when any API failed (#20840)

parent 651da83c
No related branches found
No related tags found
No related merge requests found
......@@ -29,7 +29,18 @@ const LegacyImage = props =>
className={props.imageClassName}
/>
) : null;
/**
* @typedef {Record<string, any>} EmptyStateProps
* @property {import("react").ReactNode} message
* @property {import("react").ReactNode} [title]
* @property {import("react").ReactNode} [action]
* @property {import("react-router").IndexLinkProps["to"]} [link]
* @property {import("react").ReactNode} [illustrationElement]
* @property {function} [onActionClick]
*
* @param {EmptyStateProps} props
* @returns {import("react").ReactElement}
*/
const EmptyState = ({
title,
message,
......
import React, { Fragment } from "react";
import { t } from "ttag";
import LoadingAndErrorWrapper from "metabase/components/LoadingAndErrorWrapper";
import EmptyState from "metabase/components/EmptyState";
import ErrorDetails from "metabase/components/ErrorDetails";
import CollectionSection from "../CollectionSection";
import DatabaseSection from "../DatabaseSection";
import GreetingSection from "../GreetingSection";
......@@ -31,6 +34,7 @@ export interface HomepageProps {
onCollectionClick?: () => void;
onDashboardClick?: (dashboard: Dashboard) => void;
onDatabaseClick?: (database: Database) => void;
allError?: boolean;
}
const Homepage = ({
......@@ -49,6 +53,7 @@ const Homepage = ({
onCollectionClick,
onDashboardClick,
onDatabaseClick,
allError,
}: HomepageProps): JSX.Element => {
return (
<HomepageRoot>
......@@ -87,6 +92,14 @@ const Homepage = ({
onHideSyncingModal={onHideSyncingModal}
/>
</Fragment>
) : allError ? (
<EmptyState
title={t`Something's gone wrong`}
message={t`We've run into an error. You can try refreshing the page, or just go back.`}
illustrationElement={
<div className="QueryError-image QueryError-image--serverError" />
}
/>
) : (
<LoadingAndErrorWrapper loading />
)}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment