pagespeed key alert

This commit is contained in:
Alex Holliday committed 2026-01-26 20:47:10 +00:00
1 parent 1819df5117
commit 90e9b41973
3 files changed
+29 -21

No files matched your search

@@ -12,13 +12,11 @@ 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 { Trans, useTranslation } from "react-i18next";
import { Link as RouterLink } from "react-router-dom"; import { Link as RouterLink } from "react-router-dom";
import { Typography } from "@mui/material";
export const PageSpeedKeyPriorityFallback = () => { export const PageSpeedKeyPriorityFallback = () => {
const theme = useTheme();
const { t } = useTranslation();
return ( return (
<BaseFallback> <BaseFallback>
<Alert <Alert
@@ -26,23 +24,23 @@ export const PageSpeedKeyPriorityFallback = () => {
sx={{ sx={{
width: "100%", width: "100%",
maxWidth: 600, maxWidth: 600,
backgroundColor: theme.palette.warning.light,
color: theme.palette.warning.contrastText,
"& .MuiAlert-icon": {
color: theme.palette.warning.contrastText,
},
}} }}
> >
{t("pageSpeedWarning")}{" "} <Typography>
<Link <Trans
component={RouterLink} i18nKey="common.alerts.pageSpeedApiKey.content"
to="/settings" components={{
color="inherit" settingsLink: (
fontWeight="inherit" <Link
> component={RouterLink}
{t("pageSpeedLearnMoreLink")} to="/settings"
</Link>{" "} color="inherit"
{t("pageSpeedAddApiKey")} fontWeight="inherit"
/>
),
}}
/>
</Typography>
</Alert> </Alert>
</BaseFallback> </BaseFallback>
); );
@@ -178,8 +176,8 @@ export const MonitorBasePageWithStates = ({
if (priorityFallback) { if (priorityFallback) {
return ( return (
<BasePage <BasePage
loading={false} loading={loading}
error={false} error={error}
{...props} {...props}
> >
{priorityFallback} {priorityFallback}
@@ -3,6 +3,7 @@ import {
UpStatusBox, UpStatusBox,
DownStatusBox, DownStatusBox,
PausedStatusBox, PausedStatusBox,
PageSpeedKeyPriorityFallback,
} from "@/Components/v2/design-elements"; } from "@/Components/v2/design-elements";
import { Dialog } from "@/Components/v2/inputs"; import { Dialog } from "@/Components/v2/inputs";
import { HeaderCreate } from "@/Components/v2/common"; import { HeaderCreate } from "@/Components/v2/common";
@@ -52,6 +53,9 @@ const PageSpeedMonitorsPage = () => {
const isLoading = monitorsIsLoading || settingsIsLoading; const isLoading = monitorsIsLoading || settingsIsLoading;
const showApiKeyWarning =
isAdmin && settingsData && !settingsData.pagespeedKeySet;
const handleConfirm = async () => { const handleConfirm = async () => {
if (!selectedMonitor) return; if (!selectedMonitor) return;
await deleteFn(`/monitors/${selectedMonitor.id}`); await deleteFn(`/monitors/${selectedMonitor.id}`);
@@ -70,6 +74,7 @@ const PageSpeedMonitorsPage = () => {
items={monitors || []} items={monitors || []}
page="pageSpeed" page="pageSpeed"
actionLink="/pagespeed/create" actionLink="/pagespeed/create"
priorityFallback={showApiKeyWarning ? <PageSpeedKeyPriorityFallback /> : undefined}
> >
<HeaderCreate <HeaderCreate
path="/pagespeed/create" path="/pagespeed/create"
+5
View File
@@ -13,6 +13,11 @@
"cancel": "Cancel", "cancel": "Cancel",
"confirm": "Confirm" "confirm": "Confirm"
}, },
"alerts": {
"pageSpeedApiKey": {
"content": "Warning: You haven't added a Google PageSpeed API key yet. Visit <settingsLink>Settings</settingsLink> to add one. Without it, the PageSpeed monitor won't function."
}
},
"dialogs": { "dialogs": {
"delete": { "delete": {
"description": "This action cannot be undone.", "description": "This action cannot be undone.",