Skip to content

Commit

Permalink
add Error page
Browse files Browse the repository at this point in the history
Signed-off-by: Vallari <[email protected]>
  • Loading branch information
VallariAg committed Aug 14, 2023
1 parent 3a30b59 commit f99dc23
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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";

Expand Down Expand Up @@ -41,6 +42,8 @@ function App(props: AppProps) {
<Route path="/queue" element={<Queue />} />
<Route path="/:name" element={<Run />} />
<Route path="/:name/:job_id" element={<Job />} />
<Route path="/error" element={ <Error /> } />
<Route path="*" element={<Navigate to="/error" replace />} />
</Routes>
</div>
</div>
Expand Down
17 changes: 17 additions & 0 deletions src/pages/Error/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import Divider from '@mui/material/Divider';
import Typography from '@mui/material/Typography';


export default function ErrorPage() {
return (
<div>
<Typography variant="overline" display="block" gutterBottom>
<div style={{ display: "flex", flexDirection: "row", gap: 10 }}>
404
<Divider orientation="vertical" variant="middle" flexItem />
This page could not be found.
</div>
</Typography>
</div>
)
}
5 changes: 3 additions & 2 deletions src/pages/Run/index.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -29,6 +29,7 @@ const Root = styled("div")(() => ({
}));

export default function Run() {
const navigate = useNavigate();
const theme = useTheme();
const [params, setParams] = useQueryParams({
status: StringParam,
Expand All @@ -38,7 +39,7 @@ export default function Run() {
const { name } = useParams<RunParams>();
const query = useRun(name === undefined ? "" : name);
if (query === null) return <Typography>404</Typography>;
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;
Expand Down

0 comments on commit f99dc23

Please sign in to comment.