From f99dc23df34ea22c1e097fc03ebbf1802809075d Mon Sep 17 00:00:00 2001 From: Vallari Date: Mon, 14 Aug 2023 21:10:37 +0530 Subject: [PATCH] add Error page Signed-off-by: Vallari --- src/App.tsx | 5 ++++- src/pages/Error/index.tsx | 17 +++++++++++++++++ src/pages/Run/index.tsx | 5 +++-- 3 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 src/pages/Error/index.tsx diff --git a/src/App.tsx b/src/App.tsx index ba0b42e..2c7901a 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,6 +1,6 @@ import { useState } from "react"; -import { Routes, Route } from "react-router-dom"; +import { Routes, Route, Navigate } from "react-router-dom"; import { Helmet } from "react-helmet"; import AppBar from "./components/AppBar"; @@ -9,6 +9,7 @@ import Runs from "./pages/Runs"; import Run from "./pages/Run"; import Job from "./pages/Job"; import Queue from "./pages/Queue"; +import Error from "./pages/Error"; import "./App.css"; @@ -41,6 +42,8 @@ function App(props: AppProps) { } /> } /> } /> + } /> + } /> diff --git a/src/pages/Error/index.tsx b/src/pages/Error/index.tsx new file mode 100644 index 0000000..9483be3 --- /dev/null +++ b/src/pages/Error/index.tsx @@ -0,0 +1,17 @@ +import Divider from '@mui/material/Divider'; +import Typography from '@mui/material/Typography'; + + +export default function ErrorPage() { + return ( +
+ +
+ 404 + + This page could not be found. +
+
+
+ ) +} \ No newline at end of file diff --git a/src/pages/Run/index.tsx b/src/pages/Run/index.tsx index e608c1d..450b046 100644 --- a/src/pages/Run/index.tsx +++ b/src/pages/Run/index.tsx @@ -1,6 +1,6 @@ import { useQueryParams, StringParam, NumberParam } from "use-query-params"; import { styled, useTheme } from "@mui/material/styles"; -import { useParams } from "react-router-dom"; +import { useParams, useNavigate } from "react-router-dom"; import Typography from "@mui/material/Typography"; import Button from "@mui/material/Button"; import ButtonGroup from "@mui/material/ButtonGroup"; @@ -29,6 +29,7 @@ const Root = styled("div")(() => ({ })); export default function Run() { + const navigate = useNavigate(); const theme = useTheme(); const [params, setParams] = useQueryParams({ status: StringParam, @@ -38,7 +39,7 @@ export default function Run() { const { name } = useParams(); const query = useRun(name === undefined ? "" : name); if (query === null) return 404; - if (query.isError) return null; + if (query.isError) return navigate('/error'); const data: Run | undefined = query.data; const suite = data?.suite; const branch = query.data?.branch;