Merge pull request #2053 from bluewave-labs/feature/pagespeed-api-warning-2022
Feature/pagespeed api warning 2022
This commit is contained in:
6 files changed
+96
-13
No files matched your search
@@ -1,12 +1,14 @@
|
|||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
import { useTheme } from "@emotion/react";
|
import { useTheme } from "@emotion/react";
|
||||||
import { Box, Button, Stack, Typography } from "@mui/material";
|
import { Box, Button, Stack, Typography, Link } from "@mui/material";
|
||||||
import Skeleton from "../../assets/Images/create-placeholder.svg?react";
|
import Skeleton from "../../assets/Images/create-placeholder.svg?react";
|
||||||
import SkeletonDark from "../../assets/Images/create-placeholder-dark.svg?react";
|
import SkeletonDark from "../../assets/Images/create-placeholder-dark.svg?react";
|
||||||
import Background from "../../assets/Images/background-grid.svg?react";
|
import Background from "../../assets/Images/background-grid.svg?react";
|
||||||
import Check from "../Check/Check";
|
import Check from "../Check/Check";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { useSelector } from "react-redux";
|
import { useSelector } from "react-redux";
|
||||||
|
import Alert from "../Alert";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
import "./index.css";
|
import "./index.css";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -17,13 +19,40 @@ import "./index.css";
|
|||||||
* @param {Array<string>} props.checks - An array of strings representing the checks to display.
|
* @param {Array<string>} props.checks - An array of strings representing the checks to display.
|
||||||
* @param {string} [props.link="/"] - The link to navigate to.
|
* @param {string} [props.link="/"] - The link to navigate to.
|
||||||
* @param {boolean} [props.vowelStart=false] - Whether the title starts with a vowel.
|
* @param {boolean} [props.vowelStart=false] - Whether the title starts with a vowel.
|
||||||
|
* @param {boolean} [props.showPageSpeedWarning=false] - Whether to show the PageSpeed API warning.
|
||||||
* @returns {JSX.Element} The rendered fallback UI.
|
* @returns {JSX.Element} The rendered fallback UI.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const Fallback = ({ title, checks, link = "/", isAdmin, vowelStart = false }) => {
|
const Fallback = ({ title, checks, link = "/", isAdmin, vowelStart = false, showPageSpeedWarning = false }) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const mode = useSelector((state) => state.ui.mode);
|
const mode = useSelector((state) => state.ui.mode);
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
// Custom warning message with clickable link
|
||||||
|
const renderWarningMessage = () => {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{t("pageSpeedWarning")} {" "}
|
||||||
|
<Link
|
||||||
|
href="https://docs.checkmate.so/users-guide/quickstart#env-vars-server"
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
sx={{
|
||||||
|
textDecoration: "underline",
|
||||||
|
color: "inherit",
|
||||||
|
fontWeight: "inherit",
|
||||||
|
"&:hover": {
|
||||||
|
textDecoration: "underline",
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{t("pageSpeedLearnMoreLink")}
|
||||||
|
</Link>
|
||||||
|
{" "}{t("pageSpeedAddApiKey")}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box
|
<Box
|
||||||
@@ -80,14 +109,40 @@ const Fallback = ({ title, checks, link = "/", isAdmin, vowelStart = false }) =>
|
|||||||
</Stack>
|
</Stack>
|
||||||
{/* TODO - display a different fallback if user is not an admin*/}
|
{/* TODO - display a different fallback if user is not an admin*/}
|
||||||
{isAdmin && (
|
{isAdmin && (
|
||||||
<Button
|
<>
|
||||||
variant="contained"
|
<Button
|
||||||
color="accent"
|
variant="contained"
|
||||||
sx={{ alignSelf: "center" }}
|
color="accent"
|
||||||
onClick={() => navigate(link)}
|
sx={{ alignSelf: "center" }}
|
||||||
>
|
onClick={() => navigate(link)}
|
||||||
Let's create your first {title}
|
>
|
||||||
</Button>
|
Let's create your first {title}
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
{/* Warning box for PageSpeed monitor */}
|
||||||
|
{(title === "pagespeed monitor" && showPageSpeedWarning) && (
|
||||||
|
<Box sx={{ width: "80%", maxWidth: "600px", zIndex: 1 }}>
|
||||||
|
<Box sx={{
|
||||||
|
'& .alert.row-stack': {
|
||||||
|
backgroundColor: theme.palette.warningSecondary.main,
|
||||||
|
borderColor: theme.palette.warningSecondary.lowContrast,
|
||||||
|
'& .MuiTypography-root': {
|
||||||
|
color: theme.palette.warningSecondary.contrastText
|
||||||
|
},
|
||||||
|
'& .MuiBox-root > svg': {
|
||||||
|
color: theme.palette.warningSecondary.contrastText
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}}>
|
||||||
|
<Alert
|
||||||
|
variant="warning"
|
||||||
|
hasIcon={true}
|
||||||
|
body={renderWarningMessage()}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
)}
|
)}
|
||||||
</Stack>
|
</Stack>
|
||||||
</Box>
|
</Box>
|
||||||
@@ -100,6 +155,7 @@ Fallback.propTypes = {
|
|||||||
link: PropTypes.string,
|
link: PropTypes.string,
|
||||||
isAdmin: PropTypes.bool,
|
isAdmin: PropTypes.bool,
|
||||||
vowelStart: PropTypes.bool,
|
vowelStart: PropTypes.bool,
|
||||||
|
showPageSpeedWarning: PropTypes.bool,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Fallback;
|
export default Fallback;
|
||||||
@@ -52,6 +52,7 @@ const PageSpeed = () => {
|
|||||||
]}
|
]}
|
||||||
link="/pagespeed/create"
|
link="/pagespeed/create"
|
||||||
isAdmin={isAdmin}
|
isAdmin={isAdmin}
|
||||||
|
showPageSpeedWarning={true}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ const paletteColors = {
|
|||||||
orange500: "#E88C30",
|
orange500: "#E88C30",
|
||||||
orange600: "#DC6803",
|
orange600: "#DC6803",
|
||||||
orange800: "#624711",
|
orange800: "#624711",
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const semanticColors = {
|
const semanticColors = {
|
||||||
@@ -234,6 +235,21 @@ const newSemanticColors = {
|
|||||||
dark: newColors.orange600,
|
dark: newColors.orange600,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
/* Custom palette for PageSpeed warning box */
|
||||||
|
warningSecondary: {
|
||||||
|
main: {
|
||||||
|
light: paletteColors.orange50,
|
||||||
|
dark: paletteColors.orange800,
|
||||||
|
},
|
||||||
|
contrastText: {
|
||||||
|
light: paletteColors.orange600,
|
||||||
|
dark: paletteColors.orange100,
|
||||||
|
},
|
||||||
|
lowContrast: {
|
||||||
|
light: paletteColors.orange300,
|
||||||
|
dark: paletteColors.orange400,
|
||||||
|
},
|
||||||
|
},
|
||||||
error: {
|
error: {
|
||||||
main: {
|
main: {
|
||||||
light: newColors.red700,
|
light: newColors.red700,
|
||||||
@@ -248,6 +264,7 @@ const newSemanticColors = {
|
|||||||
dark: newColors.red600,
|
dark: newColors.red600,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
/* These are temporary, just for everything not to break */
|
/* These are temporary, just for everything not to break */
|
||||||
gradient: {
|
gradient: {
|
||||||
color1: {
|
color1: {
|
||||||
|
|||||||
+4
-1
@@ -375,5 +375,8 @@
|
|||||||
"infrastructureMonitorUpdated": "Infrastructure monitor updated successfully!",
|
"infrastructureMonitorUpdated": "Infrastructure monitor updated successfully!",
|
||||||
"errorInvalidTypeId": "Invalid notification type provided",
|
"errorInvalidTypeId": "Invalid notification type provided",
|
||||||
"errorInvalidFieldId": "Invalid field ID provided",
|
"errorInvalidFieldId": "Invalid field ID provided",
|
||||||
"inviteNoTokenFound": "No invite token found"
|
"inviteNoTokenFound": "No invite token found",
|
||||||
|
"pageSpeedWarning": "Warning: You haven't added a Google PageSpeed API key. Without it, the PageSpeed monitor won't function.",
|
||||||
|
"pageSpeedLearnMoreLink": "Click here to learn",
|
||||||
|
"pageSpeedAddApiKey": "how to add your API key."
|
||||||
}
|
}
|
||||||
+4
-1
@@ -360,5 +360,8 @@
|
|||||||
"uptimeCreate": "",
|
"uptimeCreate": "",
|
||||||
"uptimeCreateJsonPath": "",
|
"uptimeCreateJsonPath": "",
|
||||||
"uptimeCreateJsonPathQuery": "",
|
"uptimeCreateJsonPathQuery": "",
|
||||||
"maintenanceTableActionMenuDialogTitle": ""
|
"maintenanceTableActionMenuDialogTitle": "",
|
||||||
|
"pageSpeedWarning": "Предупреждение: Вы не добавили ключ API Google PageSpeed. Без него монитор PageSpeed не будет работать.",
|
||||||
|
"pageSpeedLearnMoreLink": "Нажмите здесь, чтобы узнать",
|
||||||
|
"pageSpeedAddApiKey": "как добавить ваш ключ API."
|
||||||
}
|
}
|
||||||
+4
-1
@@ -375,5 +375,8 @@
|
|||||||
"infrastructureMonitorUpdated": "",
|
"infrastructureMonitorUpdated": "",
|
||||||
"errorInvalidTypeId": "",
|
"errorInvalidTypeId": "",
|
||||||
"errorInvalidFieldId": "",
|
"errorInvalidFieldId": "",
|
||||||
"inviteNoTokenFound": ""
|
"inviteNoTokenFound": "",
|
||||||
|
"pageSpeedWarning": "Uyarı: Google PageSpeed API anahtarı eklemediniz. Bu olmadan, PageSpeed monitörü çalışmayacaktır.",
|
||||||
|
"pageSpeedLearnMoreLink": "API anahtarınızı nasıl ekleyeceğinizi",
|
||||||
|
"pageSpeedAddApiKey": "öğrenmek için buraya tıklayın."
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user