priority fallback
This commit is contained in:
1 parent
6380dcc6ba
commit
1819df5117
2 files changed
+53
-1
No files matched your search
@@ -1,8 +1,11 @@
|
|||||||
import Stack from "@mui/material/Stack";
|
import Stack from "@mui/material/Stack";
|
||||||
|
import Alert from "@mui/material/Alert";
|
||||||
|
import Link from "@mui/material/Link";
|
||||||
import {
|
import {
|
||||||
ErrorFallback,
|
ErrorFallback,
|
||||||
EmptyFallback,
|
EmptyFallback,
|
||||||
EmptyMonitorFallback,
|
EmptyMonitorFallback,
|
||||||
|
BaseFallback,
|
||||||
} from "@/Components/v2/design-elements/Fallback";
|
} from "@/Components/v2/design-elements/Fallback";
|
||||||
import { Breadcrumb } from "@/Components/v2/design-elements/Breadcrumb";
|
import { Breadcrumb } from "@/Components/v2/design-elements/Breadcrumb";
|
||||||
import CircularProgress from "@mui/material/CircularProgress";
|
import CircularProgress from "@mui/material/CircularProgress";
|
||||||
@@ -10,6 +13,41 @@ import CircularProgress from "@mui/material/CircularProgress";
|
|||||||
import type { StackProps } from "@mui/material/Stack";
|
import type { StackProps } from "@mui/material/Stack";
|
||||||
import { useTheme } from "@mui/material/styles";
|
import { useTheme } from "@mui/material/styles";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
import { Link as RouterLink } from "react-router-dom";
|
||||||
|
|
||||||
|
export const PageSpeedKeyPriorityFallback = () => {
|
||||||
|
const theme = useTheme();
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<BaseFallback>
|
||||||
|
<Alert
|
||||||
|
severity="warning"
|
||||||
|
sx={{
|
||||||
|
width: "100%",
|
||||||
|
maxWidth: 600,
|
||||||
|
backgroundColor: theme.palette.warning.light,
|
||||||
|
color: theme.palette.warning.contrastText,
|
||||||
|
"& .MuiAlert-icon": {
|
||||||
|
color: theme.palette.warning.contrastText,
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{t("pageSpeedWarning")}{" "}
|
||||||
|
<Link
|
||||||
|
component={RouterLink}
|
||||||
|
to="/settings"
|
||||||
|
color="inherit"
|
||||||
|
fontWeight="inherit"
|
||||||
|
>
|
||||||
|
{t("pageSpeedLearnMoreLink")}
|
||||||
|
</Link>{" "}
|
||||||
|
{t("pageSpeedAddApiKey")}
|
||||||
|
</Alert>
|
||||||
|
</BaseFallback>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
interface BasePageProps extends StackProps {
|
interface BasePageProps extends StackProps {
|
||||||
loading?: boolean;
|
loading?: boolean;
|
||||||
error?: boolean;
|
error?: boolean;
|
||||||
@@ -114,6 +152,7 @@ interface MonitorBasePageWithStatesProps extends StackProps {
|
|||||||
page: string;
|
page: string;
|
||||||
actionLink?: string;
|
actionLink?: string;
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
|
priorityFallback?: React.ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
const isEmpty = (items: any[]) => {
|
const isEmpty = (items: any[]) => {
|
||||||
@@ -129,12 +168,25 @@ export const MonitorBasePageWithStates = ({
|
|||||||
page,
|
page,
|
||||||
actionLink,
|
actionLink,
|
||||||
children,
|
children,
|
||||||
|
priorityFallback,
|
||||||
...props
|
...props
|
||||||
}: MonitorBasePageWithStatesProps) => {
|
}: MonitorBasePageWithStatesProps) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const showLoading = loading && (!items || items.length === 0);
|
const showLoading = loading && (!items || items.length === 0);
|
||||||
|
|
||||||
|
if (priorityFallback) {
|
||||||
|
return (
|
||||||
|
<BasePage
|
||||||
|
loading={false}
|
||||||
|
error={false}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
{priorityFallback}
|
||||||
|
</BasePage>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (!loading && isEmpty(items)) {
|
if (!loading && isEmpty(items)) {
|
||||||
return (
|
return (
|
||||||
<EmptyMonitorFallback
|
<EmptyMonitorFallback
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ const PageSpeedMonitorsPage = () => {
|
|||||||
isLoading: monitorsIsLoading,
|
isLoading: monitorsIsLoading,
|
||||||
error: monitorsError,
|
error: monitorsError,
|
||||||
refetch,
|
refetch,
|
||||||
} = useGet<MonitorsWithChecksResponse>(monitorsUrl);
|
} = useGet<MonitorsWithChecksResponse>(monitorsUrl, {}, { refreshInterval: 30000 });
|
||||||
|
|
||||||
const settingsUrl = "/settings";
|
const settingsUrl = "/settings";
|
||||||
const {
|
const {
|
||||||
|
|||||||
Reference in new issue
Block a user